请帮我解决以下问题?
解释它的图片如下:
请回答,谢谢
答案 0 :(得分:1)
除了围绕vector3点旋转相机外,您还可以将其用作相机正在查看的目标。然后你只需要改变相机在该点附近的位置。看来用于制作相机的向上矢量将始终保持不变。你提到的是Z轴,但是XNA是一个Y-up系统,所以从图像中你可以绕Y轴进行旋转。
Vector3 pivotPoint = new Vector3(?, ?, ?);
cameraPosition = Vector3.Transform(cameraPosition - pivotPoint, Matrix.CreateRotationY(anglePerFrame)) + pivotPoint;
View = Matrix.CreatLookAt(cameraPosition, pivotPoint, Vector3.Up);
Matrix billboardWorld = Matrix.Identity;
billBoardWorld.Forward = Vector3.Normalize(cameraPosition - pivotPoint);
billboardWorld.Right = Vector3.Normalize(Vector3.Cross(billboardWorld.Forward, Vector3.Up));
billboardWorld.Translation = cameraPosition - (billboardWorld.Backwards * distFromCamera);
答案 1 :(得分:1)
请注意,XNA为此Matrix.CreateBillboard(...)提供了帮助,但是如果您可以访问相机矩阵,则可能更容易执行以下操作:
var billboardWorld = Matrix.Invert(camera.ViewMatrix);
billboardWorld.Translation = billboardPosition;