私のXNAゲームでは、2次元物理エンジンであるFarseer Physicsが使用されています。物理エンジンには、物理エンジンデータ用のレンダラー(オプション)があり、デバッグに役立ちます。ビジュアルデバッグデータは非常に便利なので、カメラの状態に合わせて設定することができます。 z軸の回転を除いて、これは完全に機能します。移動、ズーム、z軸の回転をサポートするカメラクラスがあります。私のデバッグクラスは、Farseerのデバッグレンダラーを使って、カメラに応じてデバッグデータを作成する行列を作成します。ただし、1つのことを除いてうまくいきます。z軸の回転は、画面の左上隅を( 0、0)、ビューポートの中心を(0、0)としてカメラが回転します。誰も私のためのヒントを持っていますか?デバッグドロワを中央から回転させることができれば、カメラで完璧に動作します。この行列を中心にどのように回転できますか?
public void Draw(Camera2D camera, GraphicsDevice graphicsDevice)
{
// Projection (location and zoom)
float width = (1f/camera.Zoom) * ConvertUnits.ToSimUnits(graphicsDevice.Viewport.Width/2);
float height = (-1f/camera.Zoom) * ConvertUnits.ToSimUnits(graphicsDevice.Viewport.Height/2);
//projection = Matrix.CreateOrthographic(width, height, 1f, 1000000f);
projection = Matrix.CreateOrthographicOffCenter(
-width,
width,
-height,
height,
0f, 1000000f);
// View (translation and rotation)
float xTranslation = -1 * ConvertUnits.ToSimUnits(camera.Position.X);
float yTranslation = -1 * ConvertUnits.ToSimUnits(camera.Position.Y);
Vector3 translationVector = new Vector3(xTranslation, yTranslation, 0f);
view = Matrix.CreateRotationZ(camera.Rotation) * Matrix.Identity;
view.Translation = translationVector;
DebugViewXNA.RenderDebugData(ref projection, ref view);
}
私はそれを試みましたが、それでも左上隅を回転しているようです。たぶん私は誤解しているかもしれません。おそらくコードスニペットを見ることはできますか? –