Help: OBJ wont load texture from .mtl

Software: Away3D 4.x

Gordon, Newbie
Posted: 13 March 2012 01:45 PM   Total Posts: 17

Dear Guys,

after trying out different approaches of loading models proper into AWAY, it seems that nothing works out for us. We are now facing the problem of loading the materials from the .mtl file into away.

when we export the model as obj with the mtl and load it in the example-OBJ-Loader, we are won’t see anything in the viewport.

When we export the model without generating an .mtl we will see the attached picture.

The .mtl looks like this:

# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 13.03.2012 14:39:20

newmtl wire_028028177
Ns 32
d 1
Tr 0
Tf 1 1 1
illum 2
Ka 0.1098 0.1098 0.6941
Kd 0.1098 0.1098 0.6941
Ks 0.3500 0.3500 0.3500


What are we doing wrong? It can’t be that, hard to laod an proper OBJ. Thanks for any help!

 

 

 

   

Avatar
Fabrice Closier, Administrator
Posted: 13 March 2012 02:44 PM   Total Posts: 1265   [ # 1 ]

Can you tell more about your obj file itself?
See, Away will place a texturematerial default when it encounters a tag that says useMtl, and then tries to load the url found into the mtl.

Your mtl has no reference to maps at all. There is only one single default colormaterial, not perse defined in the obj file.

make sure that the tag—> mtllib, usually second or third line of the obj file
hold the right url. it MUST be relative to teh obj file. Thats why they commonly come as 2 files in same directory.

now, in your file, search for the keyword “usemtl”
It usually is located after the vt tags, right before the f tags sequence.
the value of the tag “materialname”, is the id of one material defined into the mtl. in your example mtl, it should say “newmtl wire_028028177”


now if it was correctly exported, the shortest mtl definition should look like this for a basic diffuse map.
newmtl wire_028028177
map_Kd myCoolImage.jpg

note again, that the url “myCoolImage.jpg” is relative to mtl file
in flash it becomes url_to_obj[minus obj filename]+url_found_into_mtl

Also, make sure you have set an error listener to your loader. Read the error message if any.

 

 

   

Gordon, Newbie
Posted: 15 March 2012 08:05 PM   Total Posts: 17   [ # 2 ]

Hi Fabrice,

i don’t know what i did wrong, but it works now without any problems.

Maybe i was confused, cause there isn’t any lightsource in this OBJ-Loader-Demo…

Anyway, thanks a lot!


I

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X