Textures not loading with OBJ

Software: Away3D 4.x

Tom.de, Newbie
Posted: 04 April 2012 02:21 PM   Total Posts: 30

Hey everyone.

I just started working with away3D a few days ago, so this might be a very simple question.

I am currently trying to load a model via the Loader3D functionality.
The model loads fine, however, the texture / material does not.
This is how I load the model.

Parsers.enableAllBundled();
m_Loader3D = new Loader3D();
m_Loader3D.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete);
m_Loader3D.addEventListener(LoaderEvent.LOAD_ERRORonLoadError);
m_Loader3D.load( new URLRequest('../../GameApp/assets/models/icecube/ice_cube.obj') ); 

Gathering from the examples this should automatically load the texture as well? I have to manually apply a ColorMaterial in order to see the model.

I tried loading a texture and apply it to the mesh, unfortunately to no avail.

[Embed(source="/../../JeligniteApp/assets/models/icecube/ice04.png")]
private var Ice04:Class; 

and in onResourceComplete (the following approach works if I apply a ColorMaterial, not when using a BitmapMaterial)

var IceCubeBitmap Bitmap = new Ice04();
var 
IceCubeMaterial BitmapMaterial = new BitmapMaterialIceCubeBitmap.bitmapData );
var 
nc Number m_Loader3D.numChildren;
for (var 
Number 0nci++)
{
 
var Mesh Mesh Mesh(m_Loader3D.getChildAt(i));
 
Mesh.material IceCubeMaterial;

What could I be doing wrong?
Thanks in advance for your support!

   

Tom.de, Newbie
Posted: 04 April 2012 02:30 PM   Total Posts: 30   [ # 1 ]

Very sorry, my browser died on me, hence the triple post.

   

Donny, Jr. Member
Posted: 04 April 2012 11:22 PM   Total Posts: 34   [ # 2 ]

Was a MTL file exported as well? At the top of the OBJ file, there should be a reference to a MTL file. Ensure the reference in there, and the image references in the MTL file are relative to the SWF export.

   

Avatar
Fabrice Closier, Administrator
Posted: 05 April 2012 08:20 AM   Total Posts: 1265   [ # 3 ]

First of all, you should update your away version and use TextureMaterial.

If the mtl is indeed set in the obj file, you can become a lot more wizer if you trace the error message that you get in the error handler.
It will probably give you back the url(s) that is/are failing.

   

Tom.de, Newbie
Posted: 13 April 2012 08:11 AM   Total Posts: 30   [ # 4 ]

Hey,

thanks for your answers.
Unfortunately I can not update to the latest version at this point in time.
The reason being that I work only on a small part of a platform which is heavily reliant on the current version.
Until the team actually updates the platform it I have to run with the current version.

Herein most likely also lies my texture problem. It seems that some of the renderer functionality has been changed which broke the texture rendering.
So knowing that, I should be up and running rendering textures soon. smile


Another question though:

I was trying to use the Loader3D parseData functionality (which is loadData once I’ve updated?) to load an obj file. Unfortunately I do not get any events back! Nada.

This is how I use it:

// model
[Embed(source "/../../JeligniteApp/assets/models/icecube/ice_cube.obj"mimeType "application/octet-stream")]
private var IceCubeModel:Class; 
Loader3D.enableParser(OBJParser);
m_Loader3D = new Loader3D(false);
m_Loader3D.addEventListener(AssetEvent.ASSET_COMPLETEonAssetRetrieved); 
m_Loader3D.addEventListener(LoaderEvent.RESOURCE_COMPLETEonResourceComplete); 
m_Loader3D.addEventListener(LoaderEvent.LOAD_ERRORonLoadError);
m_Loader3D.parseData(new IceCubeModel(), null, new AssetLoaderContext(false));
m_Loader3D.position = new Vector3D();
m_ObjectContainer.addChild(m_Loader3D); 

If I just do parseData without [null, new AssetLoaderContext(false)] I do get the onLoadError event. However, in the above example absolutely nothing happens.

I also tried the AssetLoader(), also, no events are fired.

I’m a bit at a loss here, especially as it seems I have to go down the embedded route.

cheers

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X