Io non sto seguendo la guida passo per passo, ma mi studio solo quello che mi puo essere utile man mano che proseguo con il mio progetto.
Per questo motivo sono passato dalla pagina 17 alla pagina 43.
Ruotare gli oggetti con il mouse.
L'unico difetto che ho trovato in questa pagina è in questa sezione:
codice:
function rotate() {
if ( mousedown ) {
x += ( _ymouse - mouseY )/10;
y += ( mouseX -_xmouse )/10;
rotation.rot( x, y, z );
tg1.setTransform(rotation);
}
}
Non so a voi, ma a me con il mio flash CS3... non funziona in questa maniera, infatti se aggiungo alla funzione rotate un trace di x e un trace di y ottengo che x e y non hanno mai valori; la soluzione è semplice... togliere il segno +; quindi il codice corretto è il seguente:
codice:
function rotate() {
if ( mousedown ) {
x = ( _ymouse - mouseY )/10;
y = ( mouseX -_xmouse )/10;
rotation.rot( x, y, z );
tg1.setTransform(rotation);
}
}
Allego anche tutto il codice da scrivere per fare la rotazione di un singolo cubo.
codice:
import sandy.core.light.*;
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.*;
var world:World3D = World3D.getInstance(); // Azione principale del mondo 3D
var rotation:Transform3D = new Transform3D();
var l:Light3D = new Light3D (new Vector (100, 0, 0), 500); //PER APPLCIARE LE LUCI
World3D.getInstance ().setLight (l); //PER APPLCIARE LE LUCI
var mouse:Object = new Object();
Mouse.addListener(this);
onMouseDown = function() {
mousedown = true;
mouseX = _xmouse;
mouseY = _ymouse;
};
onMouseUp = function() {
mousedown = false;
mouseX = _xmouse;
mouseY = _ymouse;
};
function createScene( bg:Group ):Void {
var cube:Object3D = new Box( 50, 50, 50, 'quad' );
var skin:Skin = new MixedSkin( 0xF28F35, 80, 0, 10, 1 );
skin.setLightingEnable( true ); // Abilitiamo l'illuminazione per la skin
cube.setSkin( skin );
var tg:TransformGroup = new TransformGroup();
rotation.rot(20,30,0);
tg.setTransform( rotation );
tg.addChild( cube );
bg.addChild( tg );
}
function rotate() {
if ( mousedown ) {
x =- ( _ymouse - mouseY )/10;
y = ( mouseX -_xmouse )/10;
trace (x);
trace(y);
rotation.rot( x, y, 0 );
tg.setTransform(rotation);
}
}
function init( Void ):Void {
screen = new ClipScreen( this.createEmptyMovieClip('screen', 1), 200, 200 );
var cam:Camera3D = new Camera3D( 600, 600 );
cam.setPosition(0,0,-500);
world.addCamera( cam );
var bg:Group = new Group();
world.setRootGroup( bg );
createScene( bg );
world.addEventListener(World3D.onRenderEVENT,this,rotate);
world.render();
}
init();
Questo funziona 
Spero sempre di esservi stato utile.