Jump to content
  • Advertisement
Sign in to follow this  

Rotating volume texture

This topic is 3682 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'm rendering the volume (IDirect3DVolumeTexture9). To rotate it I use texture transform matrix which is based on quaternions. Everything works fine except that texture rotates around it's local axis but I need it to rotate around the global axis. For example I render the human's head and by default the camera is directed to human's left ear. I say "Rotate around Z axis" (nod the head) and it nods. But when I rotate the head around Y axis and then I say "Rotate around Z axis" I expect the head to tilt towards me but it doesn't - the head nods. The reason for this is quite obvious. When I rotate the texture it's local axis also rotate. But does anybody know what I should do to make my head rotate around global axis? That mean when I say "Rotate around Y axis" - the head must rotate around global Y axis but not around the local one. I have to simulate camera rotation around the head. Here's the code which allows the head to rotate around it's local axis:
//Gets texture transformation matrix.
D3DXMATRIX MyTexture::GetTransformMatrix()
    D3DXMATRIX result;
    D3DXMATRIX transformMatrix;

    //Current texture rotation.
    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;

Any help appriciated.

Share this post

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

  • Advertisement

Important Information

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

GameDev.net 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!