Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Aug 23, 2011 9:07 pm 
Offline

Joined: Tue Aug 23, 2011 8:56 pm
Posts: 2
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


Top
 Profile  
 
PostPosted: Wed Aug 24, 2011 12:03 pm 
Offline

Joined: Tue Aug 23, 2011 8:56 pm
Posts: 2
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:
Code:
               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;

                  }
               }


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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group