Taking the next big step... into 3D

Member
Posts: 321
Joined: 2004.10
Post: #1
This site has always steered me in the right direction. I learned about
SDL, GLUT, OpenAL, OpenGL from this site and went from
pixmaps and GWorlds on OS 9, to texel maps and textures in OpenGL
on Tiger. And have done alot of programming (with 2D) in the
above technologies.

Now I'm interested in getting into 3D. Assume I'm a complete Newbie;
because I am. My brain always turned off any 3D stuff because the
above was enough without piling anymore on.

So, can somebody give me a brief lay of the land. What are the main
formats? Any standards? Is there alot more competing technologies than say
DirectDraw of OpenGL? Does each game company or console manufacturing have their own technology and or tools? Just a brief outline is all I need. I'll google it from there.

thanks.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
For computers at least, you will need to use OpenGL or, if you're making something for Windows, also Direct3D. That's pretty much it. I believe some of the consoles have different libraries, but for the computer that's where you stand for hardware accelerated APIs. I'm sure there are a few other APIs out there, but unless they're layered on OpenGL or Direct3D, it won't be hardware accelerated and therefore extremely slow.

Of course, if you're using OpenGL for 2D, why not use it for 3D? That's its main focus, and why not already do what you know? Basically, for OpenGL, the only real difference is that you add a third dimension to your objects. Be careful, though, because you can't have quads and polygons with vertices on different planes. (for the same quad or comment) Just read some tutorials and you should be fine.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #3
Gottcha, maybe I need to be rephrase that. I hear the term "model" quite abit
in 3D programming. In fact, the current iDev home page has a big article about
some open source modeling application. Granted openGL can give you the
"framework" for displaying and controlling 3D objects, but just like you need
Photoshop or GraphicConverter to define 2D images for consumption by openGL, don't you need tools to define 3D "objects" of any complexity for openGL. I realize you can define cubes for instance just in openGL. But for
really complex stuff, don't you need to import "model" data? Maybe I
should have said 3D modeling application formats, etc.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2005.05
Post: #4
OpenGL has no standard format for loading model and texture data from files. Its up to you to do it yourself.

I found .obj files to be easiest to start with. They are basically just text files and are supported by nearly every modelling program you can think of. There is a description of the file format here.

For static objects I now convert the obj file into my own binary format, and then load the model data into a vertex array.

HTH,

Lyndon.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #5
OpenGL doesn't specify any sort of "model" or anything else. You pretty much hand opengl vertices or lists of vertices and tell it "draw triangles", or "draw quads", etc.

I heartily recommend you buy "The Red Book" ( http://www.kokogiak.com/amazon/detpage.a...ooks&type= ) -- this is how I learned opengl. While the edition I bought used a fairly old variant of GLUT for windowing, the GL commands themselves worked and all the sample code worked through GLUT.

Basically, if I were you, I'd get the Red Book and go through the chapters, one by one doing each tutorial. It might take a month, but you'll have a fairly solid understanding pretty quickly.

Then you might want to buy a higher level book, such as one of the "Game Programming with OpenGL" types. I bought one which -- like it or not -- was Win32/DirectX specific ( for everything but the 3d, which was OpenGL ). I learned about vertex arrays and a lot of stuff which my older edition of the Red Book didn't cover.

Regarding model formats, parsing .obj files is easy. I happen to have pretty robust personal library for string parsing in C++ so I was able to write an OBJ parser in a single morning. But to actually *draw* the model, I simply tell opengl that I'm drawing triangles and then I hand GL a list of vertices. That's it, basically.

EDIT: I forgot the *most* important book in my GL library. The "OpenGL SuperBible" ( http://www.kokogiak.com/amazon/detpage.a...type=&sb=s ). It's worth every penny. It even -- and this is a first as far as I cen tell for GL books -- provides sample code that works on OS X, complete with Xcode projects! The only problem is that a fair bit of the sample code broke when I upgraded to Tiger. The breakage has to do with the was GL extensions are aliased. Ho hum. Such is life. The original binaries continue to work, but the code, when built, produces binaries that often segfault. I've done some futzing with the sample code for that book so if you have any problems, let me know which project/chapter and I can explain ( maybe ) how to get that demo working on Tiger.

Finally, to manage OpenGL extensions, I heartily recommend you try out GLEW. ( http://glew.sf.net ) GLEW makes it trivial to check at runtime for extended Gl features, such as support for shaders, or other functionality which might exist on one card on one version of OS X, but not on some other combination. This is the great weakness of GL compared to DirectX ( since COM formalizes this kind of dynamic functionality ), but GLEW makes it trivial, and is crossplatform too.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
My largest problem with the OpenGL SuperBible was all the typos. However, I think I learned a lot by fixing his mistakes.

If you want to use 3D models, you might want to look around for a framework that opens and displays models for you. I'm not sure what's available, but I know that I am going to make a program to import models, add the information necessary to display shadows, add collision surfaces, and animations, and also have a framework to use all that stuff in a game. I'm planning on doing this as my next project, so I'll probably start it in 1-3 months (however long it takes me to finish this project), and will probably take me a few months to complete. If you can't find anything, at least you know that you'll find something eventually... (assuming I succeed, of course. Rasp)
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #7
akb825 Wrote:If you want to use 3D models, you might want to look around for a framework that opens and displays models for you. I'm not sure what's available, but I know that I am going to make a program to import models, add the information necessary to display shadows, add collision surfaces, and animations, and also have a framework to use all that stuff in a game. I'm planning on doing this as my next project, so I'll probably start it in 1-3 months (however long it takes me to finish this project), and will probably take me a few months to complete. If you can't find anything, at least you know that you'll find something eventually... (assuming I succeed, of course. Rasp)

My engine does all this, and pretty soon ( once I've got a good first person camera system implemented ) I'm going to release the source. If you're interested...
Quote this message in a reply
Moderator
Posts: 529
Joined: 2003.03
Post: #8
I think I got the 2nd edition Superbible for less than $5 off eBay. Well worth it. I don't think the Red Book was all that good to learn from.

Beginning OpenGL Game Programming is pretty good also.

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #9
Quote:I found .obj files to be easiest to start with. They are basically just text files and are supported by nearly every modelling program you can think of. There is a description of the file format here.

For static objects I now convert the obj file into my own binary format, and then load the model data into a vertex array.


Shady994 got closest to what I was fishing for. What are the major/minor
modeling programs out there for the Mac? I have no idea what's out there.

So, one fires up the modeling program and create a really intricate and cool looking vase (I know, not sexy but I'm learning here) . Then you export the data as an .obj format file. Let's assume I'll be using .obj from now on.

Now as for getting the .obj into openGL; Can anyone recommend any existing libraries or predefined functions that would read into .obj files into openGL's
vertex arrays? Come to think of it, I'll also need to get up to steam with
vertex arrays.

thanks for all the help.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #10
Blender is free and powerful. That is what I'm planning on using once I start using actual models for my graphics. (the game that I'm making right now just has hard-coded graphics) As for frameworks, I have no idea what's available. A quick google search yielded no usable results, but go ahead and try on your own. You should be able to see what TomorrowXPlus does in his code relatively soon. I'll have a framework on my own eventually, but I doubt it'll be done in time for you to start your first project.

Anyways, I'm not a huge fan of text formats like .obj. It may be easy, but it's also larger and slower than a binary format. I'd consider trying a different format if you can.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2005.05
Post: #11
There are quite a few modelling programs available for the mac. They all have different interfaces and quirks which makes recommending one in particular difficult. Everyone has their own idea about which one is best. I use Wings 3d, not because it is the best, but it is what I am used to. And it's open source and free. Lately I've been looking at Cheetah 3d, which costs $99, and can export to plenty of file formats, including obj. You can already find plenty of discussions here about the different modelling programs available.

I'm sure there are libraries around that can load obj files into a format suitable for OpenGL. I don't know of any offhand though. Its pretty easy to do it yourself, and you'll learn more that way. The best way to get started is to download a free modelling program, read up on the obj file format, and create some obj files yourself. Open them up in a text editor, and you'll see that the format is pretty easy to get your head around. Smile

HTH,

Lyndon.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #12
Perfect. Thanks all. I'll stay with .obj (or text) until I get some experience under
my belt. Then I'll move on to faster formats.

Say, is Maya considered a modeling program or is it more of a movie/special
effects program? I'm aware it is super expensive and super complex so I'm
only curious.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #13
AFAIK it's also a modeling program.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #14
Quote:My engine does all this, and pretty soon ( once I've got a good first person camera system implemented ) I'm going to release the source. If you're interested...

Heck yeah. I'm like Pavlow's dogs; I'm salivating already. Is it written
in C++, Cocoa, or COBOL Smile
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #15
WhatMeWorry Wrote:Heck yeah. I'm like Pavlow's dogs; I'm salivating already. Is it written
in C++, Cocoa, or COBOL Smile

It's written in the lamentations of damned souls... e.g., C++.

Basically, I just want to have a working first person camera, not because that would make the engine "done" but because it taxes a lot of design decisions I've made, since it has to hook up into collision detection, kinematics, etc. A good first person system has its fingers in a lot of pies, so it's a good test of the underlying system. I've already fixed a fairly significant design error in the process...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Taking advantage of 3DNow, SSE, MMX or whatever the PPC equivalent is called... Jones 3 3,595 Oct 24, 2006 07:06 AM
Last Post: Jones
  Next step after Timers nabobnick 1 2,131 May 11, 2006 01:51 PM
Last Post: OneSadCookie
  How is Q3A taking advantage of dual CPUs? DoG 2 2,907 Mar 8, 2003 05:08 PM
Last Post: DoG