【问题标题】:Importing COLLADA file - Wrong vertex positions导入 COLLADA 文件 - 顶点位置错误
【发布时间】:2015-01-29 19:01:28
【问题描述】:
我正在为我的游戏引擎导入 .DAE。我一直在使用 MilkShape 导出的模型,它们运行良好:
现在我从互联网上下载了一个更大的多边形网格(带骨架),我正在尝试导入那个。我只想要网格,暂时不需要骨架/动画。
问题是,我的引擎中的输出不正确。
我不确定我做错了什么。这些结果是否对某人敲响了警钟?
顺便说一下,这是 .DAE 文件;
干杯,
抢
【问题讨论】:
标签:
import
polygon
collada
【解决方案1】:
啊,我明白了!
其中一个型号(Milkshape 型号)使用了
像这样的部分;
0 0 0 1 1 1 2 3 2
地点:
0=<position index> 0=<normal_index> 0=<vertex index>
1=<position index> 1=<normal_index> 1=<vertex index>
2=<position index> 3=<normal_index> 2=<vertex index>
但另一个模型没有使用这个偏移量,而是在位置、法线和顶点上使用了共享索引。
0 1 2 3
地点:
0 = <position index & normal_index & vertex index>
1 = <position index & normal_index & vertex index>
2 = <position index & normal_index & vertex index>'
3 = <position index & normal_index & vertex index>
您可以看到这 4 个模型有:
<triangles material="Block" count="12">
<input semantic="VERTEX" source="#Box01-geometry-vertices" offset="0" />
<input semantic="NORMAL" source="#Box01-normals" offset="1" />
<input semantic="TEXCOORD" source="#Box01-texcoords" offset="2" />
<p>0 0 0 1 0 1 2 0 2 1 0 1 3 0 (...)</p> (vertexes X 3 numbers)
</triangles>
另一个有:
<triangles material="Block" count="12">
<input semantic="VERTEX" source="#Box01-geometry-vertices" />
<input semantic="NORMAL" source="#Box01-normals" />
<input semantic="TEXCOORD" source="#Box01-texcoords" />
<p>0 1 2 3 4 5 6 7 7 8 9 10 11 (...)</p> (vertexes X 1 numbers)
</triangles>
所以,我所要做的就是删除硬编码的偏移量并使用 XML 中的偏移量。