Understanding MaterialGroups¶
Material Groups¶
Material groups, or the IMML element <MaterialGroup>, can be used to specify material properties of IMML models and primitives.
A material group has two attributes: Id and Style. It also has five types of child elements: Material, Texture, Shader, Video and Web.
Id determines which mesh of the primitive or model the material group applies to. An Id of “-1” will act as the default material group. A material group of any other number will map to one specific mesh of the given model or primitive. For Models, the mapping between mesh and material group Id is determined by the index of the mesh in its source file; the first mesh specified has an index of 0, the next, 1, the next, 2, and so on.
Here is an example of a model containing three meshes, and the material ID mapping:
1 <Model name="ExampleModel" geometry="geometry/ExampleModelGeometry.geo">
2
3 <Mesh name="Box001" material="materials/matA.material.xml" /> <!------ maps to material group ID '0'-->
4 <Mesh name="Box002" material="materials/matB.material.xml" /> <!------ maps to material group ID '1'-->
5 <Mesh name="Box003" material="materials/matC.material.xml" /> <!------ maps to material group ID '2'-->
6
7 </Model>
Primitives have their mappings the same every time. To see how material Ids map to Primitives, download the demonstration park here