我是一个初学者,所以我可能在某些基本层面上感到困惑,但我似乎用以下两个 Draw() 例程得到了相同的结果,我想知道有什么区别,一个比另一个更正确吗?
在一个中,我将变换应用于世界矩阵,在另一个中,我将变换应用于 veiw 矩阵。我认为结果完全一样,但我不是 100% 确定。
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
Matrix worldMatrix =
Matrix.CreateTranslation(view.Position.X, view.Position.Y, view.Position.Z) *
Matrix.CreateRotationX(view.Rotation.X) *
Matrix.CreateRotationY(view.Rotation.Y) *
Matrix.CreateRotationZ(view.Rotation.Z);
Matrix viewMatrix = Matrix.CreateLookAt(view.CameraPosition, view.CameraTarget, view.CameraUp);
Matrix projectionMatrix = Matrix.CreatePerspectiveFieldOfView(view.FieldOfView,
GraphicsDevice.Viewport.AspectRatio,
view.NearPlane,
view.FarPlane);
DrawModels(worldMatrix, viewMatrix, projectionMatrix);
base.Draw(gameTime);
}
这与以下有何不同:
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
Matrix worldMatrix = Matrix.Identity;
Matrix viewMatrix =
Matrix.CreateTranslation(view.Position.X, view.Position.Y, view.Position.Z) *
Matrix.CreateRotationX(view.Rotation.X) *
Matrix.CreateRotationY(view.Rotation.Y) *
Matrix.CreateRotationZ(view.Rotation.Z) *
Matrix.CreateLookAt(view.CameraPosition, view.CameraTarget, view.CameraUp);
Matrix projectionMatrix = Matrix.CreatePerspectiveFieldOfView(view.FieldOfView,
GraphicsDevice.Viewport.AspectRatio,
view.NearPlane,
view.FarPlane);
DrawModels(worldMatrix, viewMatrix, projectionMatrix);
base.Draw(gameTime);
}