callada vertex triangle extraction

hi,
I have created a simple cylinder with blender and I have exported it in a dae file. I would like to process the triangle list and visualize the object in another tool. This tool need as input a vertex list and draw triangles on each 3 consecutive vertex in the list.

<?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:249 - Illusoft Collada Exporter v:0.3.162</authoring_tool>
			<comments></comments>
			<copyright></copyright>
			<source_data>file://</source_data>
		</contributor>
		<created>2011-04-29T17:32:05.397323</created>
		<modified>2011-04-29T17:32:05.397386</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_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_geometries>
		<geometry id="Cylinder_002" name="Cylinder_002">
			<mesh>
				<source id="Cylinder_002-Position">
					<float_array count="102" id="Cylinder_002-Position-array">0.70711 0.70711 -1.00000 0.92388 0.38268 -1.00000 1.00000 -0.00000 -1.00000 0.92388 -0.38268 -1.00000 0.70711 -0.70711 -1.00000 0.38268 -0.92388 -1.00000 0.00000 -1.00000 -1.00000 -0.38268 -0.92388 -1.00000 -0.70711 -0.70711 -1.00000 -0.92388 -0.38268 -1.00000 -1.00000 -0.00000 -1.00000 -0.92388 0.38268 -1.00000 -0.70711 0.70711 -1.00000 -0.38268 0.92388 -1.00000 0.00000 1.00000 -1.00000 0.38268 0.92388 -1.00000 0.70711 0.70711 1.00000 0.92388 0.38268 1.00000 1.00000 -0.00000 1.00000 0.92388 -0.38268 1.00000 0.70711 -0.70711 1.00000 0.38268 -0.92388 1.00000 -0.00000 -1.00000 1.00000 -0.38269 -0.92388 1.00000 -0.70711 -0.70711 1.00000 -0.92388 -0.38268 1.00000 -1.00000 0.00000 1.00000 -0.92388 0.38269 1.00000 -0.70710 0.70711 1.00000 -0.38268 0.92388 1.00000 0.00000 1.00000 1.00000 0.38269 0.92388 1.00000 0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000</float_array>
					<technique_common>
						<accessor count="34" source="#Cylinder_002-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="Cylinder_002-Normals">
					<float_array count="144" id="Cylinder_002-Normals-array">-0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 -0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 -0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 -0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 -0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 -0.00000 1.00000 0.00000 0.00000 -1.00000 -0.00000 -0.00000 1.00000 0.00000 -0.00000 -1.00000 -0.00000 0.00000 1.00000 0.00000 -0.00000 -1.00000 -0.00000 0.00000 1.00000 0.00000 -0.00000 -1.00000 -0.00000 0.00000 1.00000 0.00000 -0.00000 -1.00000 -0.00000 0.00000 1.00000 -0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 0.00000 0.00000 -1.00000 0.00000 0.00000 1.00000 0.83147 0.55557 0.00000 0.98079 0.19509 0.00000 0.98079 -0.19509 0.00000 0.83147 -0.55557 -0.00000 0.55557 -0.83147 0.00000 0.19509 -0.98079 0.00000 -0.19509 -0.98079 0.00000 -0.55557 -0.83147 0.00000 -0.83147 -0.55557 0.00000 -0.98079 -0.19509 0.00000 -0.98079 0.19509 -0.00000 -0.83147 0.55557 -0.00000 -0.55557 0.83147 -0.00000 -0.19509 0.98079 0.00000 0.19509 0.98078 -0.00000 0.55557 0.83147 -0.00000</float_array>
					<technique_common>
						<accessor count="48" source="#Cylinder_002-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>
				<vertices id="Cylinder_002-Vertex">
					<input semantic="POSITION" source="#Cylinder_002-Position"/>
				</vertices>
				<triangles count="64">
					<input offset="0" semantic="VERTEX" source="#Cylinder_002-Vertex"/>
					<input offset="1" semantic="NORMAL" source="#Cylinder_002-Normals"/>
					

32 0 0 0 1 0 33 1 17 1 16 1 32 2 1 2 2 2 33 3 18 3 17 3 32 4 2 4 3 4 33 5 19 5 18 5 32 6 3 6 4 6 33 7 20 7 19 7 32 8 4 8 5 8 33 9 21 9 20 9 32 10 5 10 6 10 33 11 22 11 21 11 32 12 6 12 7 12 33 13 23 13 22 13 32 14 7 14 8 14 33 15 24 15 23 15 32 16 8 16 9 16 33 17 25 17 24 17 32 18 9 18 10 18 33 19 26 19 25 19 32 20 10 20 11 20 33 21 27 21 26 21 32 22 11 22 12 22 33 23 28 23 27 23 32 24 12 24 13 24 33 25 29 25 28 25 32 26 13 26 14 26 33 27 30 27 29 27 32 28 14 28 15 28 33 29 31 29 30 29 15 30 0 30 32 30 33 31 16 31 31 31 0 32 16 32 17 32 17 32 1 32 0 32 1 33 17 33 18 33 18 33 2 33 1 33 2 34 18 34 19 34 19 34 3 34 2 34 3 35 19 35 20 35 20 35 4 35 3 35 4 36 20 36 21 36 21 36 5 36 4 36 5 37 21 37 22 37 22 37 6 37 5 37 6 38 22 38 23 38 23 38 7 38 6 38 7 39 23 39 24 39 24 39 8 39 7 39 8 40 24 40 25 40 25 40 9 40 8 40 9 41 25 41 26 41 26 41 10 41 9 41 10 42 26 42 27 42 27 42 11 42 10 42 11 43 27 43 28 43 28 43 12 43 11 43 12 44 28 44 29 44 29 44 13 44 12 44 13 45 29 45 30 45 30 45 14 45 13 45 14 46 30 46 31 46 31 46 15 46 14 46 16 47 0 47 15 47 15 47 31 47 16 47</p>
				</triangles>
			</mesh>
		</geometry>
	</library_geometries>
	<library_visual_scenes>
		<visual_scene id="Scene" name="Scene">
			<node layer="L1" id="Cylinder" name="Cylinder">
				<translate sid="translate">-0.36892 0.23329 0.57795</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="#Cylinder_002"/>
			</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="Cylinder-PhysicsMaterial" name="Cylinder-PhysicsMaterial">
			<technique_common>
				<dynamic_friction>0</dynamic_friction>
				<restitution>0</restitution>
				<static_friction>0</static_friction>
			</technique_common>
		</physics_material>
	</library_physics_materials>
	<library_physics_models>
		<physics_model id="Scene-PhysicsModel" name="Scene-PhysicsModel">
			<rigid_body name="Cylinder-RigidBody" sid="Cylinder-RigidBody">
				<technique_common>
					<dynamic>false</dynamic>
					<mass>0</mass>
					<instance_physics_material url="#Cylinder-PhysicsMaterial"/>
					<shape>
						<instance_geometry url="#Cylinder_002"/>
					</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="Cylinder-RigidBody" target="#Cylinder"/>
			</instance_physics_model>
		</physics_scene>
	</library_physics_scenes>
	<scene>
		<instance_physics_scene url="#Scene-Physics"/>
		<instance_visual_scene url="#Scene"/>
	</scene>
</COLLADA>

I need to represent the triangle list in a tool giving just the 3d coordinates of the vertex. I know how to extract the triangle vertex position but when I send the coords contained in this dae file the object visualized is not correct. I pack sets of 3 vertex to represent each triangle. also I don’t know if I need to consider the normals and/or the information under visual scene.
Do I need to use just the triangle list and the position array to represent the cylinder triangles or I should also use the information in the normal array?

Best Regards

To confirm your understanding, can you post what you think the positions of the first triangle in your example are?

For the simple object viewer that you describe, the triangle vertex positions are all that you need. You will want the vertex normals for dynamic lighting.

The three index that identify a single triangle have an offset of 2 because triangles contains also the normals. So triangles are:
32 0 1 1st triangle
33 17 16 2nd triangle
Now I have the index to find the coordinates of the 3 points for a single triangle.
The first triangle is:
32 -> the first vertex coordinates x,y,z are at position 32,33,34
0 -> the second vertex coordinates x,y,z are at position 0,1,2
1 -> the third vertex coordinates x,y,z are at position 1,2,3

I hope I understood correctly. I send this coordinates as is I do not consider any additional translation or scale.

I think you are not taking into account the accessor stride (e.g. sample size) when using the indices provided.


T0/P0 = [ 0.00000 0.00000 -1.00000 ] starting at array(32 * 3)
T0/P1 = [ 0.70711 0.70711 -1.00000 ] starting at array( 0 * 3)
T0/P2 = [ 0.92388 0.38268 -1.00000 ] starting at array( 1 * 3)