![]() |
VR-Forces 4.5 Class Documentation
|
This example shows load an OpenFlight geometry file into a DtOsgArticulationModel and then adds the model to the scene with a DtSceneObject. Of particular interest in this example is how to create and initialize a model and a scene-object.
To create a basic VR-Vantage application, first instantiate the application, initialize it and finally call run.
... add some content to the application ...
The content that this example application displays is geometry in a DtOsgArticulatedModel (a derivation of DtModel). A DtModel is a managing container for a single DtModelInstance, providing more attributes about how the DtModelInstance should be rendered. Initialization of a DtModel starts with giving it a model-definition. Unlike the DtModelInstance which can be handed a model-definition identifying the model to load, the DtModel retrieves a model-definition which has been pre-loaded into a definition-manager. Usually DtModelDefinition objects are automatically loaded from disk to populate the definition-manager, however this example demonstrates creating one and registering it with a definition manager in code. This example constructs a DtModelDefinition and registers it in the definition-manager found within the display engine.
After the model-definitions have been pre-registered within the definition-manager, DtModel objects can access the definitions by name. To load geometry from disk, it is just a matter of telling the DtModel which definition to use. This example uses a DtOsgArticulationModel (derived from DtModel) to load geometry that can be articulated. When given the name of a registered DtModelDefinition, the DtOsgArticulationModel retrieves the definition, internally constructs a DtModelInstance then uses the definition to load the geometry into the model-instance.
After loading the geometry, this example manipulates some of the articulation nodes within the geometry.
Initializing a DtModel only loads the geometry and prepares it for rendering. The DtModel has to be place in the scene to be rendered. To add the model to the scene, a DtSceneObject is used to manage the model. The DtSceneObject is a container class that 'groups' multiple models into a single scene-object. A scene-object is an association of models that can be manipulated as a single unit. Among other features, the DtSceneObject identifies a single position and attitude within the scene for all models associated with it. As such, models are added to (and removed from) the scene object to be inserted to (and removed from) the scene itself. To create and initialize a DtSceneObject it must be constructed with a unique identifier and then associated with a model-set. A model-set is an identifier associating a complete set of visual-types to be rendered within a single channel.
Once constructed the DtSceneObject can be positioned and oriented within the scene so that any models added to the object will also be positioned and oriented.
When a model is added to a DtSceneObject it is automatically inserted into the scene. The DtSceneObject manages retrieving the renderer and identifying which channel rendering the scene to place the model in.
This example associated the scene-object with the model-set zero (the first model-set), gave arbitrary identifiers to the scene-object and model, and gave an arbitrery visual-type to the model when it was inserted into the scene-object. Of course these arbitrary values have specific meaning in real-world applications.
VR-Vantage includes pre-built versions of the example application. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.
This example is an application. You can run it by running ./bin/exampleModelArticulation.exe (on Windows) or ./bin/exampleModelArticulation (on Linux). For more information about running examples, please see Running Applications and Examples.