Sign in to follow this  

XNA to D3D9

This topic is 2605 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I moved to D3D9 because the limitations of C# and XNA, so far so good.

But now I hit to wall. I don't know how to make this in Cplusplus using D3D9 libraries.

[SOURCE]
public Vector3 Direction
{
get { return worldMatrix.Forward; } // Looking forward how to get this with D3D9 libraries
set
{
Vector3 position = worldMatrix.Translation; // Looking forward how to get this too
Vector3 forward = value;
if (forward == Vector3.Up || forward == Vector3.Down)
{
Vector3 right = Vector3.Right;
Vector3.Cross(ref right, ref forward, out up); //D3DXVec3Cross
}

//And for this too
Matrix.CreateWorld(ref position, ref forward, ref up, out worldMatrix);
}
}
[/SOURCE]
[/source]

Share this post


Link to post
Share on other sites
Your typical row-major transformation matrix is laid out like this:

X = local X-axis
Y = local Y-axis
Z = local Z-axis
T = translation

[Xx] [Xy] [Xz] [0]
[Yx] [Yy] [Yz] [0]
[Zx] [Zy] [Zz] [0]
[Tx] [Ty] [Tz] [1]


So for "Forward" you just want the local Z-axis, which is in the _31, _32, and _33 elements of a D3DXMATRIX. For Translation you want the 4th row.

Share this post


Link to post
Share on other sites
Sign in to follow this