welcome to linkAR technical documentation



Add Models

3.1.- Create a Model

The model is the basic object in our 3D world that will load the EAD and where we will manage all our transformations, animations, textures, videos, etc…

This scene we are showcasing has 4 groups: the root containing the girl and the earth piece, the animation objects, the sky dome and the buttons.

int MainModelRootID;
int skyModelID;
int buttonsModelRootID;

When we create a new model object, we can set its unique Id or we can let the system generate one for us:

private void loadEADScene()
   /** Create Girl model Root object*/
   MainModelRootID =  gl3DEngine.createNewModel();	
   /** Create Sky model root object*/
   skyModelID =  gl3DEngine.createNewModel();	
   /** Create Buttons model Root object*/
   buttonsModelRootID = gl3DEngine.createNewModel();	  

For each EAD object you want to load you need to create a new model, therefore you will be able to manage them separately. This items are usually called Worlds

3.2- Load and attach EAD

Once we have created a world, we will load the EAD object and attach it to its world. The EAD file is the exported model / scene from 3DMax.

We define some parameters:

int skeletonAnimationID;
int leftButtonModelID;
int MidButtonModelID;
int RightButtonModelID;
int HeadModelID;
int rightEYEmodelID;
int rootModelEAD_ID;
int skyEAD_ID;
int GirlShirtModel;
private static String TAG = "Hello3dLite";
EADResult eadResult; 
/** Load 3D Model scene graphics from file*/
// 1.-
eadResult = gl3DEngine.loadEAD("Data/Models/girlscene/girl_model.EAD");
rootModelEAD_ID = eadResult.getEAD_ID();
// 2.-	    	    
if(rootModelEAD_ID != -1)
   /** Attach graphics to the model*/
   // 3.-
   if(!gl3DEngine.attachEAD(MainModelRootID, rootModelEAD_ID))
      Log.d(TAG, "Error attaching girl_model.EAD");   	
  1. First, the model is loaded in the engine. Since this moment, the object will be ready to be attached to a world.
  2. We ensure that the model is correctly loaded.
  3. We attach the scene to the MainModelRootID world.
/** Load animation to the engine*/
eadResult = gl3DEngine.loadEAD("Data/Models/girlscene/girl_animation_01.EAD");
if (eadResult.isAnimationLoaded())
   Log.d(TAG, "Animation loaded girl_animation_01.EAD");
/** Load animation to the engine*/
eadResult =  gl3DEngine.loadEAD("Data/Models/girlscene/girl_animation_02.EAD");
if (eadResult.isAnimationLoaded())
   Log.d(TAG, "Animation loaded girl_animation_02.EAD");
/** Load animation to the engine*/
eadResult =  gl3DEngine.loadEAD("Data/Models/girlscene/girl_animation_03.EAD");
if (eadResult.isAnimationLoaded())
   Log.d(TAG, "Animation loaded girl_animation_03.EAD");

When we load the animations, the animations are ready to be set to the model. Consider the animations are playable only in the scene that they were designed for.

/** Load Sky scene graphics from file*/
eadResult =   gl3DEngine.loadEAD("Data/Models/girlscene/skydome.EAD");
skyEAD_ID = eadResult.getEAD_ID();
if(skyEAD_ID != -1)
   /** Attach graphics to the model*/
   if(!gl3DEngine.attachEAD(skyModelID, skyEAD_ID))
      Log.d(TAG, "Error attaching skydome.EAD");

We load the Sky EAD and attach it to the skyModelID world.

/** Load Button scene graphics from file*/
eadResult =  gl3DEngine.loadEAD("Data/Models/girlscene/buttons.EAD");
int eadID = eadResult.getEAD_ID();
if(eadID != -1)
   /** Attach graphics to the model*/
   if(gl3DEngine.attachEAD(buttonsModelRootID, eadID))

The buttons are loaded in buttonsModelRootID world.

/** Load scene Lights from file*/
eadResult = gl3DEngine.loadEAD("Data/Models/girlscene/girl_lights.EAD");
eadID = eadResult.getEAD_ID();

Finally we load the lights, the lights do not need to be attached to any world, they will affect (by default) all the objects in the scene. Later we will explain how to avoid objects from being affected by lights.

3.3- Getting scene information

It is necessary that you know the details of the scene you are loading into the engine. However, we provide you with some functions that help you to get extra scene information:

  1. getHierarchyNames: Provides you a list of all the parts of the model. In the girl scene, those are composed by Bones and Meshes.
    1. Bones: You can find additional information here. The functions you can use with these objects are transformations (setModelRotation, setModelScale, setModelPosition, setModelMatrix) and animations (setAnimation). These functions can also be applied to worlds.
    2. Meshes: The function getMeshesNames provides you a list of all the meshes of the model. These meshes are the objects that support the functions regarding visibility (setVisibilityForHierarhchy), textures (getTextureList), lights (setAffectedByLights).

To apply those functions you will need to know the object ID. For that purpose you must use the getModel function. After loading and attaching the girl scene, we can get some of the girl parts:

In this case, we know the girl head is controlled through the "ctl_head" bone. Any animation or transformation we apply to "HeadModelID" will affect only the girl head.
Another part of the model is the girl skeleton object. In this case whatever animation/transformation we apply on the skeleton will be applied only to the girl and  its sword, but not to the piece of earth under it.
HeadModelID = gl3DEngine.getModel(rootModelEAD_ID,"ctl_head");
skeletonAnimationID = gl3DEngine.getModel(rootModelEAD_ID,"ctl_girl_root");

As explained before, we will need to get the ID of the mesh we want to change its visibility parameters.
GirlShirtModel = gl3DEngine.getModel(rootModelEAD_ID,"m_girl_shirt");

For its convenience, it is recommended that the designer names the parts of the model according to ARLAb patterns.

3.4.- Replacing Textures

Each EAD object has several intrinsic textures to load. Those textures can be modified using the replaceTexture function.

   gl3DEngine.replaceTexture(GirlShirtModel, "Data/Models/girlscene/Textures/girl_texture.png", "Data/Models/girlscene/Textures/scenery_texture.png");

With this function you can replace any texture that is defined in each model (For instance girl_texture.png or girl_normal.png).

  1. Remember to apply this function to meshes objects.
  2. Consider replacing the texture modifies all the meshes that use that texture file.

When you replace textures be sure that the new texture has the same size as the replaced one.