Jump to content
  • Advertisement

Archived

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

shakazed

About quaternions.

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

Does anyone have some working code in how to implement quaternions to rotate the camera. (In Direct3D that is) I´ve read some things about quats but I don´t know how to implement them. Any help appreciated.
Bad Monkey Productions

Share this post


Link to post
Share on other sites
Advertisement

  D3DXQUATERNION qR;
D3DXQuaternionRotationYawPitchRoll(&qR, m_fYaw, m_fPitch, m_fRoll);
D3DXMatrixAffineTransformation(&m_matOrientation, 1.25f, NULL, &qR, &m_vPosition );
D3DXMatrixInverse( &m_matView, NULL, &m_matOrientation );


Then m_matView you use for your view matrix.

--Helicon56.

Share this post


Link to post
Share on other sites
Thank you very much! I really don´t know jacks-bhind about quats so can I do like this...


  

D3DXMATRIX m_matOrientation;
D3DXQUATERNION qR;
D3DXQuaternionRotationYawPitchRoll(&qR, m_fYaw, m_fPitch, m_fRoll);
D3DXMatrixAffineTransformation(&m_matOrientation, 1.25f, NULL, &qR, &m_vPosition );
D3DXMatrixInverse( &m_matView, NULL, &m_matOrientation );
iD3DDevice8->SetTransform(D3DTS_VIEW, m_matView);



...to rotate my camera? Is m_vPosition the camera´s lookat position?





Bad Monkey Productions

Share this post


Link to post
Share on other sites
Yeah that should work fine. m_vPosition is the position of the camera in the world. You specify it''s look at point by changing it''s yaw pitch and roll. Just play around with it for a while and you''ll figure it out.

--Helicon56.

Share this post


Link to post
Share on other sites
Hmm, I´m trying to use this code to rotate it but nothing happends when I do.


  
D3DXMATRIX m_matOrientation;
D3DXQUATERNION qR;

D3DXQuaternionRotationYawPitchRoll(&qR, 0.0f, 0.0f, 0.0f);
D3DXMatrixAffineTransformation(&m_matOrientation, 1.25f, NULL, &qR, &D3DXVECTOR3(0.0f,0.0f,0.0f));
D3DXMatrixInverse( &m_matView, NULL, &m_matOrientation );
m_iD3DDevice8->SetTransform(D3DTS_VIEW, &matView);


Any ideas on what I´m doing wrong. I´m trying to render a textured quad, when i use the ordinary lookat function it works just fine.




Bad Monkey Productions

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!