2

我想知道我下面使用的方法是否是在屏幕上绘制之前确定模型位置的正确方法。因为当我想创建一个复制我的模型的地板时。我发现自己面临着“Z-fighting”问题^ ^。

非常感谢你

在绘制之前将代码示例放在我的模型上的位置:

model_Position.X = (float) 1.0;
model_Position.Z = (float) 3.0;
model_Position.Y = (float) 5.0;

// Draw the model. A model can have multiple meshes, so loop.
foreach (ModelMesh mesh in model_ground_land1.Meshes)
{
    // This is where the mesh orientation is set, as well 
    // as our camera and projection.
    foreach (BasicEffect effect in mesh.Effects)
    {
        effect.EnableDefaultLighting();
        effect.World = transforms[mesh.ParentBone.Index]  *
    Matrix.CreateRotationY(model_Rotation) * Matrix.CreateTranslation(model_Position);
        effect.View = View;
        effect.Projection = Projection;
    }
    // Draw the mesh, using the effects set above.
    mesh.Draw();
}
4

1 回答 1

0

据我所知,您的方法对于定位模型是正确的。关于 Z 战斗问题,当两个 3D 面在同一平面上绘制时相互重叠时会发生。正如您所说的“复制模型”,这听起来像是问题所在,而不是模型定位本身。要解决战斗,您可以GraphicsDevice.RasterizerState.DepthBias在绘制模型的第二个副本之前设置一些非零值。从文档中:

“z-bias 值高的多边形出现在值低的多边形前面,不需要对绘制顺序进行排序。例如,值为 1 的多边形出现在值为 0 的多边形前面。”

于 2013-03-16T09:34:26.050 回答