3

I have created the following cube in Collada that I am displaying in Google-Earth by referencing it in a KML file. However, I don't succeed in giving the cube (e.g. all triangles) a specific color. At the moment the color changes rather randomly when changing anything (not just the color related attributes) in the Collada file. How do I make sure the Cube is getting colored i.e. red?

<?xml version="1.0"?>
<COLLADA>
  <asset>
    <up_axis>Z_UP</up_axis>
  </asset>
  <library_materials>
    <material id="Color">
      <instance_effect url="#phongEffect">
        <emission>
          <color>0.502 0.502 0.0 1.0</color>
        </emission>
      </instance_effect>
    </material>
  </library_materials> 
  <library_geometries>
    <geometry id="geom-Box01" name="Box01">
      <mesh>
    <source id="positions">
      <float_array id="positions-array" count="24">
        0 0 0
        0 0 1
        0 1 0
        1 0 0
        0 1 1
        1 0 1
        1 1 0
        1 1 1
      </float_array>
      <technique_common>
        <accessor source="#positions-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="normals">
      <float_array id="normals-array" count="18">
        1 0 0
        -1 0 0
        0 1 0
        0 -1 0
        0 0 1
        0 0 -1
      </float_array>
      <technique_common>
        <accessor source="#normals-array" count="8" stride="3"> 
          <param name="X" type="float"/>
          <param name="Y" type="float"/>
          <param name="Z" type="float"/>
        </accessor>
      </technique_common>
    </source>

    <vertices id="vertices">
      <input semantic="POSITION" source="#positions"/>
    </vertices>

    <triangles name="sample_triangles" count="24" color="Color">
      <input semantic="VERTEX" source="#vertices" offset="0"/>
      <input semantic="NORMAL" source="#normals" offset="1"/>
      <p> 
         0 5 3 5 2 5
         2 5 3 5 0 5
         2 5 3 5 6 5
         6 5 3 5 2 5
         5 0 3 0 7 0
         7 0 3 0 5 0
         7 0 3 0 6 0
         6 0 3 0 7 0
         1 4 5 4 7 4
         7 4 5 4 1 4
         7 4 1 4 4 4
         4 4 1 4 7 4
         0 1 1 1 4 1
         4 1 1 1 0 1
         4 1 0 1 2 1
         2 1 0 1 4 1
         1 3 5 3 3 3
         3 3 5 3 1 3
         3 3 1 3 0 3
         0 3 1 3 3 3
         4 2 7 2 6 2
         6 2 7 2 4 2
         6 2 4 2 2 2
         2 2 4 2 6 2
       </p> 
      </triangles>
     </mesh>
    </geometry>
  </library_geometries>

  <library_visual_scenes>
    <visual_scene id="MaxScene">
      <node id="node-Box01" name="Box01">
        <instance_geometry url="#geom-Box01">
        </instance_geometry>
      </node>
    </visual_scene>
  </library_visual_scenes>
  <scene>
    <instance_visual_scene url="#MaxScene"/>
  </scene>
</COLLADA>
siwica
  • 71
  • 4

1 Answers1

0

triangles element do not have Color attribute, replace it with Material. Also look at bind_material in the instance_geometry element.

user2555515
  • 779
  • 6
  • 20