3D Wavefront .OBJ loader (GLB code) pre-Beta

Previous topic - Next topic

Cliff3D

Greetings and salutations.

If anyone cared to extract the .exe attached to a folder and put some .OBJ and other files (.mtl? textures? .jpgs?) in there and test it, I'd love to hear how you get on. Do .JPGs make it crash? Does it fail to texture some parts? Are there holes in the mesh? Whatever... it SHOULD handle .OBJ files with multiple texture sprites (the record so far is 24 for one .OBJ model), and should sortof handle ambient and diffuse materials by choosing the brightest setting (I can't see how to do ambient on a per-material basis rather than a lighting basis in GLB). No transparency or wireframe views yet. Quads are handled. I think that's about it...

It seems to be working pretty well here for the stage it's at, but I've been up too many hours now and need to go lie down! Looking forward to a complete lack of problems cropping up... :D

:D

[attachment deleted by admin]

MrTAToad

I'll have to give it a go with an OBJ file created in gameSpace :)

Cliff3D

Thanks-probably one of my biggest dangers is having too many .obj files from the same/similar sources (so too much similarity).

The auto-scaling-and-centering routine is known not to center as well as I woukd like (hinky on x and z, seems inexplicably better on y!(

mars_chaos89

i try to use your obj loader with my model..but it cannot process it...

Cliff3D

That is a shame - sorry I couldn't help. I hope *.ddd files work better for you. (at this stage I wouldn't be able to work out what it isn't seeing about your .OBJ file without having the .OBJ file, and you don't know enough about .OBJ files/3D to diagnose at your end without a great deal of effort. Sorry).

mars_chaos89

plzz dont give up on me cliff....noooo

MrTAToad

Been trying with BMP textures - and whilst the object displays fine, there doesn't seem to be any textures...

Using AC3D OBJ exporter...

Cliff3D

Hmmm...is AC3D creating .MTL files?

.OBJ files are slightly odd, in that the object/model is in the .OBJ file, along with material NAMES - but the material definitions (including which - if any - bitmaps to use) is in a seperate .mtl file.

I've only recently thrown .mtl file handling together, so if there are .mtl files it's probably how I handle them that's the issue. .mtl files are small, so if you have them any chance of posting one here so I can have a look and see what it's doing? (they are just text files).

Thanks :)

MrTAToad

Hmm - I dont remember seeing the MTL file - its possible they aren't being created.

Cliff3D

Phew! That would neatly explain the models being textureless. Hmmm - I may need to create a button that says "Load a default texture" or "choose a bitmap" or something because without any shadowing, blank models look a bit... bland :( one of my problems is that many of the .OBJ models I work with are multi-texture, so having a single bitmap load seems a bit...meagre. We'll see - I can see some benefits (like a checkerboard showing stretching/smearing/seams).

MrTAToad

The next thing I'll test is objects with holes in :)

A large number of objects too...

Cliff3D

#11
OK - here's a slightly updated version (basically, the current version of the library with a slightly updated - and quieter! - main program as front end).

Main changes:

Now operates without bleeps - important if you're going to test many objets!
If the model is UV mpapped then it tris to display the first bitmap (if any) then draws the UV map in green lines then draws the uv map as a red dot cloud, then calls SHOWSCREEN so up to 3 maps are overlaid. This usually looks horribly garish :( Pauses for mouse press.

Whether it has a uv map or not, it then tries to show 3 orthographic wireframe views of the model in a backward-L layout on screen. Pauses for mouse press.

Once that mouse has been pressed, it then converts to .x model format in memory - this is slow!!! - then displays. If there is one or more bitmaps mit should use those as instructed by the .mtl, but if not it should use "Checker.png" as the default texture/bitmap (obviously, if you replaced "Checker.png" with another bitmap it will use that instead). I like the checker look, it helps break up/show the surface far betetr than pure white ever did!

This then finally shows the model as a 3D rotating object - and waits for a mouse press. On pressing any mouse button the program should exit - cleaner, I think, than needing to press the Esc key or waiitng for the demo timeout :D

One possible problem since I am using culling is that your model might appear inside-out (i.e. only the far side is shown, not the near side). I'd be quite interested in how that goes, actually!

[attachment deleted by admin]

Cliff3D

Oh! If you replaced Checker3D, be aware that if the map isn't a power of 2 size odd things may happen. That doesn't apply to any other bitmaps referred to by .mtl as the program scales all other images down to a postage-stamp size so that the program will work on my netbook ;)

Here's one of my test subjects. Note how horrible the UV mapping is on this thing - argh! A nightmare to paint. Hopefully most models are more painter-friendly than that :D



[attachment deleted by admin]