Wings 3D -> UV Mapping -> KBerg's OBJ Loader

Member
Posts: 156
Joined: 2002.10
Post: #1
I am having trouble exporting OBJ models from Wings3D and having them rendered properly using Karl Berg's OBJ Model code.

Currently I do the following:

Create Model in Wings 3D
I Create a UV Map using Wing's autoUV feature and get a 'flat laid out' version of my model. I then do 'Create Texture'.

Now I export the model and get a .obj, .mtl and the texture .tga file

Karl Berg's code comes with a model loader demo, including the model of a spaceship. Now I want to replace his model with my own. But when I use mine, it just renders as a dark grey model, with no texturing, or even any local illumination. I have tried using the material properties and texture from the demo space ship, but it still does the same thing. So I think there must be something wrong with how I do the UV Mapping in Wings 3D.

Can anybody shed any light on this problem?

Cheers

- Iain
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #2
I don't use Wings, but I've done quite a lot of stuff with OBJ files recently....

Check that the OBJ file really does contain normals (vn) and UV coordinates (vt) and check that your texture's dimensions are a power of two in both directions. Also make sure that your material and filenames match up and that Karl's OBJ loader is able to find the files (you may need to specify some or all of the path to make it work). Step through it in the debugger if necessary.

Do you know which version of Karl's loader you're using? I was able to make version 2 work with my models, although some tweaking was necessary to make it handle the first UV properly.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Member
Posts: 156
Joined: 2002.10
Post: #3
Yeah, the files do include texture coords and normals (which look like they are normalised!). I also checked the paths and they seem OK too - the loader is finding all the files it should.

This is version 2, so I was wondering if you could possibly send me one of your models that you know works, so I can compare and see if it goes OK?

iain<at>pyramid<dash>productions<dot>net

Cheers

- Iain
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #4
Admittedly, I wrote my own loader. But, you should make certain that the model being exported is quadrangulated or triangulated. I was surprised to see n-gons ( where n is > 4 ) in the obj export...

Edit: Whoops. Somehow I hadn't registered that the problem was texturing related. Sorry for the worthless post.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #5
IBethune Wrote:This is version 2, so I was wondering if you could possibly send me one of your models that you know works, so I can compare and see if it goes OK?
I recall having difficulty getting it to load .mtl files from the correct path, so maybe that's the problem you're having. I made some changes to the code in my game Rescue, to add support for loading textures from the correct place and using STL_image to support formats other than Targa. I may have used brute force to hit the Resources/Textures folder. Wink

You can get the Rescue source from my website. You can get the OBJ files from the same place (I can't remember if they're in the source archive or only in the playable download).

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #6
Incidentally there are also a couple of other problems with the said obj loader. One is that if your obj specify normals it will completely ignore them and generate it's own. This is because the function NormDisplObj resets all of your normals after it has just load them. comment out the reset code and it works fine. Also, if your normals are already normalized, comment out the code that normalizes them on load time, it made my models load about 10x faster. Also the way it deals with multiple materials doesn't tend to work, so either limit your model to one material, or find and fix the code which decides how many objects there are. I've forgotten how I did it unfortunately, or I'd tell you.

Having said all that, it still does the trick nicely when you get it to work for your specific needs. You might need to step through the loading in the debugger to find whats going wrong in your case. Make sure you're checking for glErrors, and stick a few printfs around the place to do dumps of what the obj loader thinks it's getting for comparison.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Puzzler183
Unregistered
 
Post: #7
I'd definitely suggest you just write your own loader - that one sounds loaded with problems (pardon the pun Smile ). And it's always a good educational experience.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Using Wings 3D Models In Game Nick 20 13,853 Mar 20, 2005 05:13 PM
Last Post: torncanvas