c# - 在 xna 项目中配置模型/纹理位置的最佳方法是什么

标签 c# 3d xna mesh

我想知道我下面使用的方法是否是在屏幕上绘图之前确定模型位置的正确方法。 因为当我想创建一个复制模型的地板时。我发现自己面临着“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/

相关文章:

c# - 有什么比画单独的线更快的绘制图形的方法?

xna - 有没有办法使用像 Console.write 这样的东西来调试 XNA 代码?

c# - 动态压缩 n 列表

java - Android:三星 S2 上的 GLES 2.0 损坏?

c++ - 3D 空间中四边形的角度

3d - JavaFX 8 3D场景交点

3d - 如何使射线与地形模型相交?

c# - 如何用mongoDB进行 "all or nothing"操作?

c# - 具有两个接口(interface)的 Prism 7 Singleton

c# - 如何在 Windows Phone 7 中读取 SIM 卡详细信息?