D3DXMath の操作
D3DXMath は、Direct3D アプリケーション用の数学ヘルパー ライブラリです。 D3DXMath は長い歴史があり、D3DX 9 と D3DX 10 に含まれており、以前のバージョンの DirectX にもまで遡ります。
注意
D3DX ユーティリティ ライブラリ (D3DX 9、D3DX 10、D3DX 11) は Windows 8 では非推奨であるため、D3DXMath を使用するのではなく DirectXMath に移行することを強くお勧めします。
DirectXMath は D3DXMath で同じ機能の多くを共有し、内部的には D3DXMath にはプロセッサ固有の最適化が多数含まれています。 主な違いは、D3DXMath が D3DX9* でホストされていることです。DLL と D3DX10*。DLL と非常に少数の関数がインライン化されています。 DirectXMath ライブラリの呼び出し規則は明示的に SIMD フレンドリですが、D3DXMath では SIMD 最適化を実装するために読み込みおよび格納変換を実行する必要があります。
DirectXMath と D3DXMath の混在
D3DX11 には D3DXMath が含まれていません。一般に、代わりに DirectXMath を使用することをお勧めします。 ただし、アプリケーション内の D3DX9 や D3DX10 へのリンクを引き続き自由に行うことができるため、D3DXMath を引き続き使用することも、アプリケーションで D3DXMath と DirectXMath の両方を同時に使用することもできます。
一般に、XMVECTOR* を D3DXVECTOR4* を受け取る関数にキャストするか、または D3DXMATRIX* を受け取る関数に XMMATRIX* をキャストしても安全です。 ただし、逆関数は一般に安全ではありません。XMVECTOR と XMMATRIX は 16 バイトのアラインが必要ですが、D3DXVECTOR4 と D3DXMATRIX にはそのような要件はありません。 この要件に従わないと、実行時に無効なアラインメント例外が発生する可能性があります。
XMVECTOR* を D3DXVECTOR2* または D3DXVECTOR3* を受け取る関数にキャストしても安全ですが、その逆は実行できません。 配置の問題と、D3DXVECTOR2 と D3DXVECTOR3 が小さい構造であるという事実の両方が、この操作を安全でない操作にします。
注意
D3DX (したがって D3DXMath) はレガシと見なされ、Windows 8 で実行され、デスクトップ アプリ用 Windows 8 SDK には含まれていない Windows ストア アプリでは使用できません。
Direct3D での DirectXMath の使用
Direct3D を使用する場合、DirectXMath と D3DXMath はどちらも省略可能です。 Direct3D 9 では、(従来の) 固定関数パイプラインをサポートする Direct3D API の一部として D3DMATRIX と D3DCOLOR が定義されています。 D3DX9 の D3DXMath は、一般的なグラフィックス演算を使用して、これらの Direct3D 9 型を拡張します。 Direct3D 10.x および Direct3D 11 の場合、API はプログラミング可能なパイプラインのみを使用するため、マトリックスまたは色値に対する API 固有の構造はありません。 新しい API でカラー値が必要な場合は、浮動小数点値の明示的な配列または HLSL シェーダーによって解釈される定数データのジェネリック バッファーを受け取ります。 HLSL 自体は行メジャーまたは列メジャーのマトリックス形式をサポートできるため、レイアウトは完全にユーザーの責任です (詳細については、「HLSL、 マトリックス順序」を参照してください。シェーダーで列メジャー マトリックス形式を使用する場合は、定数バッファー構造に配置するときに DirectXMath マトリックス データを入れ替える必要があります)。 オプションですが、DirectXMath ライブラリと D3DXMath ライブラリはどちらも一般的なグラフィックス関連の機能を提供するため、Direct3D プログラミングを行うときに非常に便利です。
Direct3D 9 では受信データ構造に関するアラインメントの前提条件がないため、XMVECTOR* を D3DVECTOR* または XMMATRIX* に D3DMATRIX* にキャストしても安全です。 また、XMCOLOR を D3DCOLOR にキャストしても安全です。 4 float の色表現を XMStoreColor() を使用して XMCOLOR に変換すると、D3DCOLOR と同等の 8:8:8:8 32 ビット DWORD を取得できます。
Direct3D 10.x または Direct3D 11 を使用する場合、通常は DirectXMath 型を使用して各定数バッファーの構造を構築します。このような場合は、これらの効率を高めるために配置を制御する機能、または XMVECTOR と XMMATRIX データを正しいデータ型に変換する XMStore*() 操作を使用する機能に大きく依存します。 色値の float[4] 配列を必要とする Direct3D 10.x または Direct3D 11 API を呼び出す場合は、カラー データを含む XMVECTOR* または XMFLOAT4* をキャストできます。
D3DXMath からの移植
D3DXMath 型 | DirectXMath と同等 |
---|---|
D3DXFLOAT16 | 半分 |
D3DXMATRIX | XMFLOAT4X4 |
D3DXMATRIXA16 | XMMATRIX または XMFLOAT4X4A |
D3DXQUATERNION D3DXPLANE D3DXCOLOR |
XMVECTOR は一意の型ではなく使用されるため、 XMFLOAT4Note:**D3DXQUATERNION::operator *** は D3DXQuaternionMultiply 関数を呼び出し、2 つの四元数を乗算する必要があります。 ただし、 XMQuaternionMultiply 関数を明示的に使用しない限り、四元数で **XMVECTOR::operator *** を 使用すると正しくない答えが得られます。 |
D3DXVECTOR2 | XMFLOAT2 |
D3DXVECTOR2_16F | XMHALF2 |
D3DXVECTOR3 | XMFLOAT3 |
D3DXVECTOR4 | XMFLOAT4(または、データが 16 バイトアライン済みであることを保証できる場合は、 XMVECTOR または XMFLOAT4A ) |
D3DXVECTOR4_16F | XMHALF4 |
注意
XNAMath のD3DXVECTOR3_16Fに相当するものはありません。
D3DXMath マクロ | DirectXMath と同等 |
---|---|
D3DX_PI | XM_PI |
D3DX_1BYPI | XM_1DIVPI |
D3DXToRadian | XMConvertToRadians |
D3DXToDegree | XMConvertToDegrees |
D3DXMath 関数 | DirectXMath と同等 |
---|---|
D3DXBoxBoundProbe | BoundingBox::Intersects(XMVECTOR, XMVECTOR, float&) |
D3DXComputeBoundingBox | BoundingBox::CreateFromPoints |
D3DXComputeBoundingSphere | BoundingSphere::CreateFromPoints |
D3DXSphereBoundProbe | BoundingSphere::Intersects(XMVECTOR, XMVECTOR, float&) |
D3DXIntersectTriFunction | TriangleTests::Intersects |
D3DXFloat32To16Array | XMConvertFloatToHalfStream |
D3DXFloat16To32Array | XMConvertHalfToFloatStream |
D3DXVec2Length | XMVector2Length または XMVector2LengthEst |
D3DXVec2LengthSq | XMVector2LengthSq |
D3DXVec2Dot | XMVector2Dot |
D3DXVec2CCW | XMVector2Cross |
D3DXVec2Add | XMVectorAdd |
D3DXVec2Subtract | XMVectorSubtract |
D3DXVec2Minimize | XMVectorMin |
D3DXVec2Maximize | XMVectorMax |
D3DXVec2Scale | XMVectorScale |
D3DXVec2Lerp | XMVectorLerp または XMVectorLerpV |
D3DXVec2Normalize | XMVector2Normalize または XMVector2NormalizeEst |
D3DXVec2Hermite | XMVectorHermite または XMVectorHermiteV |
D3DXVec2CatmullRom | XMVectorCatmullRom または XMVectorCatmullRomV |
D3DXVec2BaryCentric | XMVectorBaryCentric または XMVectorBaryCentricV |
D3DXVec2Transform | XMVector2Transform |
D3DXVec2TransformCoord | XMVector2TransformCoord |
D3DXVec2TransformNormal | XMVector2TransformNormal |
D3DXVec2TransformArray | XMVector2TransformStream |
D3DXVec2TransformCoordArray | XMVector2TransformCoordStream |
D3DXVec2TransformNormalArray | XMVector2TransformNormalStream |
D3DXVec3Length | XMVector3Length または XMVector3LengthEst |
D3DXVec3LengthSq | XMVector3LengthSq |
D3DXVec3Dot | XMVector3Dot |
D3DXVec3Cross | XMVector3Cross |
D3DXVec3Add | XMVectorAdd |
D3DXVec3Subtract | XMVectorSubtract |
D3DXVec3Minimize | XMVectorMin |
D3DXVec3Maximize | XMVectorMax |
D3DXVec3Scale | XMVectorScale |
D3DXVec3Lerp | XMVectorLerp または XMVectorLerpV |
D3DXVec3Normalize | XMVector3Normalize または XMVector3NormalizeEst |
D3DXVec3Hermite | XMVectorHermite または XMVectorHermiteV |
D3DXVec3CatmullRom | XMVectorCatmullRom または XMVectorCatmullRomV |
D3DXVec3BaryCentric | XMVectorBaryCentric または XMVectorBaryCentricV |
D3DXVec3Transform | XMVector3Transform |
D3DXVec3TransformCoord | XMVector3TransformCoord |
D3DXVec3TransformNormal | XMVector3TransformNormal |
D3DXVec3TransformArray | XMVector3TransformStream |
D3DXVec3TransformCoordArray | XMVector3TransformCoordStream |
D3DXVec3TransformNormalArray | XMVector3TransformNormalStream |
D3DXVec3Project | XMVector3Project |
D3DXVec3Unproject | XMVector3Unproject |
D3DXVec3ProjectArray | XMVector3ProjectStream |
D3DXVec3UnprojectArray | XMVector3UnprojectStream |
D3DXVec4Length | XMVector4Length または XMVector4LengthEst |
D3DXVec4LengthSq | XMVector4LengthSq |
D3DXVec4Dot | XMVector4Dot |
D3DXVec4Add | XMVectorAdd |
D3DXVec4Subtract | XMVectorSubtract |
D3DXVec4Minimize | XMVectorMin |
D3DXVec4Maximize | XMVectorMax |
D3DXVec4Scale | XMVectorScale |
D3DXVec4Lerp | XMVectorLerp または XMVectorLerpV |
D3DXVec4Cross | XMVector4Cross |
D3DXVec4Normalize | XMVector4Normalize または XMVector4NormalizeEst |
D3DXVec4Hermite | XMVectorHermite または XMVectorHermiteV |
D3DXVec4CatmullRom | XMVectorCatmullRom または XMVectorCatmullRomV |
D3DXVec4BaryCentric | XMVectorBaryCentric または XMVectorBaryCentricV |
D3DXVec4Transform | XMVector4Transform |
D3DXVec4TransformArray | XMVector4TransformStream |
D3DXMatrixIdentity | XMMatrixIdentity |
D3DXMatrixDeterminant | XMMatrixDeterminant |
D3DXMatrixDecompose | XMMatrixDecompose |
D3DXMatrixTranspose | XMMatrixTranspose |
D3DXMatrixMultiply | XMMatrixMultiply |
D3DXMatrixMultiplyTranspose | XMMatrixMultiplyTranspose |
D3DXMatrixInverse | XMMatrixInverse |
D3DXMatrixScaling | XMMatrixScaling |
D3DXMatrixTranslation | XMMatrixTranslation |
D3DXMatrixRotationX | XMMatrixRotationX |
D3DXMatrixRotationY | XMMatrixRotationY |
D3DXMatrixRotationZ | XMMatrixRotationZ |
D3DXMatrixRotationAxis | XMMatrixRotationAxis |
D3DXMatrixRotationQuaternion | XMMatrixRotationQuaternion |
D3DXMatrixRotationYawPitchRoll | XMMatrixRotationRollPitchYaw (パラメーターの順序が異なる点に注意してください:D3DXMatrixRotationYawPitchRoll は、ヨー、ピッチ、ロール、 XMMatrixRotationRollPitchYaw がピッチ、ヨー、ロールを取ります) |
D3DXMatrixTransformation | XMMatrixTransformation |
D3DXMatrixTransformation2D | XMMatrixTransformation2D |
D3DXMatrixAffineTransformation | XMMatrixAffineTransformation |
D3DXMatrixAffineTransformation2D | XMMatrixAffineTransformation2D |
D3DXMatrixLookAtRH | XMMatrixLookAtRH |
D3DXMatrixLookAtLH | XMMatrixLookAtLH |
D3DXMatrixPerspectiveRH | XMMatrixPerspectiveRH |
D3DXMatrixPerspectiveLH | XMMatrixPerspectiveLH |
D3DXMatrixPerspectiveFovRH | XMMatrixPerspectiveFovRH |
D3DXMatrixPerspectiveFovLH | XMMatrixPerspectiveFovLH |
D3DXMatrixPerspectiveOffCenterRH | XMMatrixPerspectiveOffCenterRH |
D3DXMatrixPerspectiveOffCenterLH | XMMatrixPerspectiveOffCenterLH |
D3DXMatrixOrthoRH | XMMatrixOrthographicRH |
D3DXMatrixOrthoLH | XMMatrixOrthographicLH |
D3DXMatrixOrthoOffCenterRH | XMMatrixOrthographicOffCenterRH |
D3DXMatrixOrthoOffCenterLH | XMMatrixOrthographicOffCenterLH |
D3DXMatrixShadow | XMMatrixShadow |
D3DXMatrixReflect | XMMatrixReflect |
D3DXQuaternionLength | XMQuaternionLength |
D3DXQuaternionLengthSq | XMQuaternionLengthSq |
D3DXQuaternionDot | XMQuaternionDot |
D3DXQuaternionIdentity | XMQuaternionIdentity |
D3DXQuaternionIsIdentity | XMQuaternionIsIdentity |
D3DXQuaternionConjugate | XMQuaternionConjugate |
D3DXQuaternionToAxisAngle | XMQuaternionToAxisAngle |
D3DXQuaternionRotationMatrix | XMQuaternionRotationMatrix |
D3DXQuaternionRotationAxis | XMQuaternionRotationAxis |
D3DXQuaternionRotationYawPitchRoll | XMQuaternionRotationRollPitchYaw (パラメーターの順序が異なる点に注意してください:D3DXQuaternionRotationYawPitchRoll はヨー、ピッチ、ロール、 XMQuaternionRotationRollPitchYaw がピッチ、ヨー、ロールを受け取ります) |
D3DXQuaternionMultiply | XMQuaternionMultiply |
D3DXQuaternionNormalize | XMQuaternionNormalize または XMQuaternionNormalizeEst |
D3DXQuaternionInverse | XMQuaternionInverse |
D3DXQuaternionLn | XMQuaternionLn |
D3DXQuaternionExp | XMQuaternionExp |
D3DXQuaternionSlerp | XMQuaternionSlerp または XMQuaternionSlerpV |
D3DXQuaternionSquad | XMQuaternionSquad または XMQuaternionSquadV |
D3DXQuaternionSquadSetup | XMQuaternionSquadSetup |
D3DXQuaternionBaryCentric | XMQuaternionBaryCentric または XMQuaternionBaryCentricV |
D3DXPlaneDot | XMPlaneDot |
D3DXPlaneDotCoord | XMPlaneDotCoord |
D3DXPlaneDotNormal | XMPlaneDotNormal |
D3DXPlaneScale | XMVectorScale |
D3DXPlaneNormalize | XMPlaneNormalize または XMPlaneNormalizeEst |
D3DXPlaneIntersectLine | XMPlaneIntersectLine |
D3DXPlaneFromPointNormal | XMPlaneFromPointNormal |
D3DXPlaneFromPoints | XMPlaneFromPoints |
D3DXPlaneTransform | XMPlaneTransform |
D3DXPlaneTransformArray | XMPlaneTransformStream |
D3DXColorNegative | XMColorNegative |
D3DXColorAdd | XMVectorAdd |
D3DXColorSubtract | XMVectorSubtract |
D3DXColorScale | XMVectorScale |
D3DXColorModulate | XMColorModulate |
D3DXColorLerp | XMVectorLerp または XMVectorLerpV |
D3DXColorAdjustSaturation | XMColorAdjustSaturation |
D3DXColorAdjustContrast | XMColorAdjustContrast |
D3DXFresnelTerm | XMFresnelTerm |
注意
DirectXMath の球面調和関数は個別に使用できます。 ID3DXMatrixStack と同等の DirectXMath も使用できます。
関連トピック
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示