Ciao, ho scaricato un esempio che fa ruotare un cubo...
questi numeri quì sotto mi scrivono il cubo...
l'action script che lo fa muovere e lo scrive è diviso in 4 fotogrammi...
Io voglio ottenere un diamante cioè un cubo e una piramide poggiata su ogniuna delle basi...
Io ho provato a modificare i vertici (aggiungendone) ma non sono riuscito nel mio intento
qualcuno può aiutarmi a creare la figura o può spiegarmi questi punti a cosa corrispondono?
questo è l'action script che c'è nel primo fotogrammacodice:myTri = [-1,-1,-1, 1, 1,-1,-1, 1, -1, 1,-1, 1, 1, 1,-1, 1, -1,-1,-1, 1, -1, 1,-1, 1, 1,-1,-1, 1, 1, 1,-1, 1, -1,-1, 1, 1, 1,-1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1,-1, 1, 1, -1, 1, 1, 1, 1,-1, 1, 1, 1, 1, 1, 1, -1,-1, 1, 1, -1,-1,-1, 1, -1, 1, 1, 1, -1, 1,-1, 1, 1, 1, 1, 1, 1, 1,-1, 1, 1,-1, 1, 1, 1,-1,-1, 1];
questo c'è nel secondo...codice:/********************************************** * By vamosg(oo.com) */ _root.createEmptyMovieClip ("pen", 1); /********************************************** * MATRIX MULTIPLICATION */ function mult(A,B){ C = new Array(); for(i=0;i<B.length;i+=4){ C.push(B[i]*A[ 0]+B[i+1]*A[ 1]+B[i+2]*A[ 2]+B[i+3]*A[ 3]); C.push(B[i]*A[ 4]+B[i+1]*A[ 5]+B[i+2]*A[ 6]+B[i+3]*A[ 7]); C.push(B[i]*A[ 8]+B[i+1]*A[ 9]+B[i+2]*A[10]+B[i+3]*A[11]); C.push(B[i]*A[12]+B[i+1]*A[13]+B[i+2]*A[14]+B[i+3]*A[15]); } return C; } /********************************************** * PERSPECTIVE MATRIX */ function pers(f){ pers = new Array(); pers = [1,0,0 ,0, 0,1,0 ,0, 0,0,1 ,0, 0,0,1/f,1]; return pers; } /********************************************** * SCALE MATRIX */ function scale(x,y,z){ scale = [x,0,0,0, 0,y,0,0, 0,0,z,0, 0,0,0,1]; return scale; } /********************************************** * NORMALISE HOMOGENEOUSNESS */ function homdev(A){ B = new Array(); for(i=0;i<A.length;i+=4){ B.push(A[i+0]/A[i+3]); B.push(A[i+1]/A[i+3]); B.push(A[i+2]/A[i+3]); B.push(A[i+3]/A[i+3]); } return B; } /********************************************** * ROTATE IN X */ function rotx(x){ x = x*(Math.PI/180); c = Math.cos(x); s = Math.sin(x); rotx = [1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]; return rotx; } /********************************************** * ROTATE IN Z */ function rotz(z){ z = z*(Math.PI/180); c = Math.cos(z); s = Math.sin(z); rotz = [c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; return rotz; } /********************************************** * ROTATE IN Y */ function roty(y){ y = y*(Math.PI/180); c = Math.cos(y); s = Math.sin(y) roty = [c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]; return roty; } /********************************************** * TRANSLATE IN X,Y,Z */ function trans(x,y,z){ tmatr = [1,0,0,x, 0,1,0,y, 0,0,1,z, 0,0,0,1]; return tmatr; } /********************************************** * DRAW MODEL LINES */ function drawlines(model){ xoff = 200; yoff = 200; with (_root.pen) { for(i=0;i<model.length;i+=8){ lineStyle (1, 0x000000, 50); moveTo (model[i+0]+xoff, model[i+1]+yoff); lineTo (model[i+4]+xoff, model[i+5]+yoff); } } }
nel terzo fotogramma ci sono solo commenti mentre nel quarto c'ècodice:/********************************************** * By vamosg(oo.com) */ /********************************************** * DEFINE TRANSFORMATION MATRICES */ scale = scale(50,50,50); roty = roty(0); rotx = rotx(0); focal = 250; persm = pers(focal); moveX = 10; moveY = 0; moveZ = 0; /********************************************** * DEFINE POINTS */ myTri = [-1,-1,-1, 1, 1,-1,-1, 1, -1, 1,-1, 1, 1, 1,-1, 1, -1,-1,-1, 1, -1, 1,-1, 1, 1,-1,-1, 1, 1, 1,-1, 1, -1,-1, 1, 1, 1,-1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1,-1, 1, 1, -1, 1, 1, 1, 1,-1, 1, 1, 1, 1, 1, 1, -1,-1, 1, 1, -1,-1,-1, 1, -1, 1, 1, 1, -1, 1,-1, 1, 1, 1, 1, 1, 1, 1,-1, 1, 1,-1, 1, 1, 1,-1,-1, 1]; /********************************************** * SCALE OBJECT * SET UP AFFINE */ myTri = mult(scale,myTri); affine = mult(roty,rotx);
Vi prego, aiutatemi....codice:/********************************************** * By vamosg(oo.com) */ /********************************************** * MULTIPLY POINTS WITH AFFINE MATRIX */ myTri = mult(affine,myTri); /********************************************** * MULTIPLY DISPLAY POINTS WITH PERSPECTIVE * MATRIX AND NORMALISE */ if(Key.isDown(Key.RIGHT)) moveX+=50; if(Key.isDown(Key.LEFT)) moveX-=50; if(Key.isDown(Key.UP)) moveY+=50; if(Key.isDown(Key.DOWN)) moveY-=50; move = trans(moveX,moveY,moveZ); dis = mult(move,myTri); dis = mult(persm,dis); dis = homdev(dis); /********************************************** * CLEAR PREVIOUS LINES * DRAW NEW LINES */ pen.clear(); drawlines(dis); /********************************************** * NEXT FRAME */ gotoAndPlay(3);
dirvi grazie è riduttivo....
![]()
![]()

Rispondi quotando
