Sign in to follow this  

XNA to D3D9

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.

public Vector3 Direction
get { return worldMatrix.Forward; } // Looking forward how to get this with D3D9 libraries
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);

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this