Sign in to follow this  

Rotating volume texture using quaternions

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this