我完全同意 Coincoin,上下文代码会有所帮助。
如果您只想将变换后的网格绘制到屏幕上,则不需要以这种方式变换网格。您可以只更改世界、视图和投影矩阵之一。这会产生预期的结果。就像下面的示例代码一样。
// Clear the backbuffer to a Blue color.
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue,
1.0f, 0);
// Begin the scene.
device.BeginScene();
device.Lights[0].Enabled = true;
// Setup the world, view, and projection matrices.
Matrix m = new Matrix();
if( destination.Y != 0 )
y += DXUtil.Timer(DirectXTimer.GetElapsedTime) * (destination.Y
* 25);
if( destination.X != 0 )
x += DXUtil.Timer(DirectXTimer.GetElapsedTime) * (destination.X
* 25);
m = Matrix.RotationY(y);
m *= Matrix.RotationX(x);
device.Transform.World = m;
device.Transform.View = Matrix.LookAtLH(
new Vector3( 0.0f, 3.0f,-5.0f ),
new Vector3( 0.0f, 0.0f, 0.0f ),
new Vector3( 0.0f, 1.0f, 0.0f ) );
device.Transform.Projection = Matrix.PerspectiveFovLH(
(float)Math.PI / 4, 1.0f, 1.0f, 100.0f );
// Render the teapot.
teapot.DrawSubset(0);
// End the scene.
device.EndScene();
这个样本取自这里。