Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Reading Indices From DAE File

This topic is 1073 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys,

 

I'm getting the vertices POSITION from <float_array id="Box001-POSITION-array"> as the following:

-20.189827 -16.902542 0.000000
20.189827 -16.902542 0.000000
-20.189827 16.902542 0.000000
20.189827 16.902542 0.000000
-20.189827 -16.902542 26.019667
20.189827 -16.902542 26.019667
-20.189827 16.902542 26.019667
20.189827 16.902542 26.019667
 
What I see is that the indices should be retrieved from <p>:
0 0 9 2 1 11 3 2 10 3 3 10 1 4 8 0 5 9 4 6 8 5 7 9 7 8 11 7 9 11 6 10 10 4 11 8 0 12 4 1 13 5 5 14 7 5 15 7 4 16 6 0 17 4 1 18 0 3 19 1 7 20 3 7 21 3 5 22 2 1 23 0 3 24 4 2 25 5 6 26 7 6 27 7 7 28 6 3 29 4 2 30 0 0 31 1 4 32 3 4 33 3 6 34 2 2 35 0
Now, how I do fill the index buffer from the above data? I mean the indices seem too big, and I only need 36 indices to create a box.
 
Here is the contents of box.DAE:
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
  <asset>
    <contributor>
      <author></author>
      <authoring_tool>FBX COLLADA exporter</authoring_tool>
      <comments></comments>
    </contributor>
    <created>2016-01-11T11:23:05Z</created>
    <keywords></keywords>
    <modified>2016-01-11T11:23:05Z</modified>
    <revision></revision>
    <subject></subject>
    <title></title>
    <unit meter="0.025400" name="centimeter"></unit>
    <up_axis>Y_UP</up_axis>
  </asset>
  <library_geometries>
    <geometry id="Box001-lib" name="Box001Mesh">
      <mesh>
        <source id="Box001-POSITION">
          <float_array id="Box001-POSITION-array" count="24">
-20.189827 -16.902542 0.000000
20.189827 -16.902542 0.000000
-20.189827 16.902542 0.000000
20.189827 16.902542 0.000000
-20.189827 -16.902542 26.019667
20.189827 -16.902542 26.019667
-20.189827 16.902542 26.019667
20.189827 16.902542 26.019667
</float_array>
          <technique_common>
            <accessor source="#Box001-POSITION-array" count="8" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <source id="Box001-Normal0">
          <float_array id="Box001-Normal0-array" count="108">
0.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000
0.000000 0.000000 -1.000000
0.000000 0.000000 1.000000
0.000000 0.000000 1.000000
0.000000 0.000000 1.000000
0.000000 0.000000 1.000000
0.000000 0.000000 1.000000
0.000000 0.000000 1.000000
0.000000 -1.000000 0.000000
0.000000 -1.000000 0.000000
0.000000 -1.000000 0.000000
0.000000 -1.000000 0.000000
0.000000 -1.000000 0.000000
0.000000 -1.000000 0.000000
1.000000 0.000000 0.000000
1.000000 0.000000 0.000000
1.000000 0.000000 0.000000
1.000000 0.000000 0.000000
1.000000 0.000000 0.000000
1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 1.000000 0.000000
-1.000000 0.000000 0.000000
-1.000000 0.000000 0.000000
-1.000000 0.000000 0.000000
-1.000000 0.000000 0.000000
-1.000000 0.000000 0.000000
-1.000000 0.000000 0.000000
</float_array>
          <technique_common>
            <accessor source="#Box001-Normal0-array" count="36" stride="3">
              <param name="X" type="float"/>
              <param name="Y" type="float"/>
              <param name="Z" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <source id="Box001-UV0">
          <float_array id="Box001-UV0-array" count="24">
0.000000 0.000000
1.000000 0.000000
0.000000 1.000000
1.000000 1.000000
0.000000 0.000000
1.000000 0.000000
0.000000 1.000000
1.000000 1.000000
0.000000 0.000000
1.000000 0.000000
0.000000 1.000000
1.000000 1.000000
</float_array>
          <technique_common>
            <accessor source="#Box001-UV0-array" count="12" stride="2">
              <param name="S" type="float"/>
              <param name="T" type="float"/>
            </accessor>
          </technique_common>
        </source>
        <vertices id="Box001-VERTEX">
          <input semantic="POSITION" source="#Box001-POSITION"/>
        </vertices>
        <triangles count="12">
          <input semantic="VERTEX" offset="0" source="#Box001-VERTEX"/>
          <input semantic="NORMAL" offset="1" source="#Box001-Normal0"/>
          <input semantic="TEXCOORD" offset="2" set="0" source="#Box001-UV0"/>
          <p> 0 0 9 2 1 11 3 2 10 3 3 10 1 4 8 0 5 9 4 6 8 5 7 9 7 8 11 7 9 11 6 10 10 4 11 8 0 12 4 1 13 5 5 14 7 5 15 7 4 16 6 0 17 4 1 18 0 3 19 1 7 20 3 7 21 3 5 22 2 1 23 0 3 24 4 2 25 5 6 26 7 6 27 7 7 28 6 3 29 4 2 30 0 0 31 1 4 32 3 4 33 3 6 34 2 2 35 0</p>
        </triangles>
      </mesh>
    </geometry>
  </library_geometries>
  <library_visual_scenes>
    <visual_scene id="" name="">
      <node name="Box001" id="Box001" sid="Box001">
        <matrix sid="matrix">1.000000 0.000000 0.000000 0.119303 0.000000 0.000000 1.000000 -12.444590 0.000000 -1.000000 0.000000 3.062286 0.000000 0.000000 0.000000 1.000000</matrix>
        <instance_geometry url="#Box001-lib"/>
        <extra>
          <technique profile="FCOLLADA">
            <visibility>1.000000</visibility>
          </technique>
        </extra>
      </node>
      <extra>
        <technique profile="MAX3D">
          <frame_rate>30.000000</frame_rate>
        </technique>
        <technique profile="FCOLLADA">
          <start_time>0.000000</start_time>
          <end_time>3.333333</end_time>
        </technique>
      </extra>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#"></instance_visual_scene>
  </scene>
</COLLADA>
Edited by Medo3337

Share this post


Link to post
Share on other sites
Advertisement

You can see that in the indices list it tells you that it's storing a set of indices for VERTEX, NORMAL and TEXCOORDs, so if you just want to read vertex positions you need to read on a stride of 3. Eg. 0 0 9 2 1 11 3 2 10 3 3 10 1 4 8 0 5 9...

 

However, I'd advise using assimp to load in COLLADA files, you'll quickly find that different exporters reference data in many different ways.

Edited by Syntac_

Share this post


Link to post
Share on other sites

@Syntac_: Now I can draw the mesh, but trying to get the UV into the vertex buffer.

 

I see here that I have 12 UV, while in my vertex buffer I only have 8 vertices, how do I assign 12 UV to 8 vertices?+

 

Resolved. I created 36 vertices instead of 8 and used the indices to build the vertex buffer.

 

Thanks,

Edited by Medo3337

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!