Trajectory preview

Please don't post Bullet support questions here, use the above forums instead.
gveiga
Posts: 3
Joined: Fri Apr 17, 2009 5:59 pm

Trajectory preview

Post by gveiga »

Hello guys, I'm new on Bullet and I'm wondering about how can I do a trajectory preview using the bullet physics. I've found the predictIntegratedTransform function on the btRigidBody, but it only calculates a point following the same velocity, direction, etc. without suffer any other physics influence from the environment. There is a way to turn it on, or am I in the wrong way for that? Any enlightenment will be welcome :D

Here is the code that I'm using for the trace function:

Code: Select all

void MainApp::TraceTrajectory(btRigidBody* body)
{
   btScalar timeStep = 0.0;
   btScalar totalTime = 10.0; // looking for a 10 sec preview
   btScalar totalFrames = totalTime * 10.0; // each sec will calculate 10 points
   btTransform predictedTrans;
   btTransform previousTrans = body->getWorldTransform();

   // cleanup my Debug Scene (it's used only for the trajectory preview)
   mDebugDraw->CleanupDebugDraw();

   for (timeStep = 0.0; timeStep < totalTime; timeStep += totalTime / totalFrames)
   {
      body->predictIntegratedTransform(timeStep, predictedTrans);

      mDebugDraw->drawLine(previousTrans.getOrigin(),
                           predictedTrans.getOrigin(),
                           btVector3(0.5, 0.5, 0.0));

      previousTrans = predictedTrans;
   }
}
Thanks,
Gilberto
gveiga
Posts: 3
Joined: Fri Apr 17, 2009 5:59 pm

Re: Trajectory preview

Post by gveiga »

Anyone?

Just to clarify, I'm willing to do a preview path, not the path that the object did on the simulation... A preview like the ones on the golf games, showing the parabola trajectory of the ball.

If the prediction is not possible I'm thinking about save the state of the simulation, process it to reach the equivalent to 5 secs. (not the 5 secs. at realtime), store the results and reload my scene back. Is it possible?

Thanks,
Gilberto Veiga