• Advertisement
Sign in to follow this  

Rotating volume texture

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