我用
设置了相机 _aspectRatio = device.Viewport.AspectRatio;
_projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(90.0f),_aspectRatio,0.1f,10000.0f);
使用Update设置视图矩阵,_position由旋转定义的旋转设置。
private void Update()
{
_viewMatrix = Matrix.CreateLookAt(_position, _lookAt, Vector3.Up);
}
public void Rotate(float angle)
{
rotation += angle;
_position = Vector3.Transform(_position, Matrix.CreateRotationY(angle));
Update();
}
要在字段中设置精灵,我使用以下代码:
_effect.Parameters["xWorld"].SetValue(Matrix.CreateRotationY(camera.rotation) * PositionMatrix);
_effect.Parameters["xView"].SetValue(camera.ViewMatrix);
_effect.Parameters["xProjection"].SetValue(camera.ProjectionMatrix);
_effect.Parameters["xTexture"].SetValue(_texture);
它正在工作,精灵用相机平面看着相机垂直。当相机位置矢量改变时,问题就会出现,精灵保持初始角度,我不知道在哪里可以计算精灵的改变Y旋转。
答案 0 :(得分:0)
解决方案是我在相机课程中进行了y旋转。在那个课程中,我有一个方法可以看到y旋转。