1
我的相機設置與XNA廣告牌精靈相機平面
_aspectRatio = device.Viewport.AspectRatio;
_projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(90.0f),_aspectRatio,0.1f,10000.0f);
視圖矩陣獲取設置與更新,並_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);
這是工作,精靈是看用相機平面相機perpendiculair。當攝像機位置矢量改變時,問題即將到來,精靈正在保持初始角度,我不知道在哪裏可以計算出精靈變化的Y軸旋轉。