javaattributesoffsetcolladanormals

Collada geometry mesh triangles node's NORMAL offset attribute


I am trying to understand what exactly attribute "offset" does to values of the triangles/normals in a collada .dae file.

For example, let's say we have this in mesh node inside of a geometry node:

<triangles count="4">
    <input semantic="VERTEX" source="#some-mesh-vertices" offset="0"/>
    <input semantic="NORMAL" source="#some-mesh-normals" offset="1"/>
    <p>0 0 1 0 2 0 2 0 1 0 3 1 4 2 5 2 6 2 6 2 5 2 7 2</p>
</triangles>

Does that value of "1" do something to the normals or to triangles...or to both? And what exactly...like does it moves the normals/triangles array elements, or adding some value to them? I am strugling to understand it as I am building arrays from it for 3D model in Java, so of course, without this knowledge it is giving me errors as that offset value has to have some meaning which I do not get yet.


Solution

  • The offset only describes how to read the list.

    In this example you would read every second number, but starting at a given offset.

    <input semantic="VERTEX" source="#some-mesh-vertices" offset="0"/>
    <input semantic="NORMAL" source="#some-mesh-normals" offset="1"/>
    <p>0 1 2 3 4 5 6 7</p>
    
    vertexIndices = [0,2,4,6]
    normalIndices = [1,3,5,7]
    

    These indices would then be used to get the actual values from their source.