I m new in this forum. I m trying to create a box displaying six different pictures in each face.
I used the code below. But somehow it doesn't work.
My image size is 601*401
QUOTE
import flash.display.BitmapData;
import sandy.core.data.*;
import sandy.primitive.*;
import sandy.core.*;
import sandy.view.*;
import sandy.core.transform.*;
import sandy.core.group.*;
import sandy.skin.*;
import sandy.events.InterpolationEvent;
import sandy.util.Ease;
var rotint:RotationInterpolator;
var midX:Number = Stage.width/2;
var midY:Number = Stage.height/2;
var backCulling = true;
var isRolling = false;
var box:Object3D;
function start (Void):Void{
var w:World3D = World3D.getInstance ();
w.setRootGroup( createScene() );
w.addEventListener(World3D.onRenderEVENT,this,onRender);
var mc:MovieClip = _root.createEmptyMovieClip('screen',1);
//public function ClipScreen(mc:MovieClip, w:Number, h:Number, bgColor:Number)
var screen:ClipScreen = new ClipScreen(mc,401,401);
//public function Camera3D(nFoc:Number, s:IScreen)
var cam:Camera3D = new Camera3D(500,screen);
//public function setPosition(x:Number, y:Number, z:Number):Void
cam.setPosition(0,0,-350);
//public function addCamera(cam:Camera3D):Number
w.addCamera (cam);
//cullingButton.onRelease = switchBackCulling;
stopButton.onRelease = stop;
rotint.pause();
w.render();
//backCulling = box.enableBackFaceCulling = !backCulling;
//cullingButton.setLabel ( backCulling ? "Off" : "On" );
}
/*function switchBackCulling(){
backCulling = box.enableBackFaceCulling = !backCulling;
}
*/
rotint.resume();
function stop(){
if (isRolling){
rotint.pause();
stopButton.setLabel( "Start" );
}
else {
rotint.resume();
stopButton.setLabel( "Stop" );
}
isRolling = !isRolling;
}
//public function createScene(bg:Group):Void
//Method to overload in your application.
//In this method you have to create your scene graph and use the argument bg as the tree's root.
function createScene(Void):Group{
var g:Group = new Group();
//public function TextureSkin(t:BitmapData)
//t : The actionScriptLink of the bitmap;
var skin1:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side1"));
var skin2:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side2"));
var skin3:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side3"));
var skin4:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side4"));
var skin5:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side5"));
var skin6:TextureSkin = new TextureSkin(BitmapData.loadBitmap("side6"));
//skin.setLightingEnable(true);
box = new Box(80,80,80,"quad");
//box.setSkin( skin );
var faces = box.getFaces();
trace( faces.length );
faces[0].setSkin(skin1);faces[0].setBackSkin(skin);
faces[1].setSkin(skin2);
faces[2].setSkin(skin3);
faces[3].setSkin(skin4);
faces[4].setSkin(skin5);
faces[5].setSkin(skin6);
//faces[9].setSkin(skin); faces[9].setBackSkin(skin);
// Transforms
var ease:Ease = new Ease();
var tg:TransformGroup = new TransformGroup();
rotint = new RotationInterpolator( ease.create(),400 );
//public function setPointOfReference(v:Vector):Void
//Allows you to make your object rotate around a specific
//position and not anymore around its center. The value passed in
//argument represents an offset to the object position.
//It is NOT the real position of the rotation center.
//v Vector the offset to apply to change the rotation center.
rotint.setAxisOfRotation( new Vector( 2, 0 , 1));
rotint.addEventListener(InterpolationEvent.onEndEVENT, this, loop);
tg.setTransform(rotint);
tg.addChild(box);
g.addChild(tg);
return g;
}
// Interpolator event handler
function loop(e:InterpolationEvent):Void{
// we call the redo method of the Interpolator to continue
e.getTarget().redo();
}
function camMove():Void
{ var cam:Camera3D = World3D.getInstance ().getCamera ();
// Moving the camera in and out along its direction of view axis
if (Key.isDown (Key.UP)){cam.moveForward(5);}
if (Key.isDown (Key.DOWN)){cam.moveForward(-5);}
}
function changeRotation(e:InterpolationEvent):Void
{ rotint.setAxisOfRotation(new Vector(_ymouse-midY,midX-_xmouse,0));
}
function onRender():Void
{
changeRotation();
camMove();
}
// Get started
start ();
Thanks in Advance