For some reason, when I copy and paste this code into flash, it is
giving me an error on the last function "onLoaderSuccess"
Are these the correct lines of code to put in the obj name:
_objLoader = Obj.load(_objURL, {material:_materialObject3D,
name:"OBJ", scaling:10}); //adjust the scaling as needed
name:"OBJ" is where I'm adding the name of my lightwave file that I
have exported as an .obj
and for my material:
_materialLoader.load(new URLRequest(_materialURL));
Thanks!
Larry
2009/12/30 Paweł Stanisławczuk <[email protected]>:
> Hi!
>
> Someone can call this method "old school" but it works for me
>
> First I load material, then obj. Import required classes. It's a copy
> paste of 2 different classes, but it should work.
>
> private var _materialLoader:Loader;
> private var _materialObject3D:BitmapMaterial;
> private var _objLoader:Object3DLoader;
> private var _mesh:Mesh;
>
> public function loadMaterial():void {
> _materialLoader = new Loader();
> _materialLoader.contentLoaderInfo.addEventListener(Event.INIT,
> onComplete);
> _materialLoader.contentLoaderInfo.addEventListener
> (IOErrorEvent.IO_ERROR, onMaterialLoaderError);//create this function
> _materialLoader.load(new URLRequest(_materialURL));
> }
>
> private function onComplete(event:Event):void {
>
> _materialLoader.contentLoaderInfo.removeEventListener(Event.INIT,
> onComplete);
> _materialLoader.contentLoaderInfo.removeEventListener
> (IOErrorEvent.IO_ERROR, onMaterialLoaderError);
>
> var bitmap:Bitmap = materialLoader.content as Bitmap;
> bitmap.smoothing = true;
>
> _materialObject3D = new BitmapMaterial(bitmap.bitmapData);
> _materialObject3D.smooth = true;
>
> loadOBJ();
>
> }
>
> private function loadOBJ():void {
> _objLoader = Obj.load(_objURL, {material:_materialObject3D,
> name:"OBJ", scaling:10}); //adjust the scaling as needed
> _objLoader.addOnSuccess(onLoaderSuccess);
> _objLoader.addOnError(onLoaderError); //create this function
> }
>
> private function onLoaderSuccess(event:LoaderEvent):void {
> var obj:ObjectContainer3D = (event.target.handle as
> ObjectContainer3D);
> _mesh = obj.children[0] as Mesh; // I need this trick, I export OBJ
> using LightWave
>
> scene.addChild(_mesh);
> }
>
> Good Luck!
> Paweł
>
>
> On Dec 30, 7:07 pm, Wave3d <[email protected]> wrote:
>> I am a rookie at using away3d, but I like the ability to have a 3d
>> engine using flash. I have tried to load in .obj files, and have
>> looked online for tutorials, yet I haven't found one that will work
>> yet. Do you have any information on the basic code for loading a .obj
>> file into flash using away3d, I'm looking for the bare bones code just
>> so I can understand what elements of code have to be in the
>> actionscript to load the model.
>