View Full Version : Translation problem
02-20-2004, 02:23 AM
I'm in the process of developing a snooker game and I'm having trouble with the movement of the snooker balls. I've no problem tracking where there supposed to be going and when a collision occurs but I can't seem to figure out how to control the speed at which the balls move.
For example i've got the start and finish vectors of the white ball but at the moment all that i'm doing is a simple translation from start vector to finish vector. How do I simulate a powerfull shot and a soft shot?
Appreciate it if anyone can help me out.
02-20-2004, 02:54 AM
Not really an advanced or OpenGL question.
For a snooker simulation your objects need to have a velocity and a normalized direction vector, damping of the table cloth, spin, maybe torque parameters.
The velocity and direction needs to be derived by rigid body collisions. Measure the time it takes to draw a frame and calculate the distance your ball travels in its direction in that time. Update the position for each frame. Simple as that.
Search the internet for rigid body collision formulas.
02-20-2004, 02:55 AM
Frame rate independent animation is what you're looking for.
You need a direction vector, the current speed of the object and the time that has passed since the last frame.
The first two can conveniently be combined into a velocity vector. The time you'll have to measure. QueryPerformanceCounter is one of the more obvious ways to measure time (on Windows systems) and is sufficiently accurate for animation purposes.
Now, say your object has a current position P and a velocity vector V.
Then you'd do
}This is only basic movement. In practice, velocity should be a function of acceleration and, again, time.
02-20-2004, 03:45 AM
I'll transfer this to the math & algorithms forum, where this discussion is more appropriate.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.