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
In OpenGL? It is simply not possible. Just like it is not possible in any graphics API, unless integrated in a middleware. I don't understand why people working on this keep on insisting on the concept of "set API_OF_CHOICE_HERE to simulate gravity". 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.
collision is a geometry problem, that is complex to solve. especially complex when solved in a "sweep" manner. (google "sweeping volumes") there is a log of academic research on this. Most physics library does not compute collision but intersection rather. So if you have a huge movement during one time step, some collisions could be missed. that's life.
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...
Based on your question and how you expressed it, your level of knowledge/experience may not be enough to solve this thing yet. 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.
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)