1. Welcome

IIf you are reading it might be because you’d like to learn how to use HALCA, a library developed by Bernhard Spanlang for character animation. In particular, you’d like to use it in XVR, a tool to render those animations. In such a case, you can download the tutorial files from here. This document is organised as follows:

  1. Welcome

  2. Basic Notions

  3. Start Using Halca

  4. Pipeline to import animations

  5. How to use morph targets

  6. Troubleshooting

This tutorial has been developed at the EVENT Lab by Joan Llobera with some input from Daniel Pérez-Marcos. A description of the HALCA library can be found at: http://www.lsi.upc.edu/~bspanlang/animation/avatarslib/doc/.

  1. Basic Notions


The main functions are:
           This includes the calls to SceneBegin() and SceneEnd(), in which the drawing functions should go.

Other functions: OnTimer, OnExit, OnDownload...

What any program has to do is:

  1. Find out what characters should do

  2. do it

  3. show it was done



This function initializes the avatars, loads the animations, etc.

There are 3 ways of executing animations. It is recommended not to mix modes. (see step 2 of the pipeline explained below),
            exeAct() This function executes an animation once.
            blendCycle() This function executes an animation in a loop
            Morph() This function executes in morph mode (see second tutorial)

To update the animations (in all 3 modes)
        This function updates the positions according to the loaded animations but also with other functions, as for example SetPosition

To draw the animations (see step 3 of the pipeline below)

  1. Start Using HALCA

To do this, I’ve prepared a tutorial for you. Open the folder named “my first XVR project, and notice it includes:

-FirstCharacter.s3d: the main functions in XVR

In it, you can also find:
-Common: some common functions generally used, such as mouse navigaton.
-KeyboardManager: this is used to interact with the keyboard.
-Other files such as dll, etc. that make the system work

Do not take care of the other files, and try hard finding the solution before you look the solutions. By now, only fill in the TO DO parts, which are 4 exercises, in order of increasing difficulty. This will show you how to load a character, add a basic animation and do a first adjustment to this movement. At the end there is also a fifth exercise to introduce you to the use of morph targets.

If in addition to these exercises you want to add your own animations and /or morph targets, there are instructions to do so below.

NOTE: start opening the .prj file in XVR...

  1. Pipeline to import animations

Below is explained how to export characters and animations from 3D Studio max into XVR. The process should be attempted by anyone wanting to use the library.

1) load the 3D model in 3d max.: we have a character.

(if it is not rigged, there you go... good luck)
(if don't want to rig, you can also just create a biped without rigging, but it will not be possible to visualise that in HALCA)

2) load the animation related to it.

(or animate, or whatever you want that has as a result an animation)

3) export it as a cal3D animation

       -set the apropriate name sets (in edit > edit named selection sets)

        -ensure you are in FIGURE MODE

       -run the unified script export_cal3D
             (useful info: can be found at: http://www.cs.ucl.ac.uk/staff/W.Steptoe/char/char0700.html)

-xaf file is the animation
-cfg is the config

-xrf is for material (only jpeg supported, not tiff, and power 2 resolution)

       -go out from figure mode
       -export the animation

       -build the following structure:
             -in the folder of the project, create a folder named data. Put the cfg file of each character in it.
             -in the data folder, create another folder also named data, and put the rest of the files of the character in an other folder in it. It is recommended that this last folder is character specific.
                    Ensure the texture files referenced in the xrf are in this folder   (see 5.C for how the different materials are linked)

            -add to the cfg files the names of the animations you want to load

NOTE: to be able to export you need:

-a file called cal3d.dll in the 3dsmax8 folder

-a file called cal3d_max_exporter_DL3D.dle in 3dsmax8/stdplugs.

4) export the "furniture"

AAM format is what is preferred by XVR

5) create an XVR project with these things.

5.A)       -Download the following files from http://www.lsi.upc.edu/~bspanlang/animation/avatarslib/doc/ :
-Avatars.s3d to load the functions of the dll in XVR
HALCAWin32.dll or HALCAX64.dll dependent if you use 32 or 64 bit windows
             -skinshDquat.sh, (Note you should change #define DQUAT_TRANSF_XVRSHADER if we use skinshDQuat.sh)

             -To obtain Common.s3d, in order to have some basic functions, including necessary things in order that the characters work well.

To be taken in account:

to draw the avatars with:

instead of the usual

please note the import of the dlls is set in the avatars.s3d file.
Therefore, the only lines necessary are
#include "Common.s3d" //some general-use functions
#include "Avatars.s3d"

5.B) structures of data:

5.C) in onInit(), set the function to local dir (XVR engines after 147 is necessary)


Inititalize the avatars (this loads the functions of the dll)

And finally addthe characters


6) Load the animations in your XVR project

Parameters: ( C_VOID, "exeAct",C_INT,C_INT,C_FLOAT,C_FLOAT);// AvatarID, AnimationID, inTime, outTime

For example:


To take into consideration:

Takes as parameters: AvatarID, AnimationID, inTime, outTime (default 0), weight (how much of the animation),  lock (pose after playing)

The number of the animation (AnimationID) is the order of appearance in the .cfg file, starting from 0, or can be obtained with:


The number of the avatar is the order of declaration, and is returned by:


  1. How to use Morph Targets with Avatars

This process is of a slightly more advanced level. It explains how to use morph targets within HALCA.

1) Add the meshes in the .CFG file, e.g.:




2) Modify the SKinshTM.sh file:

2.A) Add the Vertex and values attributes for each morphtarget, e.g.

uniform float morphval0;

uniform float morphval1;

attribute vec3 vertexMorph0;

attribute vec3 vertexMorph1;

2.B) Modify the following equation to add the effects of each target morph.

vec4 pos = gl_ModelViewMatrix*weightmat*vec4((vec3(gl_Vertex)+vertexMorph0*morphval0+vertexMorph1*morphval1),1.0);

//The current morph value (stand) is given to the function

3) add a function to modify the morphs:

3.A) in main.s3d:

#define TM_TRANSF_XVRSHADER //instead of VA_TRANS

var morphval=vector(10); //up to 11 morphes

//If you want to modify the morph manually with keymanager:

function incMorphVal(i,x){



KeyManager.addKeyFunction("m",VK_LSHIFT,true,"incMorphVal",{0,0.01},2,"Increase Morph"); //In oninit

3.B) in Drawscene();

#ifdef VA_TRANS









PRINT HELP on the screen:


#include "HUD.s3d"

#include "IK.s3d"

function togglePrintHelp(){



*******+* ONINIT:
KeyManager.addKeyFunction("h",0,true,"togglePrintHelp",{},0,"Print This Help");

******* ONFRAME: (at the end):

******* ONTIMER:

- IN HUD.s3d:
HUDvisible = true;

  1. Troubleshooting

1) If you want to use Vista, pray.

        If you have a MSVCR80.dll dependency, then stop, stay calm, and look for the good side of life, because you need a new XVRCal3d dll version.

if still, after that, you're going to try with Vista, or with other OS, can be useful to check you have all the dll. dependencies.
This can be done with Depends. http://www.dependencywalker.com/

For example, in Vista,
you might need to install NetFramework version 2 or 3