Ogre game programming using TDD - c++

I'd like to ask you if it's worth it to use the TDD concept while creating a 3D game in C++ with Ogre? I know I can use it while creating my algorithms (like path-finding, AI, paging, etc.) and the game logic, but can it be used to test the drawing side? I mean if the proper objects are drawn, if the proper animation is set & used and a lot of other "things" that I don't want to enumerate.
I've been searching about it for days but I haven't found the answer that I can accept.
Basically which part of game development should be done with TDD and which part not? Does 3D game development need TDD?

Ogre uses so many Singletons and other global state, I find it difficult to see how you could implement meaningful tests for it- even ignoring the difficulty of testing the accuracy of a rendered image.

Related

Basic 3D OpenGL collision detection C++

I'm currently in the process of developing a very basic 3D OpenGL game in C++ as part of a small college project. We don't get a lot of insight from the teachers however, and only very limited documentation, as well as a small timeframe, so I'm kind of a little lost here at the moment.
My game is a tank battle on an orthogonal plane that pretty much looks exactly like the image I sketched below. Each tank (A and B) can be controlled by a different player, and each one can shoot projectiles, which are supposed to influence the other tank's score upon collision.
My question is, what would be the simplest way of effectively implementing collisions for the tanks? (Tank vs tank, tank vs map boundaries and tank vs any kind of parallelepipedic object like the one in the center of the picture - and the same thing but applied to the projectiles shot from the tank turrets).
Ideally, without the need of using an external physics engine, but also accepted if the implementation can be done easily. At the moment, I'm solely using the GLUT library.
Download and integrate Box2D (http://box2d.org) into your project.
Unless your project is to implement a physics engine, then don't bother doing it yourself. Your time will be much better spent learning how to integratate libraries and how proper physics engines work.
You can then easily use a box collider for your tanks, circle for projectiles and 4 lines for your perimeter. You can create callbacks to notify you when a projectile has collided with another tank.
You will have to use forces and torques to move and rotate your tanks, rather than just updating their positions. But you would probably have to do that anyway if you were going to implement the physics yourself.

C++ using animations from Flash or similar

I want to program a game, and I want to do it in C++, because everyone seems to agree this is the best way to program a game. What I really want, though, is the ability to animate something, swap images around during runtime, and retain the animation. Also, the ability to pin graphics to certain parts of other graphics, or group graphics together. I know for sure Actionscript and Flash can do both of these. It's especially easy in Flash because I can visually see the animation and swap symbols via Actionscript to change it to what I want at whichever frame I want. Now, I know that it's fairly simple to swap images during runtime in C++ as well, but in C++, (from my understanding) I would have to animate via code and I would have to manually move each graphic separately for the graphics to stay together. Is there's a way where I can animate in Flash, then use those animations and swap images in C++? Or, if there's some other way to accomplish the same thing, without using Flash? (don't mind using bitmaps)
I think maybe you should just program your game in Flash and ActionScript, if you're already experienced with those tools and your game can fit in them. Programming a game in C++ is a difficult and complex task, necessary for difficult and complex games but often overkill for simple and fun design. If you just want to design games, go with the simplest tool that lets you make your prototype!
If your game is too big to implement in Flash, consider using XNA, or a prebuilt game engine such as Ogre or Unity. XNA is in C♯ but even that is good enough for any game that a one-man team could build.
Scaleform lets you embed Flash in a C++/DirectX game, but as you can see it is rather complicated to employ. We have one engineer and three artists dedicated full-time to Scaleform UI on our project, to give a sense of how much work it is.

Finding the right tools for programming a futuristic-styled UI project

I've always been inspired by dynamic, futuristic-like user interfaces. The best I can describe is a graphic interface such as in the latest Iron Man movies.
Although I wouldn't build a full blown application, I would like to make little snipplets of animations that I plan to make interactive. And maybe put them together someday to make something bigger. Admittedly, I will use for audio manipulation in the future but anyway, that's not the point since it's the animations/graphics I'm unsure of.
I know it's possible to make those kind of animations in Adobe After Effects. I'm just having a hard time thinking of the processes (artistically and programmability) to proceed.
While researching on this on my own I have acquired basic experience with OGRE 3D and Blender. I've imported and compiled meshes on OGRE, have been able to do basic things like move the meshes around which is about it.
I'm beginning to think I may be approaching this the wrong way and there are better tools or if 3D is overkill for those kind of animations when 2D would suffice and maybe provide a smoother experience.
I'm having trouble understanding the process and am wondering two things:
1.)The main thing I'm having trouble understanding is how to get still graphics to make animations? Do the meshes keep the timeline from a program like Blender then a graphics engine like OGRE reads the timeline and plays them?
Most importantly:
2.)Do I even need graphics (meshes)? Most of the interface are thin-border boxes, text and shapes of transparent LED-like colors that can move around dynamically to make that futuristic effect.
Please share your opinions, suggestions and anything you think might help me accomplish to develop those kinds of sexy eye candy! Thanks.
When you look at awesome futuristic UIs in movies, they are usually made of
basic primitives
desaturated colors, and/or one color tone
transparency
a cool font or two
high-tech text, graphs or similar
simple animations to make things look "alive", blinking lights/text and similar
a touch interface, of course
Maybe you can't do a lot about the touch interface, but the rest is really not hard graphics wise, it's a matter of carefully crafted artwork and combining simple elements in a cool way.
Also I would look into Adobe Photoshop and fancy texturing rather than Blender and fancy modelling, as you are looking for a fancy 2D UI, and detailed 3D models will not be that important. Playing around in photoshop (well, or GIMP if you want a free alternative) can help you develop your art skills, and help you get that high-tech, sci-fi look on a 2D surface.
You know, I would go as far as to suggest making some sci-fi wallpapers in the style you are after before trying to solve this problem in code. I think you will find that photo manipulation skills and an eye for art will help you here. And for gods sake, look at those movies (Iron Man, Minority Report etc.) that have those UIs you are aiming at, and analyze what exactly they are. Decompose them like I did in the list above.
As for the "which tools should I use?", I say the answer to that is fairly simple:
OpenGL
Photoshop (or GIMP if you are a starving student etc.)
A compiler & toolchain
A code editor/IDE
A cup
I see this is tagged C++, which is an excellent choice of programming language if I may say so.
Ogre is a full blown 3D engine, which is fine, but not exactly targeted at what you want to use it for. You might find that you struggle to get what you want done (disclaimer: I have not tried this in Ogre, and it might work well for this. Then again, when did you last see Ogre used in an audio manipulation program?). My advice is to learn good, simple OpenGL. That would give you complete power over your UI, not get in your way or limit you in any way. It is also cross platform, well documented, and used by tons of developers all over the world (also for audio manipulation applications). I can't see how you could possibly go wrong with it. The fun part is that it probably won't take you long to get advanced enough in it to start developing some pretty nice UIs. As I mentioned, it's more of an art problem than a coding problem.
The cup is for the coffee, by the way. :)
The easiest and most efficient way is to keep track of all your graphics data (meshes, animations, effects) in "media files" and load & play them in runtime. Though you'll be able to easily change your game without changing the code.
For example, you have a Diablo-like game and you wanna turn it to the future-style. You just need to rewrite some player and AI scripts and modify meshes/effects/sounds/animations. But if you've done those via code - it will be a new game from scratch.
I would suggest Ogre, but you already used that, so by my opinion, you are on the right track.
Look up 'billboards' in Ogre documentation, re: LED and 2D stuff.

Creating effects in 3D game from scratch, using c++ and DirectX

So the title says it. I couldn't find any info on how actualy build effects into 3D game. I'll maybe stick to some engine later, but for understanding of this whole thing I would need to try it on my own for this time. I found a few about particle systems which may be the right way but any other connection between DirectX and particle systems on google gave results as 3DSmax and etc.
So I would be thankful if you would point me on some tutorials for this, or explaining it...
Last possibilitie would be pointing me on some simple engine focused on this thing (I don't really want to fight through tons of code and understanding how this engine works, I just need to see how they implement this FX stuff).
Thanks
PS: the other possibilitie would be if you know about good book discusing this. It can be more complex but apart from tutorial, books are usually wrote more basicly so this would be also nice way to go
First of all: particle effects are just one kind of effects, it's better you specify the word particle engine :p.
Secondly: search int he articles of Gamedev, it's really the best resource if you want things like this. You can find lots of articles and even better, tons of links, and useful information on the discussion boards. Two articles I can link to is the NeHe lesson about particles in OpenGL, it's not directx but NeHe tutorials for OpenGL are very good. I also found one for directx8 and VB (so a little bit older).
Keep in mind though that a particle engine is often a huge performance hit if you can't optimize it yourself, so try to look at open source game engines (e.g. OGRE) on how they implement it or even better, specific particle engines.
So I would be thankful if you would point me on some tutorials for this
You need to download microsoft DirectX SDK.
In addition to it, you should try NVidia SDK.
You may also try ATI SDK. Study them all.
In addition to them... there are couple of books on OpenGL: "Red Book", "Blue Book", Orange Book . "Computer graphics using OpenGL" by Francis Hill is also a very good one.
Get this info, and start reading.
how actualy build effects into 3D game
This question is too broad. There are lighting effects, particle systems, post-processing effects, physics (which are also effects), and even character animation is an effect. It is unclear what kind of effects you are talking about.
What do you think is better DirectX or OpenGL.
They are more or less equal. You can do same things in both of them. Try both and pick one you liked more. OpenGL is better for playing around and experimenting (because you can easily draw triangle without messing with hardware buffers), available on larger selection of platforms, plus GLSL is better than HLSL (because it doesn't "compile into assembly"). DirectX is geared towards performance from the beginning, available on XBox360, and 9th version was actually good. openGL is more "abstract" and DirectX is closer to hardware.
If you could use the factors as simplicity, area of usage, performance, number of examples and resources etc
If you want simplicity, you should forget about making game engine. You'll have to learn quite a lot of things if you want to deal with 3D.
Both DirectX and OpenGL are used for making 3d-related products.
You can get good performance with both DirectX and OpenGL, and get poor performance if you don't know what you're doing.
Both DirectX and OpenGL have insane amount of examples and books - just search for it. They weren't made yesterday, so enough information is already available.
You need to select goal, select platform, select your API, research available technologies, and start writing code. Wondering "which one is better" is a waste of time. 3D knowledge and algorithm are equally applicable to both APIs.
OpenGL is the best bet to learn I feel. Glut is available free of cost and has all the functions you need to implement a particle engine. Plus theres loads of sample code online. I like the way functions are . Easy to remember and use logically
The best books for learning D3D9.0c/D3D10 are by Frank Luna. Just put him in to amazon or google and you'll get results. He teaches how to build a fully-fledged game engine from scratch.

I want to make a simple 3D game using openGL, where should I start?

I find that I learn best by example. Is there a good website or codebase that shows how event handling, collision detection, modeling, and basic 3D drawing works?
The game I'm trying to begin with is a simple racing game where the user controls a small space ship and navigates through channels, asteroid fields, space colonies, and various other obstacles (I know, real original). Movement is in 3 dimensions. The game should know when the shuttle hit an obstacle. There are defined tracks as there are in most racing games (circuits and linear paths).
Pressing the arrow keys should cause the direction vector to rotate appropriately. Also, the ship should use something like an afterburner when the user presses the space bar, for example. Movement up and down is also an option.
If you want to learn OpenGL, I recommend starting with "OpenGL Red Book", and then looking at NeHe's samples. Red Book is free at least in online HTML format, there are also downloadable PDFs around.
However, Red Book and NeHe will teach you mostly how to use OpenGL; writing games is art, and there's far too much to explain, far too much to learn, and far too much to read about it. Here's just a tip.
This is basic structure of most games. Hopefully it helps with basics. Of course it's not a full game, won't run, and greatly depends on how you do things, but it should give you a basic idea.
void update(float k)
{
// k == time in seconds since last update; e.g. 0.02
ship.y += ship.speed_y*k;
}
int main()
{
while(1)
{
if(hasEvents())
{
event_t evt;
getEvent(&evt);
if (evt.type == keypress && evt.key==down)
{
ship.speed_y=1;
}
}
paint();
new_ticks = get_ticks();
update((new_ticks - old_ticks)/1000.);
old_ticks = new_ticks;
}
}
Not knowing your initial skill level I suggest you taking a look at Ogre3D. It is a complete 3D-rendering engine that has really clean interface to work with, easy to extend and best of all, it's quite multiplatform working on Windows, Linux and Mac OS X. The examples and tutorials provided are pretty self-explaining.
If you want to write your own OpenGL-only engine completely from scratch, Ogre3D may not be the path to follow...
A couple of notes, some of which have already been stated:
The OpenGL Redbook. An excellent place to start. The book has seen several revisions, so the free online version is a bit dated by comparison.
GameDev.net. They are a wonderful resource for developers of all experience, and they have a lot of talented people on the forums. They have answered the question, "I want to make a game, where do I start?" many, many times.
I do not recommend NeHe. I find that the tutorials there, more often than not, confuse a neophyte. The tutorials show "how", but do very little to explain the crucial why.
Game development is a huge multifaceted discipline. It's challenging even if you have very solid math and programming skills.
Two pieces of advice:
Start small. Start small. Start small. You might think your goal is pretty modest, but it will involve a great deal more than you imagine.
Avoid the temptation to cut and paste example code. You will cheat yourself out of crucial understanding.
NeHe
This site helped more then anything when I was learning opengl.
I must give a warning for using nehe because many people have recommended it.(don't have an account to make comments, sorry)
Mainly because it only shows how to do things with the fixed pipeline instead of shaders. The first couple of tutorials might be ok the get a kickstart of how to get something on the screen. But don't waste your time with for example learning how to activate alpha blending and setting up lighting for the fixed pipeline, because if you want to do something that doesn't look like a game from 1999 you will have to relearn how to do all that stuff again but with shaders. Better to learn the new way from the beginning imo.
Firstly, I don't recommend using OpenGL for your first game, especially if you've never programmed before. You should strongly consider the newer and easier methods like XNA with C#.
Secondly, like OpenGL, XNA also has a large number of tutorials on the Internet, which I believe you will find very helpful.
If you've never done programming before, I recommend as a starting project, you should try creating a very simple game like Pong, or Tic Tac Toe. I think you will get a good feel of game development in general. From there, you can start on your actual project from the experience you've gained by creating Pong.
Lastly, the main piece of advice I can give you as you adventure on your quest is to never give up no matter what obstacles you face in creating your game.
Good Luck! ^^
I've no idea how much game programming experience you have, but I'd start with something a bit more limited.
Start with a 2d tile-based game (Sokoban etc) - they're relatively easy to write - something where the objects are always exactly on a tile, that makes things pretty trivial.
Once you've got the principles of that, game loop, timing, processing user input, data model, renderer etc, then you can do something more involved.
Then you can try something like "Asteroids" which is going to need some 2d vector maths, modelling intertia (i.e. integration) possibly a bit of trig. and a non-tile based collision system.
Once you've got that licked, then you can try something 3d - which makes things more complicated again, maths-wise.
I would look around on www.gamedev.net, it contains some excellent tutorials for beginners and in the forums you'll find a great deal of information on any subject related to games programming.
First, you should think about the structure of your code. Every game ever has some variation of the following:
int main()
{
Screen::Init();
Game::Init();
while (Game::isrunning)
{
Game::Update();
Screen::Render();
}
Game::Shutdown();
return 0;
}
The rest just becomes an implementation detail. Try looking at SDL, it handles a lot of the nasty things of Windows programming (initializing a window, loading OpenGL, etc.) so you can focus on writing your game.
Yes, look up tutorials online. Yes, hang out at GameDev.net. Yes, NeHe is confusing and specialized.
For OpenGL, I would combine the OpenGL SuperBible's ability to make one aware of the context and possibilities of OpenGL with a good old-fashioned Google search.
It also helps to know someone who can help you out from time to time. GameDev.net has chatrooms and the people are friendly.
If you want opengl but with the simplicity of python - which could be nice to understand the principle of the API at first - check out the wrappers : http://pyopengl.sourceforge.net/
They are compatible with the latest version of opengl and their development is quite active.