3D Camera Setup
Introduction
Looking down a different axis
// Make the camera look down the Y axis so that Z is up:
Camera.Main.RotationX = (float)System.Math.PI / 2.0f;
// Since we're not looking down the Z axis turn off culling
Camera.Main.CameraCullMode = CameraCullMode.None;
// If the XY plane is the ground then Z is up.
// Give the camera an altitude of 1 units.
Camera.Main.Z = 1;
// This keeps the camera oriented so that the up vector is positive Z:
Camera.Main.UpVector = new Vector3(0, 0, 1);
// Place a bunch of Sprites in the world on the XY plane
for (int i = 0; i < 200; i++)
{
Sprite sprite = SpriteManager.AddSprite("redball.png");
sprite.X = -50 + 100 * (float)FlatRedBallServices.Random.NextDouble();
sprite.Y = 100 * (float)FlatRedBallServices.Random.NextDouble();
// Make the Sprite "sit" on the ground
sprite.Z = sprite.ScaleY;
// Spin the Sprites so that they sit on the XZ plane (facing the camera)
sprite.RotationX = (float)System.Math.PI / 2.0f;
}
// Set the sort type to distance along forward vector or else Sprites won't
// sort properly.
SpriteManager.OrderedSortType = SortType.DistanceAlongForwardVector;
Last updated
Was this helpful?