Cannnot load mtl file’s color

Software: Away3D 4.x

polig, Newbie
Posted: 08 October 2012 07:05 AM   Total Posts: 18

Hello Developer team.

I loaded obj file (and mtl file) by using AssetLibrary and added to scene.
the source code is like following ( executed loadObjFile function )

private function loadObjFile():void {
 Loader3D
.enableParserOBJParser );
 
AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETEeComplete);
 
AssetLibrary.load( new URLRequest("test.obj")); //test.obj and test.mtl
}

private function eComplete(e:AssetEvent):void {
 
if (e.asset is Mesh{
  
var myObj ObjectContainer3D Mesh(e.asset);
  
scene.addChildmyObj );
 
}

The figure of Mesh was shown. but all the colors of the mesh was same.
mtl file contains 5 colors info.

Could you tell me what is my fault.

 

   

Avatar
Alex-Crafter, Newbie
Posted: 08 October 2012 07:44 AM   Total Posts: 28   [ # 1 ]

Haven’t fiddled with imported material data yet.. but you should check 2 things while exporting:
-are you exporting material and textures with your model? In 3d studio max, obj exporter panel gives an option to export only geometry or geometry+materials.
-are you using a multi-channel material? If you are using this kind of material, maybe the away3d obj parser takes it as a color material..

Hope this helps..

   

polig, Newbie
Posted: 08 October 2012 08:07 AM   Total Posts: 18   [ # 2 ]

Thanks for fast reply, Alex.

Sorry, my 3D modeling tool is domestic (japan). And I don’t know a lot about the obj file. But the model is so simple. Just only one cube three color materials.

following is the inside of the files.

test.obj

mtllib test.mtl

v 100.000000 100.000000 100.000000
v 100.000000 
-100.000000 100.000000
-100.000000 100.000000 100.000000
-100.000000 -100.000000 100.000000
-100.000000 100.000000 -100.000000
-100.000000 -100.000000 -100.000000
v 100.000000 100.000000 
-100.000000
v 100.000000 
-100.000000 -100.000000
# 8 vertices

vt 0.00000 1.00000
vt 1.00000 1.00000
vt 1.00000 0.00000
vt 0.00000 0.00000
# 4 texture vertices

usemtl mat3
f 1
/1 3/2 4/3 2/4
usemtl mat1
f 3
/1 5/2 6/3 4/4
usemtl mat3
f 5
/1 7/2 8/3 6/4
usemtl mat1
f 7
/1 1/2 2/3 8/4
usemtl mat2
f 7
/1 5/2 3/3 1/4
f 2
/1 4/2 6/3 8/4
# 6 elements 

test.mtl

newmtl mat1
Ka 0.60000 0.00000 0.00706
Kd 0.80000 0.00000 0.00941
Ks 0.00000 0.00000 0.00000
Ns 5.00000

newmtl mat2
Ka 0.00000 0.60000 0.02353
Kd 0.00000 0.80000 0.03137
Ks 0.00000 0.00000 0.00000
Ns 5.00000

newmtl mat3
Ka 0.00000 0.01647 0.60000
Kd 0.00000 0.02196 0.80000
Ks 0.00000 0.00000 0.00000
Ns 5.00000 

I noticed one thing. the Mesh is painted all by first material color.
Could you give me any other hints…

 

   

Avatar
Alex-Crafter, Newbie
Posted: 08 October 2012 08:31 AM   Total Posts: 28   [ # 3 ]

since you are using a custom 3d tool, how about doing this?
create a texture with all your colors:
like a jpeg 2x2pixels- you can have 4 colors, 1 in each pixel.
Then you must create a material with that texture, and manipulate the uv faces, so that each face stays inside the desired pixel color in the texture.
exporting that object along with the material will probably result in a standard textureMaterial, instead of a multi-material one.

   

polig, Newbie
Posted: 08 October 2012 09:03 AM   Total Posts: 18   [ # 4 ]

Sorry, It might be not good my explanations.

Yes, I can display a model with only one texture.(create one texture file and draw picture of sevral parts of material in it , adjust UV position) However, the test.obj that I posted before was just only for loading test.

What I really want to do is to load 3D models those I bought in web shop, or downloaded from Internet and so on. If possible, I don’t want to adjust the modeling and texture data, want to use as it is.

   

Avatar
80prozent, Sr. Member
Posted: 08 October 2012 01:22 PM   Total Posts: 430   [ # 5 ]

hi

buying/download 3d-objects and use them as they are, will only work good for 3d-objects, that where build for this purpose (for realtime-rendering).

if you want to make shure your swf dont waste performance, i highly recomment to check your 3d-objects in a 3d-application (optimize pointcount etc), and convert it to a binary format (best is awd2 for minimum filesize).

to convert your models to awd2 you can use prefab.

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Fabrice Closier, Administrator
Posted: 08 October 2012 02:30 PM   Total Posts: 1265   [ # 6 ]

The above obj will display only first color(or last one, don’t remember for sure), as the parser doesn’t support multiple materials per mesh.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X