如何将目标相机更改为跟随?
目标:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Flight
{
public class FollowCamera : CCamera
{
public Vector3 Target { get; set; }
public FollowCamera(Vector3 Position, Vector3 Target,
GraphicsDevice graphicsDevice)
: base(graphicsDevice)
{
this.Position = Position;
this.Target = Target;
}
public override void Update()
{
//Missing lines of code used to determine
//the up vector
Vector3 forward = Target - Position;
Vector3 right = Vector3.Cross(forward, Vector3.Up);
Vector3 up = Vector3.Cross(right, forward);
this.View = Matrix.CreateLookAt(Position,
Target, up);
}
}
}
我确实有线索可以使用这行代码进行一些修改,并添加相机应该在目标后面多远的长度。这行代码让我的船绕着屏幕飞过去,现在我需要确保相机随船一起移动。请帮忙
this.local = Matrix.CreateFromYawPitchRoll(orientation.Y, orientation.X, orientation.Z) * Matrix.CreateTranslation(position.X, position.Y, position.Z) * this.local;