package geometry.curves { import away3d.entities.Mesh; import away3d.events.LoaderEvent; import away3d.loaders.Loader3D; import away3d.loaders.misc.AssetLoaderContext; import away3d.loaders.parsers.OBJParser; import triga.render.ViewHelper; import triga.spline.curves.Cubic; import triga.utils.Subdivision; /** * @author Nicolas Barradeau * http://en.nicoptere.net */ public class C_subdivisions extends BaseScene { [Embed(source="../../../lib/res/models/windmill/windmill.obj", mimeType="application/octet-stream")] private var OBJ:Class; private var _loader:Loader3D; public function C_subdivisions():void { addChild( GlobalTextField.instance ); GlobalTextField.instance.htmlText = '
the windmill model & texture is a courtesy of Raphaƫl Kuntz\na talented 3D artist, his website is here: http://visu.kuntz.tv/
' ; var size:uint = 256, color:uint = 0xFF000000, backgroundColor:uint = 0xFFFFFFFF; setup(); ViewHelper.grainyBackground( view, 1024, false, 0, 16 ); ViewHelper.vignette( view, 1024, false, 0, 1, 216 ); loadObj(); } private function loadObj():void { Loader3D.enableParser(OBJParser); _loader = new Loader3D(); _loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete); _loader.loadData( OBJ, new AssetLoaderContext(false), null ); addChild( GlobalTextField.instance ); } private function onResourceComplete(e:LoaderEvent):void { var subdiv:Mesh = Subdivision.compute( Mesh(_loader.getChildAt(0)), new Cubic(.1,true),.5,true ); subdiv.material = WHITE; WHITE.alpha = .5; addMesh( subdiv ); } } }