我想知道是否有一个变量或方法可以用来在我的游戏中旋转相机。我可以沿 xyz 轴移动它,但我不知道如何旋转它!:O
以下是变量:
Model spaceShip;
float aspectRatio;
Vector3 modelPosition = Vector3.Zero;
float modelRotation = 0f;
Vector3 cameraPosition = new Vector3(0f, 50f, 5000f);
这是它的绘制方式(模型(宇宙飞船)):
Matrix[] transforms = new Matrix[spaceShip.Bones.Count];
spaceShip.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in spaceShip.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(this.modelRotation) * Matrix.CreateTranslation(this.modelPosition);
effect.View = Matrix.CreateLookAt(this.cameraPosition, Vector3.Zero, Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45f), aspectRatio, 1f,200000f);
}
mesh.Draw();
}
并且这个纵横比被加载到:
aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;