Dynamically loading an object and texture.

Software: Away3D 4.x

Yashin, Newbie
Posted: 12 December 2012 04:03 PM   Total Posts: 11

Hi experts,
I am working on a project where I dynamically need to load 3d models ( without animation). Let us say I have a menu where i can choose the model to load at any time i want. For this project,
- i want to know what is the best format to export my models from 3d applications? I’ve done some tests in 3DS and OBJ so far.
- Using OBJ, if this is a proper format, how do i set the information for the textures and colors etc. I know that a mtl file is generated which contains the information, but when i run my project, I can’t see the textures or colors.
I’ve tried to apply a texture ( simple image) via AS3 to the loaded object, it works, but my objects will be quite complex and are built using several textures in the 3d application.
- How do i export a single texture from 3Ds MAX for my whole object? I’ve seen examples of images with all information in a single image.

Thank you for your support.

   

Rasterizer, Member
Posted: 12 December 2012 04:25 PM   Total Posts: 69   [ # 1 ]

1, use AWD. While there’s nothing wrong with OBJ or 3DS, the AWD bears all the necessary info and is able to load all dependencies (textures) on its own.

To get AWD from your stuff, use Prefab3D.

2, I have bad experiences with OBJ mtl export, I wouldn’t recommend considering that. In fact, its definitions might not be directly compatible with Away3D anyway.

3, to get a single texture and taking into account several objects and mats, you’d be best off with a texture atlas. Use TexturePacker (absolutely indispensable tool) to efficiently squeeze them into one big file. However you’d have to code its implementation, as Away3D won’t do that for you. Its not difficult at all, but you have to remember to offset+scale UVs to make it work. This will also allow you to make several versions of your textures with different levels of detail for limited platforms, which is just awesome.

   

Yashin, Newbie
Posted: 12 December 2012 04:48 PM   Total Posts: 11   [ # 2 ]

Thank you for all these information, I’ll definetely consider AWD.

However, do you know how to load the different texture information with an OBJ format? I mean, without applying any uv texture mapping via AS3, but by considering the different texture information for each sub-object in the mtl file. Is this possible?

   

Rasterizer, Member
Posted: 12 December 2012 04:56 PM   Total Posts: 69   [ # 3 ]

I’m not entirely sure about the meaning of your question, but I have this tinkling feeling what you’re asking for is the job for OBJ parser, unless you want to code your own of course. grin

By “without applying any uv texture mapping via AS3”, do you actually mean doing all this at runtime ? It can be done of course with the OBJ parser.

   

Yashin, Newbie
Posted: 12 December 2012 05:00 PM   Total Posts: 11   [ # 4 ]

Yes, I want to apply the texture at runtime, this is why it is important for me not to hardcode any texture information in AS3.

So do you mean that the OBJ parser can retrieve the material information from the mtl file and apply it to my object? Is there any sample codes for this process of loading the obj and its texture automatically applied?

   

Avatar
Darcey, Moderator
Posted: 14 December 2012 07:51 PM   Total Posts: 209   [ # 5 ]

Personally I pref to preload all my models and materials via maxloader (greensock) then inject them into Away3D and use loader3D onComplete / onParseComplete (cant remember exact handler name) loop through checking the mesh for name and apply the correct textures.

1- Preloader
2- Parse time (render all objects with textures way way way out of view)
3- Give a little time before starting whatever it is your going to do

OBJ contains a link to an MTL file these are your textures, open an OBJ file in a text editor you will see. I delete this and loop through the mesh names on parse complete.


EG:
http://www.allforthecode.co.uk/aftc/forum/user/modules/forum/article.php?index=4&subindex=6&aid=335

and

http://www.allforthecode.co.uk/aftc/forum/user/modules/forum/article.php?index=5&subindex=8&aid=329

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X