我想知道是否有一个变量或方法可以用来在我的游戏中旋转相机。我可以沿着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;
答案 0 :(得分:0)
你可以尝试旋转场景的根容器(不应该包含摄像头,对于摄像头,你应该在根目录外面有另一个容器)围绕摄像头看方向矢量