我想知道我下面使用的方法是否是在屏幕上绘图之前确定模型位置的正确方法。 因为当我想创建一个复制模型的地板时。我发现自己面临着“Z-fighting”问题 ^ ^。
非常感谢
在绘制之前将示例编码到我模型上的 st 位置:
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();
}
最佳答案
据我所知,您的模型定位方法是正确的。当两个 3D 面在同一平面上相互重叠绘制时,就会出现 Z 战斗问题。正如您所说的“复制您的模型”,这听起来像是问题所在,而不是模型定位本身。要解决冲突,您可以在绘制模型的第二个副本之前为 GraphicsDevice.RasterizerState.DepthBias
设置一些非零值。来自documentation :
"Polygons with a high z-bias value appear in front of polygons with a low value, without requiring sorting for drawing order. For example, polygons with a value of 1 appear in front of polygons with a value of 0."
关于c# - 在 xna 项目中配置模型/纹理位置的最佳方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13566416/