welcome to linkAR technical documentation

next previous


5.1- Play with animations

The animations must be loaded from an .EAD file.

The API provides following functions:

  • play
  • pause
  • resume
  • stop
  • set and get animation speed
  • set animation loop
        // 1.-
        animationObjId = [glView getModel:@"ctl_girl_root" witheadId:girlEADRes.EADId];      
        // 2.-
        if ([animationObjId intValue] > 0) {
            // Set animation to the model.
            // 3.-
            if([glView setAnimation:@"girl_animation_01" withModelId:animationObjId])
                // Play animation previously set.
                // 4.-
                if([glView playAnimation:YES withModelId:animationObjId])
                    NSLog(@"Animation Playing");
  1. First we need to find the Bone where we want to play the animation. Use the getModel function with the bone name. Bones are parts of the scene where animations can be played:
    1. If you did the scene, you know which are those bones.
    2. If someone did the scene for you, ask him which bones are available for the animation you want to play.
    3. You can use the getHierararchyNames function to get a list of all the model parts.
  2. We ensure that the ID is correctly obtained.
  3. We set our animation to the girls skeleton. If we would like to play the animation only in a specific part of the model we could set it here (for instance only in the head).
  4. If all was correctly set, the animation is played. Remember to play the animation on the same object you set it (in this case animationObjId).

The render protocol is called each rendered frame, so it's a good place to perform actions:

    //Here we can do transformations (rotation, scale, translation)

next previous