Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog

Include 3D models in HUD
26th January, 2010

Include 3D models in HUD


1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 5.00 out of 5)
Loading ... Loading ...

You always wanted to have a 3D animated models in your HUD, and you never know how to do that ? This tutorial is made for you.


If you don’t know how to create a game, a scene and a user AIModel, please do the ‘First Application’ tutorial before this one.


Create a game, a scene and a user AIModel which launch your scene (you can also use your own scene/game).

Don’t forget to edit the scene in “Textured” mode to be able to see objects with camera or light attributes.


The output of a camera can be rendered in a rendermap. Then the rendermap can be displayed in a hud component.

In fact, the 3D model you will see in the HUD is the view of a camera which is not the active camera.


In the Data Explorer, create a rendermap (Create>Resource>RenderMap) and name it (‘MyRendermap’, for instance).

One active camera to work

To manipulate the camera which will be used for the 3D HUD, it’s preferable to use another camera, a camera which will be the active camera. You can use the default camera (if existing in your scene) or create another camera. Don’t forget to set it active (in the Scene Explorer, clic on the icon corresponding to the camera).

One camera for a 3D HUD

Create a camera (in the Data Explorer : Create>Model>Camera>Simple). Put the camera in the scene and select it. In the Attribute Editor, Camera section, select the rendermap in the ‘Output’ field.


To display the camera output in a HUD, you have to create a HUD component, type RenderMap. In the HUD Editor, create this component. When editing it, go to the RenderMap section and select the RenderMap you have created previously (the same than the one of the camera). Then, reference your HUD in the Game Editor > Resources tab.

In the onInit handler of your AIModel, instanciate your HUD (hud.newTemplateInstance).

The light

In the Data Explorer, create a directional light (Create>Model>Light>Directional). Add it to your scene and select it. In the Attribute Editor, Light section, unckeck ‘project shadows’ (only one light can project shadows in the scene, it will be the main light, not this one) and check ‘Affects only objects in the same group’ (the light will illuminate not all the scene but only objects of its group).

Now, group the light to the camera : Select the light first, then add the camera to the selection with Ctrl+Clic and finally, right clic and select ‘Group Selection’ and check ‘Parent to last selected object’.

Make the position and the orientation of the light the same than the camera : Select only the light (in Single selection mode: ) and in the Attribute Editor, Common Attributes section, reset its translation and rotation.


You now will define the background color of your 3D HUD. Create a plane (Data Explorer : Create>Model>Shape>Plane) with a +Z normal vector. Put it to the scene.

Create a material (Data Explorer : Create>Resource>Material). Then, select your plane in the Scene Viewver and drag’n'drop the material on it.

Now open the material in the Material Editor. In the ‘Lighting’ section, configure the colors to have the one you want for your background (mine is black).

Group the plane to the camera with the same method than for the light (select the plane first, add the camera to the selection and group them using the last selected object as parent). Reset the translation and the rotation of the plane to match the camera and translate the plane in front of the camera.


It’s now the time to add the object you want to see in the HUD.

Put it in the scene and add it to the group of the camera. Then, place the object between the camera and the background plane.

To place your object precisly, you can set the camera you work on as the active camera (press C, then righ clic on the camera in the newly opened window and select ‘Set as Active Camera’).

When you have finish, set as active camera the one you was working with.

Now, select the group and in the Attribute Editor, place it far away (3000 for instance, on at least one axis).

Then, select the main camera of your scene (the camera which will be the active camera when playing) and set its max view distance to 1000 (Attribute Editor > Camera Attributes tab > Clip max).

When you have finish, you can set this camera as active, save the scene and start the game (F9).


Leave a Reply

You must be logged in to post a comment.