I am currently using a custom btMotionState to get the location and rotation data of an object when it has moved. I was wondering if there is any way to utilize btMotionState to also retrieve other properties such as velocities so I can ultimately serialize the objects to a database once they have been updated. If this is not possible, should I iterate through all of the btDiscreteDynamicsWorld objects and see which active objects have moved?
I am hoping that I can use the btMotionState because it was so easy to setup, but I don't think that is a possiblility....
Thanks so much for your time,
Dan
Question: custom btMotionState and serializing objects
-
- Posts: 2
- Joined: Tue Aug 23, 2011 8:56 pm
-
- Posts: 2
- Joined: Tue Aug 23, 2011 8:56 pm
Re: Question: custom btMotionState and serializing objects
I have created a simple loop to iterate over all of the objects in the btDiscreteDynamicsWorld after I step the worl and use the btDefaultMotionState. Here is what I do:
Is this the best way to iterate over all of the active objects in the dynamicWorld? Also does this mean that I am ultimately iterating over all of the objects twice to see if they are active because the btMotionState checks for active objects and then I check for them?
Thanks for your time,
Dan
Code: Select all
dynamicsWorld->stepSimulation(1/60.f,10);
for (int i=dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->isActive() && body->getMotionState())
{
btTransform trans;
body->getMotionState()->getWorldTransform(trans);
btVector3 velocity = body->getLinearVelocity();
std::cout<<"vy: "<< velocity.getY()<<std::endl;
}
}
Thanks for your time,
Dan