Archived

This topic is now archived and is closed to further replies.

3D Engine from scratch

This topic is 6031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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 :-)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 :-)

Share this post


Link to post
Share on other sites
Dunno if this post is still going or not, but here are my two cents (maybe three):

1. Read, read, read.
2. Implement whatever cool techniques that you learn, so you can see if they are really worthwhile or not.
3. Check out other people''s engines.

That is a pretty short list, but you get the idea. Also, my OpenGL Game Programming tutorials are basically going to guide people through creating an entire engine (without knowing it ), so that should be a pretty decent reference once it gets farther along.

------------------------------
Trent (ShiningKnight)
E-mail me
ShiningKnight Games (I had to make one up, to fit in with the rest of you )
Project: Writing tutorials and code for my OpenGL Game Programming series
OpenGL Game Programming Tutorials

Share this post


Link to post
Share on other sites
Sure thing freyr :-)

The source will be open source when we produce some more stable code.
They are right, keep reading, you can never learn too much.

You can contact me if you need my help

Share this post


Link to post
Share on other sites
From what people tell me, the book ''OpenGL game Programming'' teaches you all about OGL and then walks you thru building an FPS engine.

I am probably going to pick this book up soon.

I have the same question as freyr. I have been learing alot lately and I just want to find out how to put all the pieces together to make an engine and how an engine works.

Thanks,

Eastwood

Share this post


Link to post
Share on other sites
Here goes...
I''ve been reading up on BSP trees and Portal engines. As I gather it BSP trees are good for implementing no overdraw, and that they work well for static environments, like in Doom. What happens when you have a dynamic environment like Quake. Since the BSP tree is generated beforehand, is it of any use in rendering moving 3D objects (e.g platforms or models)? What''s the alternative?
If I understand portals right then they are used to minimize the amount of non-visible polygons drawn. What happens if I have a dynamic portal? (e.g. a moving window) How about if I want to allow the players to be able to destroy walls? Is it possible to create new portals on the fly?
I know I''m probably jumping way ahead of myself but I find that the more completely I understand the limitations of something the easier it is for me to use it.
Thanks!

Share this post


Link to post
Share on other sites
Actually the levels in DOOM where every bit as 'dynamic' as in Quake. They had moving parts, like doors and elevators (much as in Quake). In Quake the static parts of the world are stored in a big BSP tree and all moving parts (elevators and such) are stored in small separate BSP trees that are merged with the big one in real time. Enemies and such are not stored in BSP trees at all (simple triangle lists I think).

As far as I recall BSP trees generally generate lots of overdraw while portals (can be made to) generate zero overdraw.

Also BSP trees can be used for alot of things other than hidden surface rejection and rendering; such as collision detection.

Edited by - Dactylos on June 11, 2001 10:47:10 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
it''s going to be alot easier to make an engine for a game than it is to build an engine for an engine''s sake...

my only advice, spend as much time thinking about, researching and documenting the exact feature list and logistics of your application as you do coding, testing and debugging it.

do this FIRST. don''t just dive in and start writing code, you''ll walk away with a redo that summer vacation won''t allow.


good luck, have fun,

-anon

Share this post


Link to post
Share on other sites