Table of Contents

First Cast3D Application

Objectives of this sample are to demonstrate

  1. import of .3ds file into Cast3D .Xc3 xml file.
  2. setting up rendering scene
  3. loading and displaying 3D model

1. Importing 3D model

    C:\work> 3ds2XML stealth.3ds stealth.xc3 

A new file stealth.xc3 should appear in current directory.

2. Setting up 3D scene

Setting up scene consists of following steps:

* initial setup for Sandy3D.
public function setupSandy(): void
      // We create the camera = new Camera3D( 600, 400 ); = 1;
	// We create the "group" that is the tree of all the visible objects
	var root:Group = new Group();
	// We create a Scene and we add the camera and the objects tree 
	this.scene = new Scene3D( "scene", this, camera, root );		     
	this.scene.light = new Light3D(new Vector(0,0,1),100);
* initial setup for Cast3D.
public function setupCast3D(): void
       // init loading status		
        this.loaded = false;
       // new Cast3D instance with created earlier 3D scene and camera
	this.animator = new Cast3d(this.scene,;
       // set animation type
	this.animator.animationType = Cast3d.ANIMATION_TYPE_BYFRAME; //  ANIMATION_TYPE_REAL; //
       // set desired animation frame rate
	this.animator.fps = 22;
       // run it once
	this.animator.autoRewind = false;						

3. Loading model

*  Function performs 3D data  load from a X3c file.
private function loadData(): void
	/** stealth - simple model, no animation */
	this.loader = new Xc3Loader("stealth.x3c");
	this.loader.resourcePath = "/data";
      // optimize animation 
	this.loader.preCalcMotion = true;
     // register notification of load completion 
	this.loader.addEventListener(LoadEvent.LOAD_COMPLETE, this.cast3dLoadComplete);
     // register notification of load error
	this.loader.addEventListener(LoadEvent.LOAD_ERROR, this.cast3dLoadError);	
    // proceed with load 

If you noticed the line

        this.loader.resourcePath = "/data";

indicated the place where you want to put texture images and other media materials like sound, movie and video.


So, if done it right you should see something like these:

Complete source code of this sample.