Results 1 to 3 of 3

Thread: What values should be in array with texture?

  1. #1
    Junior Member
    Join Date
    Jun 2018
    Posts
    10

    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
    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)* count - 24; 6 face-surfaces, so for double_sided texture normal array count 36 (3(x,y,z)*6*2).



    <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.

  2. #2
    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.
    Last edited by recp; 07-05-2018 at 11:48 AM.

  3. #3
    Junior Member
    Join Date
    Jun 2018
    Posts
    10
    Thank you. it was very helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean