Results 1 to 3 of 3

Thread: Multiple materials in a mesh don't work

  1. #1
    injik
    Guest

    Multiple materials in a mesh don't work

    Hi, there.
    I have drawn a teapot on 3DS MAX.
    This teapot has composed with three colors.
    The body is red, the handle is green, and the cap is blue.

    After export to COLLADA(.dae), in the .dae, the teapot has one <mesh> and three <triangles>'s with different material.

    When re-import this .dae to 3DS MAX, the teapot has composed with only one color.
    (It may be the last one in the order of draw)


    In .dae content, there are three <material> elements in <library_materials> element, three <effect> elements in <library_effects> element. And, in each <effect> element, the <diffuse> elements have the right color values.

    Do you guys have any idea about this?
    Oh, I am working with OpenGL ES 2.0.

    Code :
    <?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>2011-09-27T12:06:46Z</created>
        <keywords></keywords>
        <modified>2011-09-27T12:06:46Z</modified>
        <revision></revision>
        <subject></subject>
        <title></title>
        <unit meter="0.025400" name="centimeter"></unit>
        <up_axis>Y_UP</up_axis>
      </asset>
      <library_materials>
        <material id="Material #25" name="Material #25">
          <instance_effect url="#Material #25-fx"/>
        </material>
        <material id="Material #23" name="Material #23">
          <instance_effect url="#Material #23-fx"/>
        </material>
        <material id="Material #24" name="Material #24">
          <instance_effect url="#Material #24-fx"/>
        </material>
      </library_materials>
      <library_effects>
        <effect id="Material #25-fx" name="Material #25">
          <profile_COMMON>
            <technique sid="standard">
              <phong>
                <emission>
                  <color sid="emission">0.000000  0.000000 0.000000 1.000000</color>
                </emission>
                <ambient>
                  <color sid="ambient">0.000000  0.000000 0.000000 1.000000</color>
                </ambient>
                <diffuse>
                  <color sid="diffuse">0.360784  0.329412 0.000000 1.000000</color>
                </diffuse>
                <specular>
                  <color sid="specular">1.000000  1.000000 1.000000 1.000000</color>
                </specular>
                <shininess>
                  <float sid="shininess">4.000000</float>
                </shininess>
                <reflective>
                  <color sid="reflective">0.000000  0.000000 0.000000 1.000000</color>
                </reflective>
                <reflectivity>
                  <float sid="reflectivity">1.000000</float>
                </reflectivity>
                <transparent opaque="RGB_ZERO">
                  <color sid="transparent">1.000000  1.000000 1.000000 1.000000</color>
                </transparent>
                <transparency>
                  <float sid="transparency">0.000000</float>
                </transparency>
              </phong>
            </technique>
          </profile_COMMON>
        </effect>
        <effect id="Material #23-fx" name="Material #23">
          <profile_COMMON>
            <technique sid="standard">
              <phong>
                <emission>
                  <color sid="emission">0.000000  0.000000 0.000000 1.000000</color>
                </emission>
                <ambient>
                  <color sid="ambient">0.584314  0.584314 0.584314 1.000000</color>
                </ambient>
                <diffuse>
                  <color sid="diffuse">0.921569  0.921569 0.921569 1.000000</color>
                </diffuse>
                <specular>
                  <color sid="specular">1.280000  1.280000 1.280000 1.000000</color>
                </specular>
                <shininess>
                  <float sid="shininess">8.000001</float>
                </shininess>
                <reflective>
                  <color sid="reflective">0.000000  0.000000 0.000000 1.000000</color>
                </reflective>
                <reflectivity>
                  <float sid="reflectivity">1.000000</float>
                </reflectivity>
                <transparent opaque="RGB_ZERO">
                  <color sid="transparent">1.000000  1.000000 1.000000 1.000000</color>
                </transparent>
                <transparency>
                  <float sid="transparency">0.000000</float>
                </transparency>
              </phong>
            </technique>
          </profile_COMMON>
        </effect>
        <effect id="Material #24-fx" name="Material #24">
          <profile_COMMON>
            <technique sid="standard">
              <phong>
                <emission>
                  <color sid="emission">0.000000  0.000000 0.000000 1.000000</color>
                </emission>
                <ambient>
                  <color sid="ambient">1.000000  0.000000 0.000000 1.000000</color>
                </ambient>
                <diffuse>
                  <color sid="diffuse">1.000000  0.000000 0.000000 1.000000</color>
                </diffuse>
                <specular>
                  <color sid="specular">1.280000  1.280000 1.280000 1.000000</color>
                </specular>
                <shininess>
                  <float sid="shininess">8.000001</float>
                </shininess>
                <reflective>
                  <color sid="reflective">0.000000  0.000000 0.000000 1.000000</color>
                </reflective>
                <reflectivity>
                  <float sid="reflectivity">1.000000</float>
                </reflectivity>
                <transparent opaque="RGB_ZERO">
                  <color sid="transparent">1.000000  1.000000 1.000000 1.000000</color>
                </transparent>
                <transparency>
                  <float sid="transparency">0.000000</float>
                </transparency>
              </phong>
            </technique>
          </profile_COMMON>
        </effect>
      </library_effects>
      <library_geometries>
        <geometry id="Teapot001-lib" name="Teapot001Mesh">
          <mesh>
            <source id="Teapot001-POSITION">
              <float_array id="Teapot001-POSITION-array" count="906">
    </float_array>
              <technique_common>
                <accessor source="#Teapot001-POSITION-array" count="302" stride="3">
                  <param name="X" type="float"/>
                  <param name="Y" type="float"/>
                  <param name="Z" type="float"/>
                </accessor>
              </technique_common>
            </source>
            <source id="Teapot001-Normal0">
              <float_array id="Teapot001-Normal0-array" count="4968">
    </float_array>
              <technique_common>
                <accessor source="#Teapot001-Normal0-array" count="1656" stride="3">
                  <param name="X" type="float"/>
                  <param name="Y" type="float"/>
                  <param name="Z" type="float"/>
                </accessor>
              </technique_common>
            </source>
            <source id="Teapot001-UV0">
              <float_array id="Teapot001-UV0-array" count="1008">
    </float_array>
              <technique_common>
                <accessor source="#Teapot001-UV0-array" count="504" stride="2">
                  <param name="S" type="float"/>
                  <param name="T" type="float"/>
                </accessor>
              </technique_common>
            </source>
            <vertices id="Teapot001-VERTEX">
              <input semantic="POSITION" source="#Teapot001-POSITION"/>
            </vertices>
            <triangles count="552" material="Material #25">
              <input semantic="VERTEX" offset="0" source="#Teapot001-VERTEX"/>
              <input semantic="NORMAL" offset="1" source="#Teapot001-Normal0"/>
              <input semantic="TEXCOORD" offset="2" set="0" source="#Teapot001-UV0"/>
     
     
    </p>
            </triangles>
            <triangles count="552" material="Material #23">
              <input semantic="VERTEX" offset="0" source="#Teapot001-VERTEX"/>
              <input semantic="NORMAL" offset="1" source="#Teapot001-Normal0"/>
              <input semantic="TEXCOORD" offset="2" set="0" source="#Teapot001-UV0"/>
     
     
    </p>
            </triangles>
            <triangles count="552" material="Material #24">
              <input semantic="VERTEX" offset="0" source="#Teapot001-VERTEX"/>
              <input semantic="NORMAL" offset="1" source="#Teapot001-Normal0"/>
              <input semantic="TEXCOORD" offset="2" set="0" source="#Teapot001-UV0"/>
     
     
    </p>
            </triangles>
          </mesh>
        </geometry>
      </library_geometries>
      <library_visual_scenes>
        <visual_scene id="" name="">
          <node name="Teapot001" id="Teapot001" sid="Teapot001">
            <matrix sid="matrix">1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 -3.000000 0.000000 -1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000</matrix>
            <instance_geometry url="#Teapot001-lib">
              <bind_material>
                <technique_common>
                  <instance_material symbol="Material #25" target="#Material #25"/>
                  <instance_material symbol="Material #23" target="#Material #23"/>
                  <instance_material symbol="Material #24" target="#Material #24"/>
                </technique_common>
              </bind_material>
            </instance_geometry>
            <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>

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: Multiple materials in a mesh don't work

    That document is invalid. If you use any XML validating parser it will tell you that the id attribute values are invalid (they contain spaces).

    It looks like the document came from FBX, so that would be a bug to file with Autodesk.

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    2

    Re: Multiple materials in a mesh don't work

    well not quite...i have the same problem with mine and it's openCollada with Maya.

    I have a character,Ryan,who i used for my bachelor thesis and I edited/combined the original mesh parts in less mesh parts to be able to skin easily.But if i check them out UVs are correct,Maya displays it correctly and so on.After i export it to dae(it contains meshes,joints,animation,skinning info) everything loads correctly in osgViewer/AnimationViewer and Maya(through openCollada importer) apart from some phongs.Those phongs are there in the dae file if i check the code but the connection is not.

    I imported the dae in Maya and through the Hypershade i checked the graph for the problematic mesh part and from the 3 phong chains only two were there and the one missing was the one that had the face texture.so now i'm stuck with the other phong that has the body texture(needed for part of the neck) and Ryan has no hair and nipples on his head.

    To be more specific,phong5 has the body texture for the neck part and phong6 has the face texture.In the hypershade for the maya ascii file i export from,i see in the graph 4 nodes for phong5 and 3 for phong6.Those are phong6P2D(place2dTexture),phong6F(file),phong6,pho ng5P2D(place2dTexture),phong5F(file),phong5,Ryan:: 5(shading group) and phong14(alone,something black).
    If i import the exported dae back to Maya the ones i see in the hypershade are:
    place2dTexture_7(phong5P2D),phong5F,phong5,phong5S G(Ryan::5 the shading group) and phong14.
    But phong6,phong6F,phong6P2D(which is actually place2dTexture_ as i said exists in the dae file(can be seen in the outliner with show only dag objects unchecked).


    if there are any ideas it would be much appreciated if they could come fast,i'm supposed to turn the thesis along with the project in this Friday(31/.

    Thx,
    Nikos


    EDIT1:btw i'm using Maya 2011 and the appropriate openCollada importer/exporter plugin.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •