Table of Contents

What is Cast3D?

Cast3D is 3D animation framework library for Adobe Flash in ActionScript3. The foundation is a multi key-framed geometrical animation. Cast3D supports geometry and texture morphing, skin animation, 3D sound, animated movie and video. A number of animation interpolation splines is implemented to provide smooth and natural motion, like Bezier, TCB, Hemite(cubic), Cosine and Linear.

Cast3D does not have it's own rendering engine. So for 3D graphics rendering Cast3D currently is ported to popular 3D engines, Sandy3D and Papervision3D.

Cast3D has it own data file. It is an XML file, which contains information about 3D scene, abjects of a scene, materials, textures, lighting, sound, camera etc.. and motion. Those who are familiar with COLLADA format, may find some similarity of data types in both file formats, but Cast3D file is much thiner and contains only data it can process.

To make process of creation of 3D Flash animations with Cast3D easy, import C++ library was introduced. Which purpose is to generate Cast3D XML file from exposed functionality of library. There are also few import utilities built on top of Import library available now for download, like 3dsMax (.3ds) file import utility and geometry generation sample. COLLADA file import is coming soon.

No native rendering engine's 3D data loaders are involved in loading process. Cast3D populates all the scene and motion data directly into the engine and controls transient or frame by frame rendering.

Here is 'Flying Stealth' sample (Sandy3D rendering engine). Originally imported from .3ds file, this model has a 'plane' motion, camera view point motion and synchronized 3D sound, which balance moves from right to left along with plane. Click on 'plane' to start animation:

Use controls (while not animating): Rotate: Left-Mouse-Drag, Pan: Ctrl+Left-Mouse-Drag, Zoom In/Out: Shift+Left-Mouse-Drag, or Mouse-Wheel
For more samples see Demo page.

Architecture

Cast3D is designed in a way that very little or no programming required for displaying and animating 3D scene.

Typically, creation of 3D Flash animation would follow these steps:

  1. Create and import 3D model file from a 3D modeling tool, for example 3dSMax.
  2. Using code for one of provided samples, update URL path of the .xc3 XML file to load.
  3. Build and add resulting SWF file to a HTML page.

yeah, it's that simple.

Main object class is 'Cast3d' which takes as arguments a rendering engine's 3D scene holder and Camera objects. Then it loads file and populates 3D scene graph for both. There is a way to override or add properties and interactive handles for specific geometry objects and materials during the load time.
For example, if somebody wants to modify a color, texture and lighting attributes of a material, or add some interactivity to 3D object, so it responds to a mouse click and triggers other actions.

    /**
     * Initial 3D scene setup and load.
    */
     {
          var animator:Cast3d = new Cast3d(this.scene, this.camera);
          var loader:Xc3Loader = new Xc3Loader("/demos/sandy/stealth_fly/stealthfly.x3c");
          loader.resourcePath = "/demos/sandy/stealth_fly/data";
          loader.load(animator.source);
      }

The main class also exposes high level control over animation, like 'start', 'stop', 'resume', etc.. .

For each frame Cast3D updates position and orientation of geometrical rendering objects:

   /**
     * Handles the ENTER_FRAME event and updates the 3D scene.
     */
      private function handleEnterFrame(event: Event): void
      {								
          // Update Cast3D first		
          animator.render();
 
         // then render scene 	
          scene.render();			
      }

Here is illustration for update scheme:

Animation 3D World update diagram

For sample code see tutorials page. Also for documentation and source code visit download page.

Acknowledges

Many thanks to Thomas Pfeiffer from Sandy3D community who's help with setting up website and support is hard to overestimate.

Thanks.