I am not sure where you have gone wrong.
I can show you what I did. It is a bit more structured than the Sandy
examples
It declares a World3D and a movie clip and then builds a scene that can
be rotated.
Then it creates and adds a camera
This is the main flow. It sets up a Movie Clip to draw the world on and
then calls init which sets up the world, positions the camera and starts
the rendering.
The transforms and rotation objects are part of constructing the scene
and you can ignore then.
CODE
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.*;
// not needed for your stuff
import com.rwcontrols.utils3D.RWRotation
import flashout.as;
import flash.display.BitmapData;
/**
* This is the main entry point for all test classes.
*/
class com.rwcontrols.sandytest.TestMain {
static var app : TestMain;
private var w:World3D;
private var mySection:TransformGroup;
private var masterRotation:RWRotation;
private var rotationTransform:Transform3D;
private var myRotatingSection:TransformGroup;
private var myScene:Group;
private var myCamera1:Camera3D;
// entry point
static function main(mc) {
app = new TestMain(mc);
}
function TestMain(mc) {
var myMC : MovieClip;
try { init(mc); }
catch (e:Error)
{trace(e.message);}
}
private function init(screen: MovieClip):Void
{
var i:Number;
this.w = World3D.getInstance();
//This draws a section of a plant
this.mySection = this.createSection() ;
// You can simplify this - I wanted to rotate the plant
this.masterRotation = new RWRotation(0,45,0);
this.rotationTransform =
this.masterRotation.createRotationTransform();
this.myRotatingSection =
this.createRotatableSection(this.mySection,this.rotationTransform);
//This creates the final scene to be viewed.
this.myScene = createScene(this.myRotatingSection)
this.w.setRootGroup(this.myScene );
//Now add a camra to look at the movie clip
this.myCamera1=createCamera1(screen)
this.w.addCamera(this.myCamera1);
//This makes it rotate
this.w.addEventListener (World3D.onRenderEVENT, this, rotate);
// Ready to draw it
this.w.render();
}
/CODE
Creating the camera is pretty simple and you can use this as is. Just
change your camera position. The look at just points the camera down
since I have raised the camera above the scene but still want the scene
to be in the middle of the frame. I just pass it the Movie clip that the
scene is on
CODE
private function createCamera1(screen:MovieClip):Camera3D{
var ecran:ClipScreen = new ClipScreen(screen, 1000, 1000, 0xFF );
// we create our camera
var cam:Camera3D = new Camera3D( 700, ecran);
cam.setPosition(0,200,-600);
cam.lookAt( 0, -20, -200 );
return cam;
}
/CODE
Creating the scene in my case is a multi-step process since I wanted a
rotating group on the scene.
The last step just adds the final group of objects(rotatable Site) to
the group that will be given to the world.
CODE
private function createScene( rotatableSite:TransformGroup ):Group
{
// we create the root node.
var bg:Group = new Group();
bg.addChild(rotatableSite);
return bg;
}
/CODE
Just in case you wanted to see the creation of a rotatable Group. I need
this to be able to rotate the thing on every onEnterFrame.
CODE
private function
createRotatableSection(site:TransformGroup,rotationTransform:Transform3D):TransformGroup
{
var tRot:TransformGroup = new TransformGroup();
// The rotation is set in the transform group which will hold
our site
tRot.setTransform( rotationTransform );
trace(Flashout.DEBUG+tRot)
// Our site is added to the rotation group
tRot.addChild( site );
return tRot;
}
/CODE
You do not need this but this is how I make it spin.
CODE
function rotate(){
this.masterRotation.incrementRotation(this.rotationTransform,0,1,0)
}
/CODE
My scene is fairly complex. This is only bits and pieces of it since you
already have your own scene to do
CODE
private function createSection( Void ):TransformGroup{
// Set up some skins and lights
var cyl1skin= new MixedSkin(0xFF, 40, 0xFF, 40, 1)
var cyl2skin= new MixedSkin(0x00FF00, 40, 0x00FF00, 40, 1)
var cyl3skin= new MixedSkin(0xFF, 40, 0xFF, 40, 1)
cyl1skin.setLightingEnable( true );
cyl2skin.setLightingEnable( true );
cyl3skin.setLightingEnable( true );
//Create some objects
var cyl1 = new Cylinder( 20, 70, 60, 'quad');
// code omitted here
var section:TransformGroup = new TransformGroup();
//add some of the groups created in the missing code
section.addChild(bin1);
section.addChild(bin1LabelTG);
section.addChild(bin2);