私の XNA ゲームでは、物理エンジン データ用のオプションのレンダラーを備えた 2D 物理エンジンである 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);
}