ZFGC

Projects => Discussion => Topic started by: sjegtp on April 03, 2011, 05:01:32 pm

Title: Moving from 2D to 3D
Post by: sjegtp on April 03, 2011, 05:01:32 pm
Hello ZFGC! I haven't posted here for years, but this is something that has been bothering me recently.

I have done several 2D games in GM and C++/SDL, now I want to do something in 3D. I've started learning OpenGL and tried a few things, but I'm starting to think that programming 3D games at the low level (with OpenGL) won't be as simple as 2D was (with SDL). So I'd like to ask for some suggestions:

 - Do you use a particular engine to make 3D games? (Preferably something using C, C++ or Python)
 - What tools do you use to create animations, terrains, etc.? In what file format do you keep models and textures? How do you import and animate them?
 - Do you use effects like reflections, shadows, alpha blending, normal maps, Phong interpolation, etc.? (all of these seem to be a pain to make work in OpenGL...)
 - What about collision detection and physics? Do you use any techniques different from 2D?
Title: Re: Moving from 2D to 3D
Post by: Xiphirx on April 03, 2011, 09:50:12 pm
I wouldn't know much in this area, but I remember researching a bit about this a few years ago and Irrlicht kept popping up in my face. You may want to check it out :)
Title: Re: Moving from 2D to 3D
Post by: sjegtp on April 03, 2011, 10:33:54 pm
Ah yes, in fact before trying OpenGL I did a project with some friends in Irrlicht once, but I had several problems with that engine... It was too high level, I didn't have enough freedom to make it work the way I wanted, plus there were some compatibility issues. (OpenGL, on the other hand, seems to be too low level...)
But thanks for the suggestion :)
Title: Re: Moving from 2D to 3D
Post by: legendarylugi on June 02, 2011, 05:30:37 am
If it's not too late to respond, I'd like to offer my suggestions.

- Do you use a particular engine to make 3D games? (Preferably something using C, C++ or Python)

Well, you have several choices.

Unity 3D is an excellent engine, it supports C#, Boo (a Python implementation), and Javascript (or rather, a built-in scripting language that is syntactically based on Javascript). It's powerful, flexible, and is fairly simple to learn. It's also 100% free. Or rather, there is a free version available. This version is still quite full-featured, and the free license allows you to use it for commercial purposes if you plan on going that route. The paid version is pretty expensive, but more full-featured. You shouldn't have to worry about that for some time though, as again, the free version is still very powerful.

Another upside to Unity is it can build for most major platforms. You can publish games for Mac, PC, and even browser-based games with the free version of Unity. Certain paid versions of Unity can also publish for PS3, Wii, 360, iPhone, and Android.


Another fantastic free engine is Unreal Engine 3 (also known as Unreal Development Kit, or UDK). It's more powerful than the free version of Unity, but also requires more in terms of hardware to run. I can't speak to ease of use, having no personal experience with the engine, but I'm sure it's decent in that department. However, it only supports a scripting language called Unrealscript, so if you have a preferred language, you'll have to compromise on that. Again, this engine is *incredibly* powerful and totally free.

I'm sure there are other quality free engines out there besides those two, but none come to mind.


- What tools do you use to create animations, terrains, etc.? In what file format do you keep models and textures? How do you import and animate them?

Let's see, for creating 3d models, animations, and other assets, there are several packages out there. Most of them cost quite a bit of money, but some of them are free or have free versions available.

There's an open source, free modeling and animation tool out there called Blender, that supports most major modeling and animation formats. Its functionality is okay, but from what I can tell ease of use is not its strongsuit. The UI's a bit hard to work with (however, I hear recently it's gone through quite a major UI overhaul).

Then there are the commercial quality packages like 3dsMax  and Maya. These packages are quite expensive, but the manufacturer of those two apps, Autodesk, does offer a free version to college students.

There are several major file formats for storing animations and models. One industry standard for basic model storage is .obj(though I believe .obj doesn't support textures), and a popular format for storing models with animations is .fbx. Many apps support these formats. Maya also uses a pair of formats called .mb and .ma for storing files, and 3ds max also has a format I can't remember the name of right now.

Terrains can be modelled out in your 3d app of choice, but some game engines also have a toolkit for creating terrains in the engine itself. Unity has a built-in terrain system, and I'm fairly certain Unreal does as well.

Usually it's a better idea to animate your models in your modelling app, rather than in the game engine. Unity has the ability to create animations in the editor, but I far prefer to use Maya for this job and import them into Unity later. Although, Unreal apparently has an excellent cut-scene creating tool called Matinee.

When it comes to importing your assets, I'm sure the UI of whatever engine you use will help make it clear how to do that.

 - Do you use effects like reflections, shadows, alpha blending, normal maps, Phong interpolation, etc.? (all of these seem to be a pain to make work in OpenGL...)

Yes. :P All of this stuff is much, much easier to do using a game engine and 3d animation apps. For instance, Maya can generate normal maps automatically, taking a base mesh to apply it to and a detail mesh to get the normal information from, and applying this normal map in your engine should be easy. Phong interpolation comes down to a shader you can simply drag and drop onto your objects in your game engine. Reflections also comes down to built-in shaders, or even shaders you write yourself.

Unity doesn't support real-time lighting-based shadows in the free version, but Unreal does. However, the free version of Unity does support lightmapping to fake shadows, and I'm sure there's all kinds of stuff you could do with custom shaders to get proper shadowing effects.
- What about collision detection and physics? Do you use any techniques different from 2D?

Well, if you're using an engine, most of the low-level collision handling and physics code will already be written for you, and you'll simply be accessing methods and classes from the existing physics API.


I hope that was all helpful information. Let me know how it goes! Or, since this answer is a bit late, let me know how it went. XD
Title: Re: Moving from 2D to 3D
Post by: Walnut on June 02, 2011, 07:15:00 am
If I were you I would make a 2D game like Tetris or something in OpenGL to get a feel for it before jumping into 3D. Making a 2D game in OpenGL/DirectX is essentially the same as making a 3D game (Provided you don't use Direct2D, I don't know if OpenGL has an equivalent these days) only you render textured quads instead of whole primitives

You have to do a lot of the same groundwork but it makes it more manageable to learn when you're going step by step like that
Title: Re: Moving from 2D to 3D
Post by: Cassyblanca on June 02, 2011, 05:03:11 pm
(Provided you don't use Direct2D, I don't know if OpenGL has an equivalent these days)
Nope, you still have to do it through quad rendering.

I think LegendaryLugi pretty much summed it up, though the Torque engine line (http://www.garagegames.com) is also a great place to start looking.
Title: Re: Moving from 2D to 3D
Post by: TheDarkJay on June 02, 2011, 05:34:21 pm
I advise you learn to draw 3D things in OpenGL or DirectX. Get a book, get your head around the matrix maths, around the basics of the 3D models, around shaders (almost all 3D uses shaders nowadays, the whole matrix stack thing from the times of OpenGL 1.0 is outdated and deprecated), around the theory of how things like reflections are implemented. You don't need to remake the Unreal Engine, but I'd say it's best you have a rough idea what's going on if you decide to use the Unreal Engine...or the XNA engine, or the Irrlicht engine, or Unity or you get the idea ^^

Then again I do tend to advocate learning to swim with the sharks even if you just want to splash around with dolphins :)
Title: Re: Moving from 2D to 3D
Post by: sjegtp on June 08, 2011, 01:13:22 pm
Thanks for the answers! In fact I won't start making this game so soon, but I want to have things planned early.

@legendaryluigi:
I'll take a look on those Unity3D, it sounds interesting.

About the models and textures topic, I guess Blender has all the tools I need to design them, but I'm not sure how to implement them in a lower level language like C++, though it is good to know that engines fully support them.

Hmm... I suppose Phong Interpolation is simple to implement on a shader, but shadows not so much. I've seen tutorials using the stencil buffer from OpenGL to do them but it's quite... awful, certainly not the best way of doing it. Anyway, another point is that doing those effects (should) consume a lot of processing power, so simply switching on all of them in an engine maybe isn't the right thing to do, that's the main reason I'm asking this to you.

The problem with collision detection is that... usually the engines just detect the collision, don't tell you how to handle them. Making a good, smooth collision handling in 2D is already a pain, in 3D it must be challenging... that's why I'm kind of reluctant to use engines for that, it's hard to customize. There's also the bounding box problem, in 2D it is quite simple to do, in 3D... not so much, I suppose.

@walnut:
lol I actually did a 3D tetris game, with actual 3D pieces... it was terrible XD but doing a 2D game using OpenGL is not the point, it must be quite the same of doing it in SDL or another 2D rendering library, except that I'm doing more complex function calls.

@Minalien:
I've heard of that Torque engine before too, I'll take a look, thanks.

@TDJ:
Well, I've done a couple of things in OpenGL and Irrlicht, not much. But I think you're right, maybe I should first learn things properly, then I decide on what engine to use. And yes, I want to swim with the sharks :D
Title: Re: Moving from 2D to 3D
Post by: Cassyblanca on June 08, 2011, 03:15:10 pm
As far as the tools go, if you've got a .edu email address you can also take a look at all of Autodesk's products (Maya, XSI, and 3DS Max to be specific), which have free educational versions available (full features, just not allowed to do commercial releases of products containing them) at http://students.autodesk.com

As far as implementing them in an engine written in, say, C++, you'll need to load the file format and create the 3D mesh through that - that's going to differ based on your graphics engine/library. This is something you'll want to wait until you're more comfortable with 3D in general for, but you can find some information in the RasterTek Direct3D tutorial series (http://www.rastertek.com) (specifically, loading a Maya ASCII file, but the concepts are the same throughout). Most 3D libraries (Irrlicht, OGRE3D) have this built-in, and all 3D engines do the same.

As far as 3D collision detection, you'll usually use a library specifically built for this. Bounding box detection isn't much more difficult, there's just an extra dimension to check (using a 3D bounding box), but it's still easier and lest costly to use circular (spherical) detection as your initial sweep as all you have to do is calculate the distance between objects and compare it to a specified radius. From there, the method will differ vastly based on the needs of your game and the engine.
Title: Re: Moving from 2D to 3D
Post by: Kren on June 16, 2011, 03:21:25 am
you can always go and use XNA I found this book some days ago and found it really useful explain the basic of shaders and shows you how to do the basics. the book is "Learning XNA 4.0" by Aaron reed:

http://www.aaronreed.com/dnn/LearningXNA40.aspx
Title: Re: Moving from 2D to 3D
Post by: Cassyblanca on June 16, 2011, 04:17:09 pm
Reed's book is worthless - there are plenty of online tutorials (Including many on Microsoft's MSDN Create website (http://create.msdn.com)) and information that you can get for free, rather than wasting your money and time.
Title: Re: Moving from 2D to 3D
Post by: Kren on June 16, 2011, 10:21:33 pm
Reed's book is worthless - there are plenty of online tutorials (Including many on Microsoft's MSDN Create website (http://create.msdn.com)) and information that you can get for free, rather than wasting your money and time.
you can also get Reed's book for free >-<

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved