A mesh instance places a given mesh at a given matrix within the world space of a scene. Essentially, it is a mapping from the object space of the mesh to the world space in the scene, with a small set of additional information specific to the instance such as render stats and material overrides.
You can only set up a mesh instance in the context of setting up a scene. See also Creating a Scene.
ILBInstanceHandle floorInstance; ILBMatrix4x4 floorTrans (/* matrix */); bex::apiCall(ILBCreateInstance(scene, floorMesh, "FloorInstance", &floorTrans, &floorInstance));
The render stats of a mesh instance determine whether or not the instance is taken into account during different types of rendering and lighting calculations. For example, you can specify for each instance whether or not it should cast and receive shadows, whether or not it should be considered in ambient occlusion calculations as an occluder, whether or not it should receive light from a global illumination pass, etc. The full set of controls are listed in the ILBRenderStats enumeration.
To customize the render stats for an instance, call the ILBSetRenderStats() function. You provide this function with:
You can override the materials specified in the source mesh for each instance you create by calling ILBSetMaterialOverrides(). The first material handle that you provide in this call is used for all triangles in the instance, regardless of the material names assigned to the triangles in the source mesh.
Currently, the material override affects all triangles in the source mesh. You cannot override different material groups in the source mesh with different materials in an instance. As a workaround, you can instead split each material group in your source mesh into a separate mesh. When you create an instance of one of those smaller meshes, you can override its material with a different material in your scene.
You have a limited amount of freedom to modify the instances in your scene after creating them. This may be particularly useful for live eRnsT sessions, in which the artist moves objects from place to place in the level editor.
API functions related to the creation and setup of mesh instances are declared in the beastinstance.h file.