Results 1 to 4 of 4

Thread: mesh with subset.

  1. #1

    mesh with subset.

    hy.
    I have a mesh with 2 subset with 2 different material .
    My importer start to import from the scene graph.
    But when i get a node of the scenegraph i have an istance with the 2 material

    this is a piece of the xml collada file
    Code :
    <instance_geometry url="#Cube-Geometry">
    					<bind_material>
    						<technique_common>
    							<instance_material symbol="Materialaer" target="#Materialaer">
    								<bind_vertex_input input_semantic="TEXCOORD" input_set="1" semantic="CHANNEL1"/>
    							</instance_material>
    							<instance_material symbol="Material_ferr" target="#Material_ferr">
    								<bind_vertex_input input_semantic="TEXCOORD" input_set="1" semantic="CHANNEL1"/>
    							</instance_material>
    						</technique_common>
    					</bind_material>
    				</instance_geometry>

    Code :
     
    now in the normal sequence i get the geometry 
    const domInstance_geometry_Array pGeomAry = m_CurrentNode->getInstance_geometry_array()//current node is the current node //selected by the traverse the scene graph.
     
    //i use this for get the geometry isnstance.
    xsAnyURI puriGeom = pGeomAry.get(0)->getUrl();
    puriGeom.resolveElement();
    In a multiple mesh subset i get the group of triangles that have the current node material group of vertex,but with 2 instance of 2 different materials how i resolve the triangle group that i must process?(I have 2 triangle group in this case ) and start reading the geometry of the corrispondent subset(triangle group)?

    thanks.

  2. #2
    Member
    Join Date
    Feb 2005
    Location
    San Jose, CA
    Posts
    63

    Re: mesh with subset.

    In your example, Your 2x <instance_material> is used only inside that <instance_geometry>.
    Your <geometry> should be something like this.
    Code :
    <geometry id="Cube-Geometry">
       <mesh>
          ...
          <triangles material="Materialaer"> ... </triangles>
          <triangles material="Material_ferr"> ... </triangles>
       </mesh>
    </geometry>

    Your <bind_material> is trying to bind:
    Materialaer with <material id="Materialaer">
    Material_ferr with <material id="Material_ferr">
    The material group names in triangles happened to be the same as id of material. This is not neccessary required.

    Here is a better example on how to resolve the material binding
    Code :
    <geometry id="geometry1">
       <mesh>
          ...
          <triangles material="group1"> ... </triangles>
          <triangles material="group2"> ... </triangles>
       </mesh>
    </geometry>
     
    <instance_geometry url="#geometry1">
       <bind_material>
          <technique_common>
             <instance_material symbol="group1" target="#blue"> ...
             <instance_material symbol="group2" target="#red"> ...
          </technique_common>
       </bind_material>
    </instance_geometry>
     
    <library_materials>
       <material id="blue">...</material>
       <material id="red">...</material>
    </library_materials>
    you can make another instance geometry that reference the of the same geometry that binds with different materials
    Code :
    <instance_geometry url="#geometry1">
       <bind_material>
          <technique_common>
             <instance_material symbol="group1" target="#green"> ...
             <instance_material symbol="group2" target="#yellow"> ...
          </technique_common>
       </bind_material>
    </instance_geometry>

  3. #3

    Re: mesh with subset.

    thanks.
    And in collda dom(that i use)there is a method for get the relative materials group triangle?
    Now I get the group of triangle by a numeric index (0,1,2)in succession.
    How i get the group by the specific material?

  4. #4
    Member
    Join Date
    Feb 2005
    Location
    San Jose, CA
    Posts
    63

    Re: mesh with subset.

    The material group is a xml attribue in your triangles element.
    If you use the COLLADA DOM, then check the below code
    Code :
       domTriangles * triangles = mesh->getTriangles_array()[triangle_index];
       daeString * material_group = triangles->getMaterial();
       // lookup your binding table with key = material_group
       // you'll get result material ID from the binding table
       // That ID will be the material you use for that instance_geometry

    Herbert

Posting Permissions

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