Creating Cal3d media

This page describes how to export a model to cal3d format as used in WorldForge be the Sear client and the model2sprite tool. The description is based on hands on experience and on discussions in the Cal3d forum. The page assumes that 3dsMAX is used. There exists a Cal3d exporter for Milkshape, and one will also be made for Blender at some point, but the author has no experience with these.

1. Creating model

You must create a full skinned model in 3dsMAX, either done with bone/skin modifiers or biped/physique modifiers. (There might be some problems if you have some fancy modifiers on your stack, as not all possibilities have been tested yet. It may be a good idea to collapse stack before applying skin/physique) There exist many tutorials on low-poly modeling and character animation within 3dsMAX, both in this site and in the rest of the net, so that part will not be covered here.

2. Preparing for Cal3d export

Assigning materials correctly within 3DSMAX is important. Each material used on the model must have a slot in the material editor. Each material must be named with a individual material number (tag) in a bracket, starting at 0.
Example:

Skin [0]
Face [1]
Shirt [2]

WorldForge 3D media uses .png textures. Currently only diffuse texture is used in the clients, but cal3d can also export materials specifying bump textures etc. For simplicity, use only standard materials. DON'T use procedural materials like noise or gradient. These materials are specific to 3dsMAX, and cannot be used anywhere else.

3. Exporting model

Now we are ready to start exporting the data to Cal3d. It's important to export the skeleton first. Any selected object will be used as starting point for the search for possible bones, so you should select the root bone of the model, or nothing at all to get the full list of model bones in the exporter dialog box. Then click on file>>export, and select Cal3d skeleton. When you see the hierarchy of bones, check all the bones you want to export. Remember that only checked bones can be used later to deform the skin or perform animations. Save as a .csf file.

After you have exported the skeleton, you export the meshes (.cmf), animations (.caf) and materials (.crf) in any order you want. The first step is always the selection of the previously exported skeleton file to have the link to the bones in the model. Some notes for the mesh export: The mesh you want to export must be selected. If you change the assignment of materials to a mesh, it's important to export the mesh again, as it stores the material tag/id in its files.

When exporting animations, it makes sense to check only the bones the animation actively utilizes. This reduses filesize, and makes the animation more versatile. Say you export an animation where the character is nodding. Check only neck-bones and head. Not exporting information about the right toe of the character does not reduce animation quality, and allows mixing the nodding animation with, say, a walking animation without the rest of the body going rigid.

Spring systems

Cal3d supports the use of spring systems. The paladin cape is such a spring system. Before going deeper into spring systems, there are some things which MUST be implemented for spring system to become a functional feature:

First of all, this feature is far from complete. There is currently no collision detection at all (see paladin cape-through-body glitch). This must be implemented for spring systems to work properly. Also, the physical model doing this animations might still be modified, or at least extended (influence of wind, etc...). So what you can do now is: either help implementing collision detection in Cal3d, or start with making your spring systems while keeping this in mind:

The vertices of the cloth get connected with springs which need to be calculated, and need to be checked for collisions in realtime, so this will give a big performance impact even if the sptring system has only a few vertices. Don't even think about a 1000-vertex cloth mesh! If you still want to export spring systems, then use the following steps:

  1. Skin your model including all clothes as usual in 3ds max, either with biped/physique or bone/skin modifier.
  2. Assign a vertex weight > 0.0 to each vertex that should be simulated as cloth. Vertices with weight = 0.0 will be treated as regular (un-clothed) skinned vertices. If you use Physique modifier: modify>>physique>vertex mode, select vertices for spring system, unselect from all bones. The selected vertices now become blue "root vertices".
  3. Make sure that the whole cloth mesh has only one single material and all the faces in it are in the same smoothing group. This is very important, the exporter will freeze otherwise!
  4. Export the mesh(es) and enable the cloth export flag.

4. Create cfg/cal file

A cal3d .cfg/.cal file is a character setup file, describing how the different exported elements are assembled in the Cal3d based client. The file is written in ascii format, and can be edited in standard ascii editors, like M$ notepad. Any comment-lines starts with #. The .cfg/.cal file starts with defining model scale and skeleton file. Then the different animation files are listed. Their order of appearance/definition names set how they are handled by the client. Following, the different meshes used to build the character are listed. Again, Their order of appearance/definition names set how they are handled by the client. Finally, the materials are listed. Their order of appearance must be so that material tagged with [0] appears first in list, then nr. [1].. etc.

Example:

scale=0.005
skeleton=male.csf

animation_idle=male_idle.caf
animation_wave=male_whatever.caf
animation_standing=male_stand.caf
animation_walking=male_walk.caf
animation_strut=male_stand.caf
animation_running=male_jog.caf

mesh=male_arms.cmf
mesh=male_face.cmf
mesh=male_pants.cmf
mesh=male_shirt.cmf
mesh_belt_axe=male_axe_belt.cmf
mesh_hand_axe=male_axe_hand.cmf

material_default_skin=male_skin.crf
material_default_face=male_face.crf
material_default_shirt=male_shirt.crf
material_default_pants=male_pants.crf
material_default_shoes=male_shoes.crf
material_default_axe=male_axe.crf