Software: Away3D 4.x

m_kus, Newbie
Posted: 05 July 2012 06:04 AM   Total Posts: 3

I’m not sure is this a bag or not. And sorry for possible mistakes in English.

I’m trying load “obj” file using:

AssetLibrary.load(new URLRequest("assets/Test.obj")); 

On success loading i’m trying apply bitmap texture:

mesh event.asset as Mesh;
mesh.material = <TextureMaterial

But resulted mesh just changes its color - no pictures on surface…
While debugging i discovered, that ObjParser.addDefaultUVs has next line:

= (j+1>2)? 0:j++; 

As result j always equals to zero and UV is repeated pairs (0,1). Is there a mistake or not?
How can I easy manipulate texture mapping for my example?


Richard Olsson, Administrator
Posted: 05 July 2012 08:16 AM   Total Posts: 1192   [ # 1 ]

First of all, the OBJ parser no longer creates dummy UVs. This is handled elsewhere in the engine in the latest codebase, so please try the “release” branch of the GitHub repository to see if that fixes the issue.

On a more important note though, if you want to use a texture on your mesh, you should probably make sure that it has the kind of UV mapping that you expect instead of using the dummy UV mapping (which is only there to prevent crashes, and which will result in the entire texture being fitted into every triangle.) The only way that you can make sure the object has a sensible UV mapping is by doing the UV unwrapping using the tools of a 3D modeling package, e.g. Blender, 3ds Max or Maya.

If your mesh already has UV mappings in your 3D modeling package, then it sounds like it’s not being exported properly (or Away3D would use that mapping instead.) Make sure you configure your exporter to include UV maps.


m_kus, Newbie
Posted: 05 July 2012 09:08 AM   Total Posts: 3   [ # 2 ]

Thank you for your response!

I have found same version of addDefaultUVs method at github.com/away3d/away3d-core-fp11/blob/master/src/away3d/loaders/parsers/OBJParser.as. Is this a latest version?

I have tried to load OBJ created by FreeCAD - and this OBJ has no UV information… So, Away 3D has no capability for generate UV and I need use Blender etc?


Richard Olsson, Administrator
Posted: 05 July 2012 09:19 AM   Total Posts: 1192   [ # 3 ]

The one you’re linking to is on the “master” branch, as you can see in the URL. The latest work has been going on in the release branch, and that’s where you need to look if you want the new UV generation code.

But don’t worry too much about that in this case, what you really want are proper UVs, not auto-generated ones.

You are correct that Away3D has no capability of generating relevant UV information. It can only create dummy UVs, which will make sure the object renders without crashing, but it will not wrap the texture around the object in a way that actually makes visual sense. You indeed have to take care of that mapping yourself in some 3D modeling package. Away3D is a rendering engine, and while it does have some good geometry generation tools and utilities, it is not intended to be used for UV unwrapping. The reason simply being that your texture has to be painted to match the UV mapping, so making the UV mapping at rendering time defeats the purpose. Here’s what a workflow should (and usually does) look like:

1. Create model
2. Unwrap model
3. Paint texture on unwrapped UV layout
4. Apply texture (or don’t, and do it in code instead
5. Export model with UVs
6. Load model in Away3D
7. Optionally apply texture (if one wasn’t included in the model file)

As you can see, doing step 2 in Away3D makes little sense, because then you wouldn’t be able to paint or preview your texture (steps 3-4) in your modeling package.

These circumstances, together with the fact that automatic UV unwrapping is extremely complicated (no modeling packages I know of do a very good job at it) and resource heavy means it would be a huge effort to implement in Away3D, that goes mostly wasted simply because it doesn’t make much sense to use it at all in most cases.


m_kus, Newbie
Posted: 05 July 2012 09:51 AM   Total Posts: 3   [ # 4 ]

Thanks. I hope that I understand you…

‹‹ OutlineMethod color


Away3D Forum

Member Login