Parsing OBJ and 3DS

Software: Away3D 4.x

Avatar
Eduardo, Newbie
Posted: 14 June 2012 10:59 PM   Total Posts: 6

Hi guys can anyone point me an example how to parse a local file?
I’m loading a file through FileReference then i extract the data.
What i’m experiencing is: it throws me an error when i try to load an obj file.
I understand that because it does not load the mtl file. How can i surpass this?
Thanks in advance.

   

Richard Olsson, Administrator
Posted: 16 June 2012 10:35 AM   Total Posts: 1192   [ # 1 ]

You can use AssetLoaderContext (second argument of load() and loadData() functions) to configure the loading framework not to include dependencies.

myLoader.loadData(myData, new AssetLoaderContext(false));

   

Avatar
Eduardo, Newbie
Posted: 17 June 2012 02:11 PM   Total Posts: 6   [ # 2 ]

Hi Richard!
But how can i listen when the load is complete?
It seems like my myLoader (Loader3D) cant listen the completion of the myData…

So i never place my model inside the scene.
By the way thank you for you’re work on this amazing engine!

   

Richard Olsson, Administrator
Posted: 17 June 2012 02:19 PM   Total Posts: 1192   [ # 3 ]

Listen for the LoaderEvent.RESOUCE_COMPLETE event which will be dispatched when the entire resource (including any dependencies if you haven’t disabled them) has finished loading.

   

Avatar
Eduardo, Newbie
Posted: 17 June 2012 02:26 PM   Total Posts: 6   [ # 4 ]

Hi Richard thank you for you’re quick reply.
But i did that an not working. If you can try it out by yourself.

So like i said i’m ripping the data as ByteArray from a FileReference file then i’m adding the ByteArray to this:

public function addObject (byteArray:ByteArray):void {
 
var _loader:Loader3D = new Loader3D();
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onModelLoaded);
_loader.addEventListener(LoaderEvent.LOAD_ERROR, function(e:LoaderEvent):void { trace(e.url + ” : ” + e.message ) } );
_loader.loadData(byteArray, new AssetLoaderContext(false));
 
}

——

but i cant get into the onModelLoaded…

private function onModelLoaded(e:LoaderEvent):void
{
  trace (“loaded”);

}

   

Richard Olsson, Administrator
Posted: 17 June 2012 02:31 PM   Total Posts: 1192   [ # 5 ]

What you have there should work, provided that the content of byteArray is a valid file of a type that Away3D recognizes and that you have enabled the relevant parsers. You should have Parsers.enableAllBundled() (or something equivalent) somewhere in your code before you trigger the load.

Have a look at the Basic_Load3DS.as example in the away3d-examples-fp11 repository on GitHub.

   

Avatar
Eduardo, Newbie
Posted: 17 June 2012 02:35 PM   Total Posts: 6   [ # 6 ]

Hi Richard thank you again raspberry
Well yes i have the static method enableAllBundled() called in the constructor of the class…

Well i will check the example and catch you later.
If i do that with a 3DS file it works out fine… but not with a OBJ file.
So maybe something weird is happening in the background or it is just me.

But if you have the time try it with an obj file.
Thank you!

   

Richard Olsson, Administrator
Posted: 17 June 2012 02:43 PM   Total Posts: 1192   [ # 7 ]

If you can’t get it to work, please file a bug and provide your files at http://github.com/away3d/away3d-core-fp11/issues . You will have to upload your files somewhere else and link to them in the bug report.

   

Avatar
Eduardo, Newbie
Posted: 17 June 2012 02:45 PM   Total Posts: 6   [ # 8 ]

Nice. I will see that and upload if i cant get it to work.
Thanks man. Continue the great job!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X