#### Archived

This topic is now archived and is closed to further replies.

# Getting Eyepoint from View Matrix

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

## Recommended Posts

Does anyone know how to calculate the camera eyepoint directly from the view matrix? I am doing matrix multiplicatons (translation and rotation) directly on the view matrix to change my viewpoint, as opposed to using the D3DXMatrixLookAtLH, but still need to keep track of my position in world coordinates. Any help is appreciated.

##### Share on other sites
Oooh! You''re not using LookAtLH! I can''t figure out how to make it work without using that! Plz can I ''borrow'' a bit of your source code? Have pity on a poor newbie to 3D stuff!

---------------

I finally got it all together...
...and then forgot where I put it.

##### Share on other sites
Check the Point Sprites sample code in DirectX 8.1 - UpdateCamera().

Back to the original question - Does anyone know how to get eyepoint position directly from the view matrix?

##### Share on other sites
Thanks. About your question - shouldn''t you be building your view matrix from your eye co-ords? If you are, what''s the problem with just storing them?

---------------

I finally got it all together...
...and then forgot where I put it.

##### Share on other sites
I am building it from mouse or key presses to change the viewpoint translation/rotation (like the point sprites sample), so I do not input eyepoint position.

##### Share on other sites
Matrices are nothing more than transformations from one coordinate system to another. A ''view'' matrix takes coordinates from world space, and transforms them to view space. If you invert the view matrix, you will have a matrix that takes coordinates from view space, and transforms them to world space. Since the camera is defined to be at the origin in view space, all you need to do is transform (0,0,0,1) by this inverse view matrix, and you will have the camera''s position in world space. (Node that transforming (0,0,0,1) by a matrix is equivalent to simply copying the last row.)
D3DXMATRIX mViewInv;D3DXMatrixInverse(&mViewInv, NULL, &mView);D3DXVECTOR3 vPosition;vPosition.x = mViewInv._41;vPosition.y = mViewInv._42;vPosition.z = mViewInv._43;

xyzzy

##### Share on other sites
Thanks for the little tutorial & code! It works great.

1. 1
Rutin
26
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002135
×