Return to the tutorials list.

7 - Model Instanciation

For this tutorial, we will use an animated model and instance it 5 times. 3 of the instance will use the same animation play in sync and the last ones different animation.

Model instanciation is done using ModelInstance, which support instanciation of an AsyncModel (model loaded asynchronously).

Each instance have a different position and rotation, which is stored in a Transform object (which support scaling as well). Positioning can be done before the actual model is loaded using ModelInstance.getModel. This is possible by the fact ModelInstance.getModel return the instanced Model which is always not null (its internal structure will be updated when async loading ends).

The animation is set differently. It requires the model to be loaded, and therefore we are using a callback mechanism with OnLoadListener. Once the Model of the instance is loaded, the listener and called and we are setting the appropriate animation.


Similarly of loading ModelReaderSettings from xml, this tutorial also show an alternative way to create ModelInstance from a serialized xml using WorldLibraryIO.


Preview
Model instanciation


Source Code


Xml data