How to render a 3D Entity
This articles explains how to render a 3D entity using the Untold Engine.
Steps to render a 3D character
The steps to render a 3D object is summarized below:
Load scene data
Create a Game Entity
Load the attributes
Add the game object to the scenegraph
Step 1. Load Scene Data
Before you can render a character, you must load the character's attributes. The loading is done through the use of U4DEngine::U4DResourceLoader class. The class loads the binary files (.u4d) representing the scene attributes (line 1a) and textures (line 1b).
Note: Please make sure to read the Untold Engine Toolchain before continuing on with this tutorial.
Step 2. Create a Game Entity
In line 2, we provide a name for the game model, myAstronaut, and use the C++ keyword new to create an instance of U4DEngine::U4DModel.
Step 3. Load Attributes
The U4DEngine::U4DModel::loadModel() method loads the attribute data into the character's data members (line 3). The method requires the name of the 3D model, as specified in Blender 3D.
Note that the loadModel() method returns a boolean value. The method will return false if the file was not found, or if the attributes are corrupted.
If the loadModel() method returns true, the next step is to send the attributes to the GPU. This is accomplished with the U4DEngine::U4DRenderManager::loadRenderingInformation() method (line 4).
Step 4. Add the game model to the scenegraph
Finally, the game object is added to the Entity Manager using the U4DEngine::U4DEntity::addChild() method (line 5).
Complete Code Snippet
The complete code to render a 3D Game Character should look as follows:
Result
Last updated