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, 0xFF0000 );
// 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(0xFF0000, 40, 0xFF0000, 40, 1)
var cyl2skin= new MixedSkin(0x00FF00, 40, 0x00FF00, 40, 1)
var cyl3skin= new MixedSkin(0x0000FF, 40, 0x0000FF, 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);
section.addChild(bin3);
section.addChild(bin4);
section.addChild(bin5);
section.addChild(bin6);
// put some ground under the bins
var xyPlane:Object3D = new Plane3D(400,400,10,'quad');
xyPlane.setSkin( new MixedSkin(0xdd8800, 20, 0, 0, 1 ));
section.addChild( xyPlane);
return section;
}
</CODE>
I hope that this helps.
Ron
Gustavo Duenas wrote:
Hi, I've just run the sandy on my flash 8 and this was the error of
the first code.
**Error** /Applications/Macromedia Flash
8/sources/sandy/view/ClipScreen.as: Line 102: There is no method with
the name 'updateScreen'.
_c.updateScreen();
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 16: Type mismatch.
var cam:Camera3D = new Camera3D( 700, screen);
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: There is no
method with the name 'addCamera'.
World3D.getInstance().addCamera( cam );
Total ActionScript Errors: 3 Reported Errors: 3
the code is:
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
{
// screen creation, the object where objects will be displayed.
var screen:ClipScreen = new ClipScreen(
this.createEmptyMovieClip('screen', 1), 600, 600 );
// we create our camera
var cam:Camera3D = new Camera3D( 700, screen);
// we move the camera backward to be able to see the object placed
at 0,0,0
cam.setPosition(0, 0, -500);
// we add the camera to the world
World3D.getInstance().addCamera( cam );
// 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 that 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
var o:Object3D = new Box( 50, 50, 50 );
// Now we simply link the Object leaf to the root node, and finish
the tree creation
bg.addChild( o);
}
// We lauch the animation creation.
init();
and this is the class path
Macintosh HD:Applications:Macromedia Flash 8:sources
somebody help me...it is supposed to be as hards as this....or I've
just missed something in the download.
regards
Gustavo Duenas
P.s: the code was on the tutorial of sandy
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com