[英]How to Rotate a Camera - Camera Rotation
我想知道我是否可以使用變量或方式來旋轉相機。 我可以沿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;
您可以嘗試圍繞攝像機的視線方向矢量旋轉場景的根容器(該根容器不應包含照相機,對於照相機,您應該在根的外部有另一個容器)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.