tags:

views:

14

answers:

1

Is there a way to rotate an object along a different plane? I am making a 3D model of the solar system, and I'd like to get Pluto to revolve around the sun on a different plane to that of the other planets. I currently have the first eight planets revolving around the sun in the xz plane(rotation about the y-axis). Is there an easy way to do this without getting into complex math? This is how I've implemented my other planets,

D3DXMATRIX marsMat;
D3DXMATRIX marsScale;
D3DXMATRIX marsTrans;
D3DXMATRIX marsAxisRot;
D3DXMATRIX marsRot;

D3DXMatrixScaling(&marsScale,0.45,0.45,0.45);
D3DXMatrixRotationY(&marsAxisRot,D3DXToRadian((GetTickCount()-start)*0.07));
D3DXMatrixTranslation(&marsTrans,-17,0,0);
D3DXMatrixRotationY(&marsRot,D3DXToRadian((GetTickCount()-start)*0.007));

marsMat = marsScale * marsAxisRot * marsTrans * marsRot;

matrixStack->Push();
{
   matrixStack->MultMatrixLocal(&marsMat);
   d3ddev->SetTransform(D3DTS_WORLD,matrixStack->GetTop());
   marsMesh->DrawSubset(0);
}
matrixStack->Pop();
A: 

D3DXMatrixRotationAxis is what you want.

Remember a plane is in fact a vector perpendicular to the plane it describes where the D parameter describes the distance from the origin. So use the A, B and C parameters to create a vector. Normalise it and use it as your rotation axis. You can then translate it such that its origin is whatever the location of your sun is (which may well be the origin point of the rotation anyway).

Goz
Cheers mate. Works like a charm.
lightnin2211