0
如何更改目標攝像頭?關注攝像頭XNA 4.0 C#
目標:
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;