   [COLLADA]c++
  Hy.I'm still importing a collada document , the vertex,vertexnormal,material ecc.. is ok , but how to import faces?The faces are a list of vertex,is correct?But in the collada file i can't find any face!and no faces normals.why? Thanks   
  First, you don't say which library are you using, official Collada DOM, or FeelingSoft FCollada, I assume the latter, which is what the majority uses.Reading faces from collada is tricky, to say the least. So you're not doing anything wrong, it's just that you have to access several not very obvious arrays at the same time to make faces from them.To read faces, you have to check first if the mesh has been stored using triangles, or polygons.If the mesh is made only with triangles, you have to read the triangle index array , which is just an array of indices to elements in the different vertex channels.Now, keep in mind that every mesh can have different sets of data channels, like having normals, UV coordinates, etc, so you have to compute the vertex stride, that is the number of indices required to access the data, per vertex.Finally, to get the data from a triangle, you have to access the triangle index array, so every new triangle happens every your-stride * 3.For example, if a mesh only has vertex positions (stride=1), you will only need the 3 first indices in the index array, to make a face. But if you have positions and normals (stride=2), you need 6 indices in the index array to make a face; 3 for the positions, and 3 for the normals, oh, and they come interleaved!If it happens that the mesh is made by polygons, not triangles, then you have to read yet another array that tells you how many vertices has every polygon, and from that, read the indices from the index array.It's been a while since I used FCollada, so maybe in recent versions they have added some utility functions to make this easier... but basically, this is how it works.Vic;  Download my project work (pdf) at http://sourceforge.net/projects/colladaloader/  and read 3.3.4 section.   ;  hy.I download your project riruilo , is very nice , but i not would use fcollada.I have this simple file:<?xml version="1.0" encoding="utf-8"?><COLLADA version="1.4.0" xmlns="http://www.collada.org/2005/11/COLLADASchema"><asset><contributor><author>Illusoft Collada 1.4.0 plugin for Blender - http://colladablender.illusoft.com</author><authoring_tool>Blender v:246 - Illusoft Collada Exporter v:0.3.159</authoring_tool><comments></comments><copyright></copyright><source_data>file://C:/</source_data></contributor><created>2008-08-06T00:31:08.421000</created><modified>2008-08-06T00:31:08.421000</modified><unit meter="0.01" name="centimeter"/><up_axis>Z_UP</up_axis></asset><library_cameras><camera id="Camera-Camera" name="Camera-Camera"><optics><technique_common><perspective><yfov>49.13434</yfov><znear>0.1</znear><zfar>100.0</zfar></perspective></technique_common></optics></camera></library_cameras><library_effects><effect id="Material-fx" name="Material-fx"><profile_COMMON><technique sid="blender"><phong><emission><color>0.00000 0.00000 0.00000 1</color></emission><ambient><color>0.40000 0.40000 0.40000 1</color></ambient><diffuse><color>0.80000 0.80000 0.80000 1</color></diffuse><specular><color>0.50000 0.50000 0.50000 1</color></specular><shininess><float>12.5</float></shininess><reflective><color>1.00000 1.00000 1.00000 1</color></reflective><reflectivity><float>0.0</float></reflectivity><transparent><color>1 1 1 1</color></transparent><transparency><float>0.0</float></transparency></phong></technique></profile_COMMON></effect></library_effects><library_lights><light id="Spot" name="Spot"><technique_common><point><color>1.00000 1.00000 1.00000</color><constant_attenuation>1.0</constant_attenuation><linear_attenuation>0.0</linear_attenuation><quadratic_attenuation>0.0</quadratic_attenuation></point></technique_common></light></library_lights><library_materials><material id="Material" name="Material"><instance_effect url="#Material-fx"/></material></library_materials><library_geometries><geometry id="Cube-Geometry" name="Cube-Geometry"><mesh><source id="Cube-Geometry-Position"><float_array count="24" id="Cube-Geometry-Position-array">1.00000 1.00000 -1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 -1.00000 1.00000 -1.00000 -1.00000 1.00000 -1.00000 1.00000 1.00000</float_array><technique_common><accessor count="8" source="#Cube-Geometry-Position-array" stride="3"><param type="float" name="X"></param><param type="float" name="Y"></param><param type="float" name="Z"></param></accessor></technique_common></source><source id="Cube-Geometry-Normals"><float_array count="18" id="Cube-Geometry-Normals-array">0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 1.00000 -0.00000 0.00000 -0.00000 -1.00000 -0.00000 -1.00000 0.00000 -0.00000 0.00000 1.00000 0.00000</float_array><technique_common><accessor count="6" source="#Cube-Geometry-Normals-array" stride="3"><param type="float" name="X"></param><param type="float" name="Y"></param><param type="float" name="Z"></param></accessor></technique_common></source><source id="Cube-Geometry-UV"><float_array count="48" id="Cube-Geometry-UV-array">0.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000 0.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000 0.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000 0.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000 0.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000 0.00000 0.00000 1.00000 0.00000 1.00000 1.00000 0.00000 1.00000</float_array><technique_common><accessor count="24" source="#Cube-Geometry-UV-array" stride="2"><param type="float" name="S"></param><param type="float" name="T"></param></accessor></technique_common></source><vertices id="Cube-Geometry-Vertex"><input semantic="POSITION" source="#Cube-Geometry-Position"/></vertices><polygons count="6" material="Material"><input offset="0" semantic="VERTEX" source="#Cube-Geometry-Vertex"/><input offset="1" semantic="NORMAL" source="#Cube-Geometry-Normals"/><input offset="2" semantic="TEXCOORD" source="#Cube-Geometry-UV"/> 0 0 0 1 0 1 2 0 2 3 0 3 4 1 4 7 1 5 6 1 6 5 1 7 0 2 8 4 2 9 5 2 10 1 2 11 1 3 12 5 3 13 6 3 14 2 3 15 2 4 16 6 4 17 7 4 18 3 4 19 4 5 20 0 5 21 3 5 22 7 5 23</polygons></mesh></geometry></library_geometries><library_visual_scenes><visual_scene id="Scene" name="Scene"><node layer="L1" id="Cube" name="Cube"><translate sid="translate">0.00000 0.00000 0.00000</translate><rotate sid="rotateZ">0 0 1 0.00000</rotate><rotate sid="rotateY">0 1 0 0.00000</rotate><rotate sid="rotateX">1 0 0 0.00000</rotate><scale sid="scale">1.00000 1.00000 1.00000</scale><instance_geometry url="#Cube-Geometry"><bind_material><technique_common><instance_material symbol="Material" target="#Material"><bind_vertex_input input_semantic="TEXCOORD" input_set="1" semantic="CHANNEL1"/></instance_material></technique_common></bind_material></instance_geometry></node><node layer="L1" id="Lamp" name="Lamp"><translate sid="translate">4.07625 1.00545 5.90386</translate><rotate sid="rotateZ">0 0 1 106.93632</rotate><rotate sid="rotateY">0 1 0 3.16371</rotate><rotate sid="rotateX">1 0 0 37.26105</rotate><scale sid="scale">1.00000 1.00000 1.00000</scale><instance_light url="#Spot"/></node><node layer="L1" id="Camera" name="Camera"><translate sid="translate">7.48113 -6.50764 5.34367</translate><rotate sid="rotateZ">0 0 1 46.69194</rotate><rotate sid="rotateY">0 1 0 0.61977</rotate><rotate sid="rotateX">1 0 0 63.55930</rotate><scale sid="scale">1.00000 1.00000 1.00000</scale><instance_camera url="#Camera-Camera"/></node></visual_scene></library_visual_scenes><library_physics_materials><physics_material id="Cube-PhysicsMaterial" name="Cube-PhysicsMaterial"><technique_common><dynamic_friction>0.5</dynamic_friction><restitution>0.0</restitution><static_friction>0.5</static_friction></technique_common></physics_material></library_physics_materials><library_physics_models><physics_model id="Scene-PhysicsModel" name="Scene-PhysicsModel"><rigid_body name="Cube-RigidBody" sid="Cube-RigidBody"><technique_common><dynamic>false</dynamic><mass>0</mass><instance_physics_material url="#Cube-PhysicsMaterial"/><shape><instance_geometry url="#Cube-Geometry"/></shape></technique_common></rigid_body></physics_model></library_physics_models><library_physics_scenes><physics_scene id="Scene-Physics" name="Scene-Physics"><instance_physics_model url="#Scene-PhysicsModel"><instance_rigid_body body="Cube-RigidBody" target="#Cube"/></instance_physics_model></physics_scene></library_physics_scenes><scene><instance_physics_scene url="#Scene-Physics"/><instance_visual_scene url="#Scene"/></scene></COLLADA>where are the normals?I find just this:1)Cube-Geometry-Normals are face normal or vertex normal? I suppose the face normal.But i'm not understand how to get the faces:Quote:But if you have positions and normals (stride=2), you need 6 indices in the index array to make a facea face with 6 indices ?Why?3 for the position and 3 for normals?where are the other normals(Vertex normal)Thanks.   ;  Because you do not have normals per vertex, you have only normals per face.By the way, I realised 1 year ago, blender collada exporter had a lot of bugs, however, I dont now at the moment.You have 6 normals, and this example, a cube too, has 24:<?xml version="1.0" encoding="utf-8"?><COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">  <asset>    <contributor> <author>Ricardo</author> <authoring_tool>3dsMax 10 - Feeling ColladaMax v3.05B.</authoring_tool> <comments>ColladaMax Export Options: ExportNormals=1;ExportEPolyAsTriangles=1;ExportXRefs=1;ExportSelected=0;ExportTangents=0;ExportAnimations=0;SampleAnim=1;ExportAnimClip=0;BakeMatrices=0;ExportRelativePaths=1;AnimStart=0;AnimEnd=3.33333;</comments>    </contributor>    <created>2008-08-06T16:37:51Z</created>    <modified>2008-08-06T16:37:53Z</modified>    <unit meter="0.0254" name="inch"/>    <up_axis>Z_UP</up_axis>  </asset>  <library_materials>    <material id="ColorMaterial_8C58E100" name="ColorMaterial_8C58E100"> <instance_effect url="#ColorMaterial_8C58E100-fx"/>    </material>  </library_materials>  <library_effects>    <effect id="ColorMaterial_8C58E100-fx"> <profile_COMMON>   <technique sid="common"><phong>  <emission>    <color>0 0 0 1</color>  </emission>  <ambient>    <color>0.54902 0.345098 0.882353 1</color>  </ambient>  <diffuse>    <color>0.54902 0.345098 0.882353 1</color>  </diffuse>  <specular>    <color>1 1 1 1</color>  </specular>  <shininess>    <float>10</float>  </shininess>  <reflective>    <color>0 0 0 1</color>  </reflective>  <reflectivity>    <float>1</float>  </reflectivity>  <transparent opaque="A_ONE">    <color>1 1 1 1</color>  </transparent>  <transparency>    <float>1</float>  </transparency></phong><extra>  <technique profile="FCOLLADA">    <spec_level> <float>0.2</float>    </spec_level>  </technique></extra>   </technique> </profile_COMMON>    </effect>  </library_effects>  <library_geometries>    <geometry id="Box01-mesh" name="Box01"> <mesh>   <source id="Box01-mesh-positions"><float_array id="Box01-mesh-positions-array" count="24">-20.7761 -24.1662 0 20.7761 -24.1662 0 -20.7761 24.1662 0 20.7761 24.1662 0 -20.7761 -24.1662 31.7394 20.7761 -24.1662 31.7394 -20.7761 24.1662 31.7394 20.7761 24.1662 31.7394</float_array><technique_common>  <accessor source="#Box01-mesh-positions-array" count="8" stride="3">    <param name="X" type="float"/>    <param name="Y" type="float"/>    <param name="Z" type="float"/>  </accessor></technique_common>   </source>   <source id="Box01-mesh-normals"><float_array id="Box01-mesh-normals-array" count="72">0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 1 0 0 1 0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0</float_array><technique_common>  <accessor source="#Box01-mesh-normals-array" count="24" stride="3">    <param name="X" type="float"/>    <param name="Y" type="float"/>    <param name="Z" type="float"/>  </accessor></technique_common>   </source>   <source id="Box01-mesh-map-channel1"><float_array id="Box01-mesh-map-channel1-array" count="36">0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 0 1 1 0</float_array><technique_common>  <accessor source="#Box01-mesh-map-channel1-array" count="12" stride="3">    <param name="S" type="float"/>    <param name="T" type="float"/>    <param name="P" type="float"/>  </accessor></technique_common>   </source>   <vertices id="Box01-mesh-vertices"><input semantic="POSITION" source="#Box01-mesh-positions"/>   </vertices>   <triangles material="ColorMaterial" count="12"><input semantic="VERTEX" source="#Box01-mesh-vertices" offset="0"/><input semantic="NORMAL" source="#Box01-mesh-normals" offset="1"/><input semantic="TEXCOORD" source="#Box01-mesh-map-channel1" offset="2" set="1"/> 0 0 9 2 1 11 3 2 10 3 2 10 1 3 8 0 0 9 4 4 8 5 5 9 7 6 11 7 6 11 6 7 10 4 4 8 0 8 4 1 9 5 5 10 7 5 10 7 4 11 6 0 8 4 1 12 0 3 13 1 7 14 3 7 14 3 5 15 2 1 12 0 3 16 4 2 17 5 6 18 7 6 18 7 7 19 6 3 16 4 2 20 0 0 21 1 4 22 3 4 22 3 6 23 2 2 20 0   </triangles> </mesh>    </geometry>  </library_geometries>  <library_visual_scenes>    <visual_scene id="unnamed_scene" name="unnamed_scene"> <node id="Box01-node" name="Box01" type="NODE">   <translate>16.3587 9.03777 0</translate>   <instance_geometry url="#Box01-mesh"><bind_material>  <technique_common>    <instance_material symbol="ColorMaterial" target="#ColorMaterial_8C58E100"/>  </technique_common></bind_material>   </instance_geometry> </node> <extra>   <technique profile="FCOLLADA"><start_time>0</start_time><end_time>3.33333</end_time>   </technique> </extra> <extra>   <technique profile="MAX3D"><frame_rate>30</frame_rate>   </technique> </extra>    </visual_scene>  </library_visual_scenes>  <scene>    <instance_visual_scene url="#unnamed_scene"/>  </scene></COLLADA>;  Thanks a lot.SO the blender file that i ìve posted have some errors?Quote:But if you have positions and normals (stride=2), you need 6 indices in the index array to make a faceI'm still understand ...my problem is the number of vertex for face,poly or triangle, where i can read in the collada file this information? Then if i know the number of vertex for face i can import the face (but is the list of vertex ordered?)Thanks   ;  Just look at the inputs in the <poligons> element, they tell you what each index is for and where to get the value from, in the file you posted, you have:<input offset="0" semantic="VERTEX" source="#Cube-Geometry-Vertex"/><input offset="1" semantic="NORMAL" source="#Cube-Geometry-Normals"/><input offset="2" semantic="TEXCOORD" source="#Cube-Geometry-UV"/>that means the first number is a vertex (position) index into the Cube-Geometry-Vertex source, the second a normal index into Cube-Geometry-Normals and finally the third a UV index into Cube-Geometry-UV, each line after the inputs represent a face, and each group of 3 indexes represent a point, it really is at least outdated, since those lines should go into  elements, not just orphaned inside the <polygons) element.;  thanks bu I'm not understand , why if i have a6(faces) x 3 in the position = 18 vertex,but i have 24 vertex in my example!6(faces) x 3 in the normals = 18 normals and is ok6(faces) x 3 in the Texture = 18 but i have 48 elements in Cube-Geometry-UV-array!   ;  That's because each of the faces is a quad, they each have 4 verts, not 3, 6 x 4= 24.As I said, there is something wrong with the file, maybe because of the buggy Blender exporter, there seems to be no way to tell how many verts per face other than each face being given on a different line.   ;  I think the clue to the number of vertices per face is that the indices are being stored inside a "triangles" node rather than a "polygons" so the number should always be 3 :)   