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.enableParser( OBJParser ); AssetLibrary.addEventListener(AssetEvent.ASSET_COMPLETE, eComplete); 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.addChild( myObj ); } }
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.
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 v -100.000000 100.000000 100.000000 v -100.000000 -100.000000 100.000000 v -100.000000 100.000000 -100.000000 v -100.000000 -100.000000 -100.000000 v 100.000000 100.000000 -100.000000 v 100.000000 -100.000000 -100.000000 # 8 vertices
I noticed one thing. the Mesh is painted all by first material color.
Could you give me any other hints…
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.
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.
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.