Kambi VRML game engine
← Users Developers →
 
Intro and News
 
view3dscene
 
The Castle
 
All Programs
 
Forum
 
Engine
 
VRML/X3D
 
Other
 

Kanim file format

Files with extension *.kanim represent "Kambi VRML engine's animations". These are XML files that describe precalculated animation as a sequence of files. Animation shows the transition from the first model to the last. Where models are structurally equal, intermediate frames are created by linear interpolation to show smooth changes.

Since animation by VRML events and interpolators is implemented in our engine now, Kanim format becomes obsolete. It's useful only if your favorite 3D modeler cannot export VRML/X3D animation with interpolators, but it can export static VRML/X3D files.

Blender exporter for this format is available (link to vrmlengine.sf.net), since Blender cannot export animations with interpolators to VRML.

On the positive side, there is at least one open-source program that can create animations with interpolators: White Dune. White dune has even an exporter to Kanim format, given a VRML animation by interpolators it generates a Kanim file and corresponding VRML files for each frame.

If you work with 3D modeler that can export proper VRML animation with interpolators, then you don't need to use Kanim format. Our engine handles events and interpolators perfectly. Internally, they may even be converted (after loading) to precalculated animations.

There's also a crude converter from kanim format to VRML/X3D interpolators in our engine examples (see examples/vrml/tools/kanim_to_interpolators). It's a little crude (works only when you animate only a single mesh), but may be enough for simple uses. So this is one way to generate an animated VRML/X3D file from Blender: export from Blender to kanim, then convert kanim to VRML/X3D.

For more technical insight, see description of animation handling in our VRML engine documentation.


File format is simple:


<?xml version="1.0"?>
<animation              // Root node is always "animation".
                        // All it's attributes are optional
                        // (default values are shown below).
                        // Some of it's attributes should be treated like a
                        // "hint for the renderer". General programs like
                        // view3dscene and demo_animation may honour them,
                        // but more specialized programs (like "The Castle"
                        // game) may ignore them, since "they know better".

  scenes_per_time="30"  // Suggested number of scenes per time to be generated.
                        // This is a hint for the renderer --- by default it's
                        // 30, but it may be ignored. Larger values make
                        // animation smoother, but also much more memory consuming.
                        // Special value 0 is allowed here, and means
                        // that animation will simply show each <frame>,
                        // suddenly changing into the next <frame>,
                        // without any smoothing of transitions with
                        // intermediate scenes.

  optimization="separate-shapes-no-transform"
                        // Suggested optimization method.
                        // This is again only a hint for the renderer, and may
                        // be ignored, see `view3dscene --help' to see the
                        // list of available values.
                        // Ignore this if you don't know what it means.

  equality_epsilon="0.001"
                        // Epsilon to use when comparing animation frames
                        // and deciding which parts didn't move at all between
                        // two adjacent frames. You can set this even to literal
                        // "0.0", but this may cause a lot of memory to be wasted
                        // when loading large animation. It's better to set
                        // this to some very small value --- so small that you're
                        // sure that user will not notice such small move
                        // anyway.

  loop="false"          // Should the animation loop ? This is a hint for
                        // the renderer, and may be ignored. Allowed values
                        // are "false" and "true", not case-sensitive.

  backwards="false"     // Should the animation go backwards after going
                        // forward ? Allowed values
                        // are "false" and "true", not case-sensitive.
>

  // A number of <frame> nodes should follow. At least one is required.
  // Note that exactly one <frame> node will actually define a still scene,
  // you need at least 2 frames if you want a real animation.

  <frame

    file_name="file_1.wrl" // This is a required attribute, and specifies
                           // the filename from which to load this
                           // animation frame. Any 3D file format is allowed here:
                           // most of all, VRML/X3D, but also
                           // other formats understood by my engine.

    time="0.0"             // This is a required attribute specyfying a
                           // time of this frame. For now, all frames
                           // must be specified in the strictly increasing order
                           // of their "time".
                           // This is understood to be in seconds.
  />

  // For example, assume that the second <frame> node follows.
  // So this defines an animation that changes from
  // file_1.wrl and file_2.wrl in exactly 1 second.

  <frame file_name="file_2.wrl" time="1.0" />

</animation>