Anyhow my problem is fairly straightforward. I have a simple model viewer which shows my model in the middle of the screen. When I press the keys X,Y or Z the model should rotate in MODEL coordinates. I am trying to use Quaternions to do this.
The results are that I can only get a single axis to rotate in model space, the other two will subsequently rotate in world space. My code is:
D3DXQUATERNION qZ; D3DXQUATERNION qY; D3DXQUATERNION qX; D3DXQUATERNION qOrient; D3DXQUATERNION qTotal; D3DXQuaternionIdentity(&qZ); D3DXQuaternionIdentity(&qY); D3DXQuaternionIdentity(&qX); D3DXQuaternionIdentity(&qOrient); D3DXVECTOR3 axisZ(0,0,1); D3DXVECTOR3 axisY(0,1,0); D3DXVECTOR3 axisX(1,0,0); D3DXQuaternionRotationAxis(&qZ,&axisZ,ga->getRotation().z); D3DXQuaternionRotationAxis(&qY,&axisY,ga->getRotation().y); D3DXQuaternionRotationAxis(&qX,&axisX,ga->getRotation().x); //I am not sure if this is neccessary. D3DXQuaternionNormalize(&qZ,&qZ); D3DXQuaternionNormalize(&qY,&qY); D3DXQuaternionNormalize(&qX,&qX); //The first quat will rotate correctly in model space, the latter 2 will rotate in world space. qTotal=qY*qX*qZ; D3DXMATRIX rotation; D3DXMatrixRotationQuaternion(&rotation,&qTotal); world=scale*rotation*move;
Note that ga is an instance of GameActor and ga->getRotation() returns a D3DXVECTOR3 containing x,y and z rotations in radians.
I would be grateful if anyone could give me a high level approach to solve my problem?
Ben.






