What values should be in array with texture?

Hi! I just started to learn collada so sorry if question is very smple.
I have created a cube in blender and add a texture to it. Than i export a dae file to watch what i create :smiley:
I have several arrays. I did’t understand why in array with textute map there are 72 values. Cube has 8 vertices, positions array (3 (x,y,z)*8) count - 24; 6 face-surfaces, so for double_sided texture normal array count 36 (3(x,y,z)62).

<float_array id=“Cube-mesh-map-0-array” count=“72”> 0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1… </float_array>

<accessor source="#Cube-mesh-map-0-array" count=“36” stride=“2”>
<param name=“S” type=“float”/>
<param name=“T” type=“float”/>
</accessor>

In file this array contains oly 0 and 1: 0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 1 1… Why?

What values are in float array with map and how are they calculating. I mean, if i want to create collada file by myself what is formula for values in array.
Thanks for any help.

I just started to learn collada so sorry if question is very smple.

Do not worry, if your questions are related to COLLADA spec, you can ask simple or complex questions.

COLLADA uses multi-index buffer to store primitive indices. It means that you can use multiple arrays with different lengths. For instance if you want to use index buffer in OpenGL you have to convert this multi-index buffer to single index buffer. Because all vertex attributes must have same index (if you use GL_ELEMENT_ARRAY_BUFFER), there may be exceptions of course. As alternative you may not use index buffer.

Converting multi-index buffer to single-index buffer is not cheap. Also COLLADA may support multi-index but you can store mesh as single-index representation. Using single index for mesh primitive elements could improve load/parse performance. Because there is no need to convert multi-index to single index… If you want to store mesh as single index buffer:

  • all arrays must have same length

to keep arrays as same length, you have to duplicate array items if needed.

In your case; it could be small array to only store 0 and 1. You may see this in another COLLADA files. But if Blender exporter exported it as single index buffer then probably it duplicated array items to keep arrays same length

Cube have 6 side, it also means there are 12 triangles. Every triangle has 3 vertex, every vertex has 2 texcoord.

12 * 3 * 2 = 72 (because all positions are edges)

Here is the formula:

In <p> element you have index data. For polygons <vcount> specifies vertex count per-face. For triangles there is no need one (it is always 3).

<p> VERTEX1 VERTEX2 VERTEX3 …</p>

VERTEX1 = IndexForINPUT0 IndexForINPUT1 IndexForINPUT2 …

INPUT0 = input->source->techniqueCommon (if common technique is used)->accessor->source(array) using IndexForINPUT0

offset attribute in <input> element specifies input order in VERTEX.

Thank you. it was very helpful.