Sign in to follow this  
The Pentium Guy

Quick and easy Matrix Question...

Recommended Posts

What part of a matrix (namely the View matrix) returns the Target.. For example: d3ddev.transform.view.M41 returns the X coordinate of the Position, (M42 -> Y Position, M43 = Z position..etc) but which one returns the Target? I don't htink an M51 exists..

Share this post


Link to post
Share on other sites
If by 'target' you mean the look-at point, you cannot extract it directly if you created your view matrix using D3DMatrixLookAt:

Quote:
from MSDN

This function uses the following formula to compute the returned matrix.


zaxis = normal(At - Eye)
xaxis = normal(cross(Up, zaxis))
yaxis = cross(zaxis, xaxis)

xaxis.x yaxis.x zaxis.x 0
xaxis.y yaxis.y zaxis.y 0
xaxis.z yaxis.z zaxis.z 0
-dot(xaxis, eye) -dot(yaxis, eye) -dot(zaxis, eye) 1



Regards,
Pat.

Share this post


Link to post
Share on other sites
A matrix is a stored tranformation in space. It is the ability to translate from one dimension system to another. In short it will store the projection that will be the new direction of the appropiate axis. So you could retrieve the camera direction by looking @ where the Z axis is now pointing in the matrix, but that will give you a direction not a specific point (I'm afraid that is not stored anymore)

Share this post


Link to post
Share on other sites
Sorry for being not explicit enough about that. As ProPuke pointed out, the point is not stored directly in the matrix. If you need to keep track of it, just store it separately in a vector.

Good luck,
Pat.

Share this post


Link to post
Share on other sites
So basically there's no way I can retreieve it unless I mathematically calculate it? Heh taht's what I was trying to avoid..

see what I did was:
dxDevice.Transform.View = Matrix.Multiply(aLookAtMatrix, aYawPitchRollMatrix)

Doing it that way, I can move the character and rotate it... however, I can only move him up down left or right, regardless of how much I rotate him (meaning no matter what direction he faces, he'll only travel up down left or right).

so, since the LookAt point changes when you do Matrix.Multiply(aLookAtMatrix, aYawPitchRollMatrix), I wanted to retreive the new lookatpoint so I could interpolate the Position adn the LookAt point to make him travel in that direction.

any help?

Share this post


Link to post
Share on other sites
Since the YawPitchRoll matrix is a rotation matrix, which is used to rotate stuff, you can use it to move the character forward towards the direction he's looking at. What you need to do is rotate the vector of the movement (0.0f, 0.0f, 1.0f) (forward on the z-axis in your case, I assume) by the rotated matrix.

The result -- the rotated vector is the direction the character should move in order to move "forward".

Hope this helps. Btw, to rotate a vector by a matrix, you need to use D3DXVec3TransformCoord (thats the c++ function. I don't know what the c# one is, but it should be similar).

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