CHAPTER 2 ■ SETTING UP DIFFERENT CAMERA MODES IN YOUR 3D WORLD
57
viewMatrix = Matrix.CreateLookAt(cameraFinalPosition, ➥
spacecraftPosition, cameraRotatedUpVector);
}
And in the Draw cycle, you need to rotate and translate your spacecraft according to its
current rotation and position:
Matrix worldMatrix = Matrix.CreateScale(0.001f, 0.001f,
➥
0.001f)*Matrix.CreateFromQuaternion(spacecraftRotation)* ➥
Matrix.CreateTranslation(spacecraftPosition);
spacecraftModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
foreach (ModelMesh mesh in spacecraftModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
effect.View = viewMatrix;
effect.Projection ...