Chapter 7. Animation

Table of Contents

7.1. Interactive VRML: TCastleScene with ProcessEvents = true
7.1.1. 3D formats support
7.2. Non-interactive precalculated animation: TCastlePrecalculatedAnimation
7.2.1. 3D formats support
7.2.2. Structural equality
7.2.3. Generating intermediate scenes
7.2.4. Storing precalculated animations in Kanim files

There are two approaches to playing a 3D animation in our engine:

7.1. Interactive VRML: TCastleScene with ProcessEvents = true

This approach means that you load one VRML / X3D file, and the TCastleScene (actually, ancestor TCastleSceneCore) will make the events work, sending/receiving events through routes, activating sensors, running scripts etc. Among many things, this means that world time will be passed to VRML TimeSensor nodes, allowing you to animate by VRML interpolator nodes. You can also pass user input to TCastleSceneCore methods like TCastleSceneCore.KeyDown, and then the user will be able to fully interact with the VRML scene.

This is what should be used for presenting interactive VRML world to the user, as envisioned by VRML specifications.

7.1.1. 3D formats support

  • This plays interactive and animated VRML / X3D files.

  • You can also load any other 3D model files to TCastleScene. But turning ProcessEvents = true will do nothing for non-VRML files. Result will be just a still scene. Other 3D model formats cannot declare things like sensors or routes, so activating VRML events processing for them is useless.

  • The Kanim format is an exception — it cannot be used in such way. Kanim format can only be loaded to a sequence of still VRML models, or to TCastlePrecalculatedAnimation described below. That was the very design idea behind Kanim format, actually. You cannot load it and play with a single TCastleScene instance.