setDimension(400, 400); $movie->setBackground(255, 255, 255); $w = 400; $h = 400; include("../functions/mytrace.php"); $s = drawSquare(0, 0, 10, 10, .1, 0, 0, 0); $a = new SWFSprite(); $a -> add($s); $a -> nextframe(); $movie->addExport($a, 'redballoon'); $movie->add(new SWFAction( " _root.createEmptyMovieClip('theScene', 1); theScene._x = 150; theScene._y = 200; focalLength = 300; // creates a 3d point make3DPoint = function(x,y,z){ var point = new Object(); point.x = x; point.y = y; point.z = z; return point; }; make2DPoint = function(x, y){ var point = new Object(); point.x = x; point.y = y; return point; }; Transform3DPointsTo2DPoints = function(points, axisRotations){ var TransformedPointsArray = []; var sx = Math.sin(axisRotations.x); var cx = Math.cos(axisRotations.x); var sy = Math.sin(axisRotations.y); var cy = Math.cos(axisRotations.y); var sz = Math.sin(axisRotations.z); var cz = Math.cos(axisRotations.z); var x,y,z, xy,xz, yx,yz, zx,zy, scaleFactor; var i = points.length; while (i--){ x = points[i].x; y = points[i].y; z = points[i].z; // rotation around x xy = cx*y - sx*z; xz = sx*y + cx*z; // rotation around y yz = cy*xz - sy*x; yx = sy*xz + cy*x; // rotation around z zx = cz*yx - sz*xy; zy = sz*yx + cz*xy; scaleFactor = focalLength/(focalLength + yz); x = zx*scaleFactor; y = zy*scaleFactor; z = yz; TransformedPointsArray[i] = make2DPoint(x, y, -z, scaleFactor); } return TransformedPointsArray; }; function makePointsArray(i){ pointsArray = [ make3DPoint(-i*2,-i,-i), make3DPoint(i*2,-i,-i), make3DPoint(i*2,-i,i), make3DPoint(-i*2,-i,i), make3DPoint(-i*2,i,-i), make3DPoint(i*2,i,-i), make3DPoint(i*2,i,i), make3DPoint(-i*2,i,i) ]; return pointsArray; }; function makePointsArray_2(i){ pointsArray = [ make3DPoint(-i,-i*2,-i), make3DPoint(i,-i*2,-i), make3DPoint(i,-i*2,i), make3DPoint(-i,-i*2,i), make3DPoint(-i,i*2,-i), make3DPoint(i,i*2,-i), make3DPoint(i,i*2,i), make3DPoint(-i,i*2,i) ]; return pointsArray; }; _root.cube_count = 100; _root.cube_start = 10; _root.cube_inc = 35; count = 0; for(i=_root.cube_start; i<(_root.cube_count+_root.cube_start); i+=_root.cube_inc){ _root['pointsArray_'+i] = makePointsArray_2(i); i++; _root['pointsArray_'+i] = makePointsArray(i); } cubeAxisRotations = make3DPoint(0,0,0); rotateCube = function(){ cubeAxisRotations.y -= this._xmouse/2000; cubeAxisRotations.x += this._ymouse/2000; for(i=_root.cube_start; i<(_root.cube_count - _root.cube_start); i+=_root.cube_inc){ this['screenPoints_'+i] = Transform3DPointsTo2DPoints(_root['pointsArray_'+i], cubeAxisRotations); i++; this['screenPoints_'+i] = Transform3DPointsTo2DPoints(_root['pointsArray_'+i], cubeAxisRotations); } this.clear(); this.lineStyle(2, 0x000000, 75); for(i=_root.cube_start; i<(_root.cube_count - _root.cube_start); i+=_root.cube_inc){ draw3d_2(this['screenPoints_'+i], this); i++; draw3d_2(this['screenPoints_'+i], this); } }; function draw3d_2(screenPoints, this){ // top this.moveTo(screenPoints[0].x, screenPoints[0].y); this.lineTo(screenPoints[1].x, screenPoints[1].y); this.lineTo(screenPoints[2].x, screenPoints[2].y); this.lineTo(screenPoints[3].x, screenPoints[3].y); this.lineTo(screenPoints[0].x, screenPoints[0].y); // bottom this.moveTo(screenPoints[4].x, screenPoints[4].y); this.lineTo(screenPoints[5].x, screenPoints[5].y); this.lineTo(screenPoints[6].x, screenPoints[6].y); this.lineTo(screenPoints[7].x, screenPoints[7].y); this.lineTo(screenPoints[4].x, screenPoints[4].y); // connecting bottom and top this.moveTo(screenPoints[0].x, screenPoints[0].y); this.lineTo(screenPoints[4].x, screenPoints[4].y); this.moveTo(screenPoints[1].x, screenPoints[1].y); this.lineTo(screenPoints[5].x, screenPoints[5].y); this.moveTo(screenPoints[2].x, screenPoints[2].y); this.lineTo(screenPoints[6].x, screenPoints[6].y); this.moveTo(screenPoints[3].x, screenPoints[3].y); this.lineTo(screenPoints[7].x, screenPoints[7].y); }; theScene.onEnterFrame = rotateCube; ")); $movie->save("3d_10.swf", 9); echo "
ahhhhhhhhh"; ?>