Loading .obj models?

Blake
Unregistered
 
Post: #1
anyone know a good example of how to load and render a .obj model?
Quote this message in a reply
kberg
Unregistered
 
Post: #2
Quote this message in a reply
Blake
Unregistered
 
Post: #3
looks a bit complicated, anything simpler?
Quote this message in a reply
kberg
Unregistered
 
Post: #4
Blake Wrote:looks a bit complicated, anything simpler?

heh, this is about as simple as could possibly! Rasp

Include ModelType.h and ModelType.cpp in your project, then all you care about are the following lines in the appropriate places for each model you want...

ModelType myModel;

myModel.LoadObj("my_model.obj", 1.0);

myModel.Draw();
Quote this message in a reply
Blake
Unregistered
 
Post: #5
kberg Wrote:heh, this is about as simple as could possibly! Rasp

Include ModelType.h and ModelType.cpp in your project, then all you care about are the following lines in the appropriate places for each model you want...

ModelType myModel;

myModel.LoadObj("my_model.obj", 1.0);

myModel.Draw();

that true, for some reason my brain wasnt working Wink
Quote this message in a reply
deekpyro
Unregistered
 
Post: #6
kberg Wrote:You could try this:

http://www.sfu.ca/~kberg/Code/ObjLoader.tgz

I use this model loader myself in a game I'm working on, sure seems easy enough once you've combed through the code a few times. I've had to make a number of changes to it myself since it isn't perfect and to fit my needs but I'd gladly help out with using it as much as I can.

Derek
Quote this message in a reply
Member
Posts: 304
Joined: 2002.04
Post: #7
if youve made improvements to kberg's code deekpyro - maybe you could send them to him to possibly be added to the next version.
Quote this message in a reply
deekpyro
Unregistered
 
Post: #8
I've spent a good deal of time restructing this model loader so it would be molded into something more specialized for my game. I hope in time to rewrite a lot of it, then with that rewrite for my game go back and make a more public version.

It's not that I don't like the modeler, if I did (frown upon it) I wouldn't be using it. On the other hand it's really messy and downright ugly in some areas Grin

Derek
Quote this message in a reply
kberg
Unregistered
 
Post: #9
deekpyro Wrote:It's not that I don't like the modeler, if I did (frown upon it) I wouldn't be using it. On the other hand it's really messy and downright ugly in some areas Grin

If there are any problems with it I would love to hear about them, especially if you consider any of them bugs. I know there are quite a lot of relatively inexperienced programmers using this code (I get emails all the time), so it's kind of important that this be stable and easy to use.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #10
Since I haven't posted in this thread, yet, its about time to add my two cents.

A couple of weeks ago I have written an .obj loader from scratch, and it took 2 hours to get all the functionality running to parse a single-mesh .obj file, with everything supported except grouping and materials.

So, it might be worthwhile to just roll your own, if you have any idea how to parse a document. The .obj file format is really simple, so it is probably a good exercise. IMO, you can write your own loader in the same time you figure out how to use somebody else's.
Quote this message in a reply
Member
Posts: 304
Joined: 2002.04
Post: #11
true DoG, but there are lots of little gotchas - like if the data is broken up into multiple lines - and all the different permutations possible for the data - that kberg has accounted for. The code has gone through a number of revisions, each time someone reported finding an obj file that broke it. Kberg's code seems to be able to handle objs that are exported from a variety of different 3d packages - many of which export slightly differently formats.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #12
Mine handles C4D and Maya files so far, but since I made it after the official file format specs, it should handle just about anything
Quote this message in a reply
Post Reply