.dae文件如何存储网格数据
How do .dae Files Store Mesh Data?
我正在尝试使用 TinyXML 从 .dae 文件读取网格到 DirectX 项目,但我很难理解 .dae 文件如何存储网格数据。
我相信我已经找到了网格数据的存储位置:在标签<library_geometries>
内有以下代码:
<library_geometries>
<geometry id="Tall_bodyShape" name="Tall_bodyShape">
<mesh>
<source id="Tall_bodyShape-positions" name="position">
<float_array id="Tall_bodyShape-positions-array" count="2910"> *** lots of numbers *** </float_array>
<technique_common>
<accessor source="#Tall_bodyShape-positions-array" count="970" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Tall_bodyShape-normals" name="normal">
<float_array id="Tall_bodyShape-normals-array" count="3948"> *** lots of numbers *** </float_array>
<technique_common>
<accessor source="#Tall_bodyShape-normals-array" count="1316" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="Tall_bodyShape-UVChannel_1" name="UVChannel_1">
<float_array id="Tall_bodyShape-UVChannel_1-array" count="2892"> *** lots of numbers *** </float_array>
<technique_common>
<accessor source="#Tall_bodyShape-UVChannel_1-array" count="1446" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="Tall_bodyShape-vertices">
<input semantic="POSITION" source="#Tall_bodyShape-positions"/>
</vertices>
<triangles material="Tall_bodySG" count="1883">
<input semantic="VERTEX" source="#Tall_bodyShape-vertices" offset="0"/>
<input semantic="NORMAL" source="#Tall_bodyShape-normals" offset="1"/>
<input semantic="TEXCOORD" source="#Tall_bodyShape-UVChannel_1" offset="2" set="0"/>
<p> *** lots of numbers *** </p>
</triangles>
</mesh>
<extra>
<technique profile="MAYA">
<double_sided>1</double_sided>
</technique>
</extra>
</geometry>
</library_geometries>
因此,顶点存储在名为 "position"
的<source>
标签中,法线存储在名为 "normal"
的<source>
标签中,<triangles>
标签列出哪些 UV 坐标和法线与哪个顶点相关联。
以"线"或"剥离"方法列出,但它没有说明我尝试哪个和哪个,它们都显示锯齿状的、球状的三角形混乱。
有谁知道我是否遗漏了其他一些网格数据,这些数据在dae的另一部分,或者我可能出错了?如有必要,我可以发布加载网格数据的函数。
编辑:附加说明:我确定.dae文件是正确的和有效的,因为它可以正确加载到PhyreEngine中(我使用的是去年用于大学项目的.dae(。
我意识到这是一个相对古老的问题,但由于它还没有真正得到回答,我将为后人尝试一下。
您是正确的,位置、法线等作为浮点数组存储在<source>
元素中。 <p>
("基元"(元素将紧接在 <triangles>
元素中列出的三个输入的索引存储在该元素中。 也就是说,前 3 个整数(例如"0 0 0"(指向第一个顶点的相应 VERTEX、NORMAL 和 TEXCOORD (UVChannel( 值。 它位于 <triangles>
元素中表示每组 3 个顶点(9 个索引整数(描述一个新的三角形,因此不会重复使用任何索引。 如果几何设置为使用条带(重用前 2 个顶点(或扇形(重用第一个和前一个顶点(,则父元素将分别称为 <tristrips>
或 <trifans>
。 第二组 3 个整数(例如"1 1 1"(描述第一个三角形中的第二个顶点,依此类推。
此外,正如@jterrace指出的那样,几何坐标是几何中描述的对象的内部坐标。 要将对象作为一个整体正确放置在场景中,您必须从场景中应用适当的变换(<translate>
、<rotate>
等(,如<library_visual_scenes>
中所述。
我使用simp来加载网格数据。解释和代码在这里:http://www.youtube.com/watch?v=ClqnhYAYtcYhttp://www.mediafire.com/download/006lk0xomup7laq/assimpLinux.zip
- 将字符串存储在c++中的稳定内存中
- std::原子加载和存储都需要吗
- C++:将控制台输出存储在宏中更好吗
- 使用QProcess执行命令,并将结果存储在QStringList中
- 访问存储在向量C++中的结构的多态成员
- 如何从存储在std::映射中的std::集中删除元素
- 存储模板类型以强制转换回派生<T>
- 类型总是使用其大小存储在内存中吗
- 当字符串存储在变量中时,如何将字符串转换为wchar_t
- 使用无符号字符数组有效存储内存
- 如何在cpp.中使用协议缓冲区存储大缓冲区/数组(char/int)
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- 带结构的二维矢量:如何存储元素
- 用于存储网格(将具有负索引)的数据结构
- 将大型3D网格存储,并带有细小的间距
- 如何从文件中读取并将内容存储在动态 2D 数组中并以网格格式显示
- c++OpenGL发布用存储在对象中的vbo和vao绘制网格
- .dae文件如何存储网格数据
- 如何有效地存储矩形网格
- 在 C++ 中存储网格状结构的一些最有效的方法是什么?