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.

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; }

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• Forum Statistics

• Total Topics
633366
• Total Posts
3011527
• Who's Online (See full list)

There are no registered users currently online

×