Advertisement Jump to content
Sign in to follow this  

Rotating volume texture using quaternions

This topic is 3725 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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!