position prediction

ebingol
Posts: 2
Joined: Wed Mar 17, 2010 9:54 am

position prediction

Post by ebingol »

It is my first post here so i might be doing something wrong.

So i am trying to solve a future position of a ball(sphere).
I went through the bullets source code and try to solve for new position
I am assuming there is no collusion with any objects
The only force I have is the gravity and a force which is added to the current velocity
( i used applyCentralImpulse for pushing this ball or kicking to be more accurate)
I dont really care about y axis. (gravity applies to y)

by the time I run this code the ball has some linearavelocity.

I am not worried orientation, well it is a ball.

Here is the code:

Code: Select all


// I tried to get the totalForce() but it does not have the gravity included in it
// total force always returns a zero vector

btVector3 gravityForce = btVector3(0,-10.0f,0) * btScalar(1.0)/m_pBody->getInvMass()* m_pBody->getLinearFactor() * time;

btVector3  forceAddedVel = m_pBody->getLinearVelocity()+ gravityForce;
// The new damping functions
btVector3  damped=forceAddedVel * btPow(btScalar(1.0) - m_pBody->getLinearDamping(),time);

 //the predicted position is the balls position plus these two terms
FuturePosition=getPosition() + (damped) * time;
Is this the right way to do this. Any help would be great.