Jump to content
  • Advertisement
Sign in to follow this  
Nesta

Rotating volume texture using quaternions

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

Hello everyone. I render the volume texture (IDirect3DVolumeTexture9). I place my camera in the static position (0, 0, -10) and rotate texture using texture transform matrix. I also use quaternions to avoid Gimbal Lock. The problem occurs when I rotate texture at 90 degrees. For example if I rotate texture around X axis Y axis becomes Z and Z axis becomes Y. The same happens when I rotate texture around Y axis, so Z becomes X and X becomes Z. Has anybody faced this problem before? Here is the code to generate the gexture transform matrix: //Gets texture transformation matrix. D3DXMATRIX MyTexture::GetTransformMatrix() { D3DXMATRIX result; D3DXMATRIX transformMatrix; //Current texture rotation. D3DXQUATERNION quat; D3DXQuaternionRotationYawPitchRoll(&quat, D3DXToRadian(m_YawOffset), D3DXToRadian(m_PitchOffset), D3DXToRadian(m_RollOffset)); m_TransformQuaternion *= quat; //m_TransformQuaternion stores texture rotation parameters and is updated every time when camera is moved. //Because this method is called every time when WM_PAINT //these variables need to be set to NULL. Otherwise the camera //will rotate on each WM_PAINT m_YawOffset = 0.0f; m_PitchOffset = 0.0f; m_RollOffset = 0.0f; //Converting from quaternion to matrix D3DXMatrixRotationQuaternion(&transformMatrix, &m_TransformQuaternion); result = transformMatrix; return result; }

Share this post


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

  • 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!