In this tutorial, I'll present to you a way to create your first Sandy 3D application, in 3 lines of code.
Here they are:
import sandy.core.Scene3D; import sandy.core.scenegraph.*; import sandy.primitive.*; // -- creation of the scene. You give it a container, a camera and a root group to add your object into. var scene:Scene3D = new Scene3D( "myScene", this, new Camera3D( 550, 400 ), new Group("root") ); // -- you add an object to the scene you've just created scene.root.addChild(new Sphere( "mySphere" ) ); // -- and you ask the scene to render scene.render();
Ok, there's 6 lines, but 3 of them are for imports statements, which is not related to Sandy really.
If you have correctly installed Sandy in your Flash CS3 environement, you should see this wireframe sphere :
wow you did it! Your first 3D object in Flash with Sandy.
Now you may wonder how to apply a texture on that sphere.
Before compiling this example, import a bitmap into your Flash file's library. Enable the bitmap's “Export for ActionScript” checkbox and set its Linkage Class name to “Texture”.
import sandy.core.Scene3D; import sandy.core.scenegraph.*; import sandy.primitive.*; import sandy.materials.*; // -- creation of the scene. You give it a container, a camera and a root group to add your object into. var scene:Scene3D = new Scene3D( "myScene", this, new Camera3D( 550, 400 ), new Group("root") ); var sphere:Sphere = new Sphere("mySphere"); // "Texture" must match the name of the Linkage Class set for a bitmap in the FLA file's library sphere.appearance = new Appearance( new BitmapMaterial( new Texture(0,0) ) ); // -- you add an object to the scene you've just created scene.root.addChild( sphere ); // -- and you ask the scene to render scene.render();
Here is the result you should see when you test the movie:
Now, it is time to move on something more interesting with more explanations.
Have fun!