• Advertisement
Sign in to follow this  

[DirectX9.0]How to retrive vector from Camera setting's View Matrix

This topic is 3232 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

I have set view matrix like this: D3DXVECTOR3 vEyePt( 0.0f, 2.0f, -3.0f ); D3DXVECTOR3 vLookatPt( 0.0f, 0.9f, 0.0f ); D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); D3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); I want to retrive the eye, lookat and up vector for a purpose to change the vector.I get the eye point like this way: D3DXMATRIXA16 m; g_pd3dDevice->GetTransform(D3DTS_VIEW, &m); D3DXMATRIX invm; D3DXMatrixInverse(&invm,NULL,&m); D3DXVECTOR3 v; D3DXVECTOR3 cameraLoc; v.x = 0; v.y = 0; v.z = 0; D3DXVec3TransformCoord(&cameraLoc,&v,&invm); Does anybody knows how the get the other lookat and up vector? Thanks in advance.... Kallol

Share this post


Link to post
Share on other sites
Advertisement

A lookAt-Vector can be retrieved but not a lookAt-Point, obviously. If you need the lookAt-Point instead of the vector, you need to store the creation values everytime the camera gets updated, which is probably a good idea anyway.

Kinda like:


void CameraClass::updateCamera(const MYVEC3& eye, const MYVEC3& lookAt, const MYVEC3& up)
{
this.eye = eye;
this.lookAt = lookAt;
this.up = up;

D3DXMatrixLookAtLH( &this.CameraMatrix, &eye, &lookAt, &up );
}


Of course that method should be the only publically available way to change the camera transform.

That makes retrieving the values easy, no need to do some matrix/vector calculations at all.

Alex

Share this post


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

  • Advertisement