.obj files? What are those?

Apprentice
Posts: 11
Joined: 2005.03
Post: #1
Could someone please explain to me what .obj files are? I'm very new to 3D programming, (as in, VERY), but I've used my degree in Google to find out the following, (I think Sad):
  • Obj files are for use in 3D games and other things.
  • It is possible to load them into Xcode projects with OpenGL and use them as such.
That's about al I know. I'm still wondering: What exactly are they? Do they hold vectors and edges and faces and such or are they encoded in a very different manner? How do you access them from OpenGL and Xcode? What sort of commands and methods are neccessary to put them in my OpenGL view? I've seen lots of implimentation tips, but nothing on what they actually are. If anyone is willing to take the time to explain this, I would really appreciate it. Thank you. Smile

"Far too many to count. I lost track at seven." ~My brother
Quote this message in a reply
Member
Posts: 78
Joined: 2002.06
Post: #2
.obj files are a simple text based 3d file format. They tend to hold vectors, faces and objects. The format is popular because it is well supported as an export option on most 3d graphic programs, and it is extremely easy to understand.

Here is a quick overview of the format: http://www.royriggs.com/obj.html

To use in your own project, you need to use some loading/parsing code to open and render the files. Several people on this forum have written their own (like me). Here is a fairly good one: http://www.idevgames.com/forum/showthrea...obj+loader
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2005.03
Post: #3
Hm... the download link is not working. "File not found", it says. I could easily find another, but if you could point me to a different one that would be nice. Smile

*thinking* Blink ... Aha!

Two more questions I came up with: Are there any freeware 3D modellers that export in .obj format? I know there are a few semi-expensive ones, but I'm not sure if there are any freeware programs.

And: How do you access the object once it's loaded into my OpenGL Xcode projects? What methods are used? I know how to move cubes and other objects I create through OpenGL, but is it the same with .obj files?

Thank you very much.

"Far too many to count. I lost track at seven." ~My brother
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #4
Well, no. If you know how to do cubes in OpenGL, you're probably familiar with glVertex3f. All the .obj files get you is the info on what values to pass to glVertex3f. OpenGL does not do any file handling at all for you.
Quote this message in a reply
Member
Posts: 28
Joined: 2003.10
Post: #5
trebek Wrote:Two more questions I came up with: Are there any freeware 3D modellers that export in .obj format? I know there are a few semi-expensive ones, but I'm not sure if there are any freeware programs.

Wings 3D is probably the free-est and best.

http://www.wings3d.com/

-- Giles Williams
Oolite - retro space-sim agogo
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2005.03
Post: #6
I love it! I tried Blender once, but it didn't seem to be able to export much and I couldn't understand it at all. (Well, maybe a little but. Smile) Wings3D is awesome! I made this really cool model in this really short time. *recovering from shock...*

Um, anything else I need... *plays around with Wings3D for a while, then Xcode, then the page reccomended by willThimbleby, then realizes*...

Oh! Does anyone have the correct link for that Obj parser thingy? I looked at the explaination of the obj format and it confused me quite a bit. I know it's a little lazy, but I really don't want to try and write my own parser, as I'm having enough trouble writing simpler things.

Also, (aren't I great at coming up with questions? Rolleyes ), I heard that it is very difficult to animate obj models. Not that I know much about animating other things, but does anyone know what this is about and what it means?

Thank you all so much. (Mostly for putting up with me...)

"Far too many to count. I lost track at seven." ~My brother
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #7
I would actually recommend you look at Karl Berg's .obj loader. It's what I used to base my early implementation on. I still have to fully look through his code. You can find it at http://www.sfu.ca/~kberg/Code/sourcecode.html. Hope that helps a bit.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #8
Animating OBJ models... yes, that's impossible, actually. Here's the deal: when you have an OBJ model loaded, you can animate its movement, rotation, scaling, color, texturing and whatnot, just like you would a square or triangle. If you want to distort the actual model, you have to distort your actual vertices loaded. There is no program that can export an animation with .obj, since that's not in the spec. So, before you jump off the obj train, let me explain what you need to do: Wink

If you just want moving static objects, glTranslatef and glRotatef them. If you want moving machinery (cars, robots, non-soft stuff) make several obj models and combine them like legoes. Finally, if you want skeletal animation and stuff, you need to figure it out yourself. But, once you're adept enough to do combined OBJ model animation, that shouldn't be too hard. Wink (Oh, and welcome to the boards, by the way)
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #9
I use ODE for rigid body dynamics, using the matrices ODE returns to position my OBJ models. Now, that said, that's great for vehicles but if you want squishy, more natural models, you'll have to look somewhere else.

There's an open source skeletal animation system, called Animadead ( http://animadead.sourceforge.net/ ) -- this would be a good counter to OBJ models + rigid body dynamics.
Quote this message in a reply
johnb003
Unregistered
 
Post: #10
I know this is a bit late to reply, had a few problems with activating my account.

Anyway, I just wanted add my comment on obj and Animadead. First of all, you might be getting started on the wrong foot; It may be better to start with a modeling program unless you already have a collection of models in a certain format. But looking at the format you want to use can sometimes be unnecessary. Like others have mentioned obj files don't help much for animation, and as TomorrowPlusX mentioned you might want to use a library like Animadead to do animation.

Animadead has it's own format you don't even need to know how it works. Animadead exports models from the modeling package to it's own format, and then you just use the library in your application, tell it what files you want it to load and start playing with the animations.

Here's a little inside info on Animadead too... It's at a good stable version now, but there is a LOT of work going into it right now. There should be a new release very soon and even 3.0 possibly by the end of the summer.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #11
.obj files are alot harder to parse then any other model format. I'd go with the .mod files, myself.

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
Nayr Wrote:.obj files are alot harder to parse then any other model format. I'd go with the .mod files, myself.

While I don't support the fancy stuff like curves and whatnot, my OBJ loader, which does support triangles & quads, and texture coordinates, was written in about 3 hours, with less than 500 lines of code -- & 1.5 of those three hours was spent testing my parser. OBJ parsing is easy.
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #13
oh. I thought he was making a full .obj loader.

It's not magic, it's Ruby.
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #14
Nayr Wrote:oh. I thought he was making a full .obj loader.
What do you mean a full one? All a .obj file is is normals, texture coordinates, vertices, and faces. If he can load tris and quads and texture the models, what else is left?
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #15
.obj files are the EASIEST to parse, they're just text telling you what to do. Try .3ds or something, dealing with all those chunks...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenAL - Ogg files vs Caf files Fred9000 8 13,391 Aug 23, 2011 08:01 PM
Last Post: ipeku