homeへのリンクです。

Sandy 4

2007年07月08日

詳しい説明はこのページ。
サンプルコードは以下のような感じ。

import sandy.core.data.*;
import sandy.core.group.*;
import sandy.primitive.*;
import sandy.view.*;
import sandy.core.*;
import sandy.skin.*;
import sandy.util.*;
import sandy.core.transform.*;
import sandy.events.*;
 
function init( Void ):Void
{
   // we create our camera
   var cam:Camera3D = new Camera3D( 600, 600 );
   // we add the camera to the world
   World3D.getInstance().addCamera( cam );
   // we move the camera backward to be able to see the object placed at 0,0,0
	cam.setPosition(0, 0, -500);
   // we create the root node.
   var bg:Group = new Group();
   // and set it as the root node of the world.
   World3D.getInstance().setRootGroup( bg );
   // and we lauch the scene creation
   createScene( bg );
   // and now everything is created, we can launch the world rendering.
   World3D.getInstance().render();
}
 
function createScene( bg:Group ):Void
{
   // We create our object. It is a cube of 50 pixels, and with the quad mode, so here four points per face.
	var o:Object3D = new Box (50, 50, 50, 'quad');
	// we create a skin to "dress up" the object a bit, and make it visually better.
	//  SimpleColor skin is used here, it needs the fill color, alpha, and thickness
	var skin:Skin = new MixedSkin (0x00FF00, 100, 0, 100, 1);
	// We apply the skin to the object
	o.setSkin (skin);
	// We create two TransformGroup instances. Each one corresponds to a node of the tree we are going to create.transformations
	var tg1:TransformGroup = new TransformGroup ();
	var tg2:TransformGroup = new TransformGroup ();
	// We also create two instances of Translation objects.
	// Give them an appropriate name, this becomes important very rapidly.
	var translation:Transform3D = new Transform3D ();
	var rotation:Transform3D = new Transform3D ();
	// we translate the object by 500 pixels on the Z axis.
	translation.translate (0, 0, -300);
	// We rotate the object by 30 degrees on an axis oriented from the origin to the point (1, 1, 1).
	rotation.rotAxis (new Vector (1, 1, 1), 30);
	// We apply those transformations to the nodes.
	tg1.setTransform (translation);
	tg2.setTransform (rotation);
	// We add the rotation transformation to the node which represents the rotation by setting it as a child.
	// The rotation will be applied first, translation later (higher in the tree)
	tg2.addChild (o);
	// Now we link the two nodes
	// The order here is very important.
	tg1.addChild (tg2);
	// Now we simply link the translation node to the root node, thus completing the tree creation
	bg.addChild (tg1);
}
 
// We lauch the animation creation.
init();

実際のswfは以下のような感じ。