Members - Reputation: 128
Posted 14 May 2012 - 12:53 AM
Ive got a littile problem ... and feel confessed
Imagine a Solid Cube , free fallin on a sphere .
how can i descibe that ? how we can set openGL to simulate a gravity ? note that gravity is a ACCELERATED move
(sure we can use translatef and define a function to increas the amount of translation periodically )
the main problem is Collision !
the cube falls and i want it to be realstic . some little bounces and a realstic angular reactions . how is this possible ?
you can point me to this book as refrence :
OpenGL programming guid 7th edition , the official guide to lerning opengl 30 and 3.1 , dave shreiner , the khronos opengl ARB working group .
and the platfotm im workin :
Visual C++ Express edition 2010
and at last ... thanx
it will be really appreciated fellas
Crossbones+ - Reputation: 2920
Posted 14 May 2012 - 01:04 AM
First thing: get the idea out of your head. GL has nothing to do with that, does not care, and will never care.
Now, how do we solve the problem?
I strongly suggest the use of a collision/dynamics library ("physics"). I am personally completely sold on Bullet.
Members - Reputation: 677
Posted 15 May 2012 - 04:06 AM
so you've got a question "do A intersects B" ? you can imagine how to answer it. also you know that the answer is yes or no (boolean).
what to do with that answer ? -> "collision response". again, another field of research that is complicated by itself. sliding, bouncing, gripping etc..
you will need a good understanding of rigid bodies physics, inertia matrices and so on.
also, there is the simulation in itself, the motions (newton, euler), the integration over time, again, a whole filed in itself, there are many numerical integrators out there (eurler, verlet, runge kutta...).
there there are all the articles from Eric Cato (maker of Box2D), the gaffers on games by Glenn Fiedler about fixed time step game loops, which is related to physic simulation because the two are imbricated.
All in all, your question is very ligitimate, I asked it to myself once as well also. Tried implementing something with sphere vs triangle sweeped collision and sliding response in variable timesteps up to 4 iterations by graphic frame, but it was unstable, and had flaws where you would randomly fall through the ground etc...
doing it with a box is even more difficult.
the best answer to that problem, is really, use a library like ODE or Bullet. Read the documentation, you'll see how complicated a problem it is. Especially that thos elibraries are able to handle multiple objects intercollision with linear-time approximated mathematical solvers, which is, once again, a whole field of numerical science that is difficult to master if you don't have a degree in it...
Members - Reputation: 2083
Posted 15 May 2012 - 07:02 AM
Simulation and gravity are abstract things that doesn't exist in programming on the level you want to program (openGL is not so high level IMHO and especially it's not made for anything else than simple graphics). Simply telling a system to "simulate gravity" exists on engine (using physics libraries) level or scripting.
So at first, in my opinion, you should get experience with things like game loops and timing, game states, continuously running loop vs event based loop.
I think moving directly to physics simulation even with an engine would be a too big step without the said concepts.
Unless you use a complete package, where you just graphically throw things together, like ODE (if I recall correctly). But if you want to program it, either with using a physics library or without it is very hard if you don't have some experience with these concepts (correct me if I'm wrong, maybe there are libraries that does everything)
Edited by szecs, 15 May 2012 - 07:08 AM.