3D Engine from scratch

Started by
14 comments, last by freyr 22 years, 11 months ago
I and a friend of mine have set ourselves a personal goal to complete a working 3D engine. However, we are having some trouble which I hope someone out there can help us with: 1. Where the fu** do I start? 2. How much should I rely on OpenGL to do rotations and translations for me? 3. What kind of design should I use, a portal engine? 4. Should I really start thinking about such advanced stuff as BSP trees in the beginning? Any comments would help. We''ve been having trouble finding a comprehensible tutorial on the net. The OpenGL tutorials here are great, but I would like some deeper understanding rather than just letting a third-party library do all the work.
Advertisement
Hey there,

Im working on one too, only with a somewhat larger group.
We are also planning right now.

The best thing I can recommend is to learn, learn and learn more ;-)
Furthermore, it pays to look at some other 3d engines too not just the pretty pictures, but also the source codes, their documentation.

Try looking at crystal.linuxgames.com (not my engine...mine is still in the works)
Also, OpenGL is very important if you want it to work on more than just Windows.
Thats my plan, so im sticking with OpenGL and for now im still working on my math, so letting OpenGL do the rotations isnt all bad.

Keep looking at the boards and the articles, you will find a wealth of clues on how to do these yourself if you have to (I havent tested the speed of the opengl calculations, but you can bet that they are effecient)

And we are starting with some good desiging first and its important to keep in mind what you want.
We want it to work the same way on different platforms, so right now when we finish all of our planning, we will start creating some libraries to work with.

Good luck and I will keepan eye out if you need any info

"There is a $500 fine for detonating explosives within the confines of a city"
"There is a $500 fine for detonating explosives within the confines of a city"
1:
Make sure you can program really well.
Build an scalable little demo,implementing things bit a bit but doing it so you don´t have to restart everything when you want to add something.
Do a window.
Set OpenGl up, fill backbuffer to a color and reset it.
Draw a triangle on screen.
Play with materials, colors and textures.
Rotate it.
Rotate around it.
...
The big trick is to do remember that you will need all of these for Quake4

2:
Let OpenGl do the Math.

3:
It depends of what do you want to do: How much similar is Quake with Black and White?(Both are 3d).

Portals are for indoors.So do BSP.
Quadtrees and Octrees are for outdoors.

4:
Of course not!.
If you want to do a FPS...You must be patient...
I´ll implement the characters before the scenario.


Have a look at:
www.flipcode.com
www.mrgamemaker.com
http://baskuenen.cfxweb.net/
www.gamasutra.com

What the hells!
1:
Make sure you can program really well.
Build an scalable little demo,implementing things bit a bit but doing it so you don´t have to restart everything when you want to add something.
Do a window.
Set OpenGl up, fill backbuffer to a color and reset it.
Draw a triangle on screen.
Play with materials, colors and textures.
Rotate it.
Rotate around it.
...
The big trick is to do remember that you will need all of these for Quake4

2:
Let OpenGl do the Math.

3:
It depends of what do you want to do: How much similar is Quake with Black and White?(Both are 3d).

Portals are for indoors.So do BSP.
Quadtrees and Octrees are for outdoors.

4:
Of course not!.
If you want to do a FPS...You must be patient...
I´ll implement the characters before the scenario.


Have a look at:
www.flipcode.com
www.mrgamemaker.com
http://baskuenen.cfxweb.net/
www.gamasutra.com

What the hells!
Thanks for the posts.
Anonymous poster - I have already fulfilled your criteria for where I should start. I can pretty much figure out the OpenGL graphics part by fiddling with the tutorials on Nehe''s page. The things that I am stil unclear about is the nitty-gritty, the inside workings of the 3D engine.
For example, how do I design the engine? Should I have a seperate module for physics laws? Should each object know its own velocity, vector and mass or should the world take care of that? How does a portal engine really work?
I have been searching for a 3D engine source code that also has a tutorial. I have not been very successful. Anybody know about something like that?
Golthar - You say learn, learn, learn... I have scoured the net searching for tutorials that ara just right(that is not to complex and not too shallow) and have not had much luck. How did you learn?
I myself is a newbie when it comes to 3D, and even more of a newbie when it comes to OpenGL (I don''t even try to use it yet).
Right now I''m fiddling with building my own engine, or API or whatever you wanna call it. I.e. I''m doing every single vertex transformation and drawing every polygon myself. And quite frankly, I''ve learned a lot from it already (There''s a white cube rotating on the screen, no shading. flat triangle fillers, yeah I implemented Z-gourad just to test it, but I haven''t implemented any kind of Z-sorting yet).
I implemented a camera system too! hehe

As for doing the transformations yourself vs. letting OpenGL do it; doesn''t OpenGL make use of any possibly availbly hardware TnL?

"How does a portal engine really work?"
The idea is that the scene consists of rooms. Each room has a portal polygon in each and every "hole" (doors, windows). These polygons are just like any other polygon, except they aren''t drawn. And thus we can use backface culling on them just like usual. If it''s not a backface, we just "go" into the room it''s pointing at and apply the same technique there.
Imagine a room where we could backface cull 10 out of 12 portal polygons, wow - what''s a remarkable speed up

"This album was written, recorded and edited at Gröndal, Stockholm in the year of 2000. At this point in time money still ruled the world. Capitalistic thoughts were wide spread. From the sky filled with the fumes of a billionarie''s cigar to the deepest abyss drenched in nuclear waste. A rich kid was a happy kid, oh..dirty, filthy times. Let this be a reminder."
- Fireside, taken from back of the Elite album
The anonymus poster was me, sorry.

Happy to see you´re more advanced that what I thought!

The way to design it...Have a look at http://baskuenen.cfxweb.net/

The way to integrate physics with graphics with Ai, with networking with... Not done yet. Design it beforehand, in an open design. Object Oriented Programming is key in doing this well.

You could inherit the Actor class form the PhysicalObject class and the GraphicalObject class, with multiple inheritance or single, let the Actor class own his Physical and Graphical representation... Don´t know what I will do.

Each actor should keep their Velocity, Position...

I recommend you reading: "Design Patterns" by Gamma... Addison Wesley. A wonderful book about software design.

www.flipcode.com has a complete course of portal engines


Go to Baskuenen...


What the hells!
What the hells!
Yes, I said that you should learn, its what I do :-)

Ofcourse you want to make sure that your skills are good and by the sounds of it, you are doing well.
NEHE is the place to be and follow all his tutorials, they are good study material.

Also, Gamedev.net has a lot of articles, which are all great.

The way I implement physics is like this:

You have an object, like a drone and the drone itself contains the data for movement, when the engine runs, a physics "device" runs through all the relevant objects and processes movement, collision and gravity.
This isnt implemented yet, otherwise I would love to show the code

In my project im also redefining the object, making a special engineobject so to speak, these can be converted to a script to transport them to other computer.
(Did I mention that I have both a Java and a C++ version in the works?)
Anyways, people keep posting the great ideas because we are all learning here

Do you know how much you want to put in the 3d engine?
In mine it will include sound, graphics and networking.

I will keep watching the boards and see if you need any more help :-)
"There is a $500 fine for detonating explosives within the confines of a city"
Slow Down - Take a deep breath, start reading books!
Building a 3D engine is no easy task (unless you want to build a really crappy one). Take the time to learn the basics of graphics programming and OpenGL. Learn them well, and then start your planning for your 3D engine. Start small - for you have to learn how to crawl before you can walk, and you need to know how to walk before you can run!!!

Have Fun
Roach
Thanks, guys, for your help and support. If only everybody in the world were like you. I''m going to hibernate for a while in the refereces you guys have pointed out. I''ll probably resurface once in a while with a question here and there.


Golthar - I''m pretty much only interested in getting the engine up and running (although sound and networking might come later). However, I would be really interested in seeing your code once it''s implemented. Thanks again! It''s kind of nice having a mentor looking over one''s shoulder :-)

This topic is closed to new replies.

Advertisement