1
我想知道是否有一個變量或方式我可以用來旋轉我的遊戲中的相機。我可以沿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;
的可能重複: HTTP:/ /stackoverflow.com/questions/5906907/xna-rotate-camera-around-its-createlookat-target 另外,看看這個例子:http://msdn.microsoft.com/en-us/library/bb197901.aspx – surfen