【问题标题】:How to apply textures to a trianglestrip using XNA?如何使用 XNA 将纹理应用于三角形条带?
【发布时间】:2013-12-13 23:27:03
【问题描述】:

我正在使用 XNA 绘制 3d 图元。

我有一个描述立方体的TriangleStrip(我希望。我使用了this paper 的图2 中所示的三角剖分)。对于那些想要检查数学的人:

public readonly VertexPositionTexture[] Vertices =
{
    new VertexPositionTexture(new Vector3( 0, 0,0), new Vector2(1,1)),//A
    new VertexPositionTexture(new Vector3( 1, 0,0),new Vector2(0,1)),//B
    new VertexPositionTexture(new Vector3( 0, 1,0),new Vector2(1,0)),//C
    new VertexPositionTexture(new Vector3( 1, 1,0),new Vector2(0,0)),//D
    new VertexPositionTexture(new Vector3( 1, 1,1),new Vector2(0,0)),//E
    new VertexPositionTexture(new Vector3( 1, 0,0),new Vector2(1,1)),//B'
    new VertexPositionTexture(new Vector3( 1, 0,1),new Vector2(0,1)),//F
    new VertexPositionTexture(new Vector3( 0, 0,0),new Vector2(1,0)),//A'
    new VertexPositionTexture(new Vector3( 0, 0,1),new Vector2(1,1)),//H
    new VertexPositionTexture(new Vector3( 0, 1,0),new Vector2(1,0)),//C'
    new VertexPositionTexture(new Vector3( 0, 1,1),new Vector2(1,1)),//I
    new VertexPositionTexture(new Vector3( 1, 1,1),new Vector2(0,0)),//E'
    new VertexPositionTexture(new Vector3( 0, 0,1),new Vector2(0,1)),//H'
    new VertexPositionTexture(new Vector3( 1, 0,0),new Vector2(1,1))//F'
};

我的问题是,我不知道如何应用纹理。起初我试图为每张脸应用不同的纹理,但事实证明这是难以捉摸的。我现在要做的是将单个纹理应用于整个立方体。

第一个问题:这是最好的方法吗?了解到我正在尝试创建一个可重用的 Cube 类,我需要将纹理应用于每个面。如果这在单个 TriangleStrip 中是不可能的,那么我现在可以停下来了。

第二个问题:如何正确地将单个纹理应用到 TriangleStrip?

第三个问题:如何为不同的面分配/应用不同的纹理?

【问题讨论】:

    标签: c# 3d xna xna-4.0


    【解决方案1】:

    我现在无法查找,但您也必须加载内容 此外,如果您正在绘制多边形,请使用 BasicEffect。你应该只使用 SpriteBatch 来绘制精灵(即:使用它的 Draw 方法)。 考虑用 google 来帮助自己......

    但是,通过 Cinema4D 或 Blender 绘制模型或网格会更容易......然后只需在其上加载纹理即可。 - 更少的工作要做;更多的努力/更快和更准确的改变可能。

    希望我对你有足够的帮助;)

    【讨论】:

    • 如果你从 MS 文档中得到了什么,那么你就是一个比我更好的人。他们给出了一个四边形的例子,但没有更多。而且我找不到任何关于如何在绘制中更改纹理的信息。
    • 别忘了投票...那些文档没有完整的解释...只是 sn-ps...您必须不止看一个或开始思考:“我该如何使用它我的程序?”。只是在他们的帮助下尝试一下;)但你有点正确......那些更像是让你的头脑恢复活力:D
    • draw 方法...你知道在哪里绘制东西...;我想你应该从你开始的新项目中删除summeries 和 cmets xD
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多