# Quick and easy Matrix Question...

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

## 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 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 MSDNThis 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 on other sites
Sorry, I don't get what you mean...

##### 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 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 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 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 on other sites
Thanks, I'll look into this

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
11

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007711
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!