1

ゲームでカメラを回転させるために使用できる変数または方法があるかどうか疑問に思っています。xyz軸に沿って移動できますが、回転する方法がわかりません! :O

変数は次のとおりです。

    Model spaceShip;
    float aspectRatio;
    Vector3 modelPosition = Vector3.Zero;
    float modelRotation = 0f;

    Vector3 cameraPosition = new Vector3(0f, 50f, 5000f);

その描画方法(モデル(宇宙船))は次のとおりです。

        Matrix[] transforms = new Matrix[spaceShip.Bones.Count];
        spaceShip.CopyAbsoluteBoneTransformsTo(transforms);

        foreach (ModelMesh mesh in spaceShip.Meshes)
        {
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.EnableDefaultLighting();
                effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(this.modelRotation) * Matrix.CreateTranslation(this.modelPosition);
                effect.View = Matrix.CreateLookAt(this.cameraPosition, Vector3.Zero, Vector3.Up);
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45f), aspectRatio, 1f,200000f);
            }
            mesh.Draw();
        }

このアスペクト比は次の場所にロードされます。

アスペクト比 = graphics.GraphicsDevice.Viewport.AspectRatio;

4

1 に答える 1

0

カメラの視線方向ベクトルを中心に、シーンのルート コンテナ (カメラを含めないでください。カメラの場合、ルートの外側に別のコンテナが必要です) を回転させることができます。

于 2012-11-27T14:58:51.793 に答える