package { /** * marching cubes demo * @author nicoptere * http://en.nicoptere.net/ */ import flash.display.Sprite; import flash.events.Event; import net.nicoptere.marchingcubes.Dataset; import net.nicoptere.marchingcubes.MarchingCubes; public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); var modelScale:Number ; var data:Dataset = new Dataset(); //generates a random shape based on metaballs data.randomShape( 20,20,20 ); modelScale = 12; //various shapes //sets up a sphere that fits in a box //data.generateSphere( 30,30,30 ); //modelScale = 6; //changes the isolevel to make it smaller //data.isoLevel = 740; //changes the isolevel to make it bigger //data.isoLevel = 370 //generates a noise //data.noise( 8,8,8 ); //modelScale = 24; //creates the marching cube to process the data set var mc:MarchingCubes = new MarchingCubes( data ); //creates a 3D wrapper to render the marching cubes var pv:PaperObject = new PaperObject( mc, modelScale, false ); //default rotation pv.group.rotationX = 45; pv.group.rotationY = -35; pv.group.rotationZ = 0; //show hide boundingbox pv.boundingBox = false //doublesided material pv.doubleSided = true; addChild( pv ); pv.build(); //alternative building Method (static) //PaperObject.build(); } } }