0
$\begingroup$

I have textured a simple plane and exported it in the COLLADA format.

The export looks like this, for vertices:

<source id="Plane-mesh-positions">
      <float_array id="Plane-mesh-positions-array" count="12">-1 -1 0 1 -1 0 -1 1 0 1 1 0</float_array>
      <technique_common>
        <accessor source="#Plane-mesh-positions-array" count="4" stride="3">
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
</source>

There are 12 values, so with a stride of 3 that means I have 4 vertices. This is exactly what I want, as I will be rendering the data with OpenGL using a single index list.

Here're my normals:

<source id="Plane-mesh-normals">
      <float_array id="Plane-mesh-normals-array" count="3">0 0 1</float_array>
      <technique_common>
        <accessor source="#Plane-mesh-normals-array" count="1" stride="3">
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
</source>

Again, I notice that blender didn't export a new normal for each face/vertex, as all 2 faces/4 vertices in my mesh will have identical normals. Awesome!

Finally, I come to the UV-coords:

<source id="Plane-mesh-map">
      <float_array id="Plane-mesh-map-array" count="12">9.99834e-5 9.99834e-5 0.9998999 0.9999 9.99868e-5 0.9998999 9.99834e-5 9.99834e-5 0.9998999 1.00064e-4 0.9998999 0.9999</float_array>
      <technique_common>
        <accessor source="#Plane-mesh-map-array" count="6" stride="2">
          <param name="S" type="float"/>
          <param name="T" type="float"/>
        </accessor>
      </technique_common>
</source>

12 values with a stride of 2 means I now have 6 UV-coords. I just want 4, so I can pack it into an index list easily. None of the 6 coords are identical, by the way, so I can't just merge duplicates when loading.

Have a look at where the triangles are referenced in the file:

<triangles material="_12_png-material" count="2">
      <input semantic="VERTEX" source="#Plane-mesh-vertices" offset="0"/>
      <input semantic="NORMAL" source="#Plane-mesh-normals" offset="1"/>
      <input semantic="TEXCOORD" source="#Plane-mesh-map" offset="2" set="0"/>
      <p>1 0 0 2 0 1 0 0 2 1 0 3 3 0 4 2 0 5</p>
</triangles>

Notice that for each triangle, a new index of UV coord is used.

How can I export this mesh in a way that doesn't make these duplicate UVs? It's already doing a good job of reusing the 4 vertices in creation of 2 triangles, so why can't it do the same for the UVs?

Thank you for reading.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.