Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jan 27, 2014 5:00 pm 
Offline

Joined: Tue Nov 05, 2013 8:51 am
Posts: 5
Hi there,

After exporting a scene in Blender into .bullet file format according to this, I load the respective .bullet file in a simple application following the serialization wiki:

Code:
btBulletWorldImporter* fileLoader = new btBulletWorldImporter(dynamicsWorld);
fileLoader->loadFile("h:\\testFile.bullet");


Question: how can I access rigid body parameters (like mass, dimensions, inertia etc.) in the Bullet world inside my program?

Thanks,
R


Top
 Profile  
 
PostPosted: Tue Jan 28, 2014 3:29 am 
Offline

Joined: Sun Jul 03, 2005 4:06 pm
Posts: 871
Location: Kirkland, WA
I would guess after import you can access the rigid bodies, joints, and shapes from the world interface and iterate all the information you need.


Top
 Profile  
 
PostPosted: Tue Jan 28, 2014 6:13 pm 
Offline

Joined: Tue Nov 05, 2013 8:51 am
Posts: 5
I've managed to access rigid body properties via the following lines:

Code:
for(int i=0; i < fileLoader->getNumRigidBodies(); i++)
{
   btCollisionObject* obj = fileLoader->getRigidBodyByIndex(i);
   btRigidBody* body = btRigidBody::upcast(obj);      

   // properties
   printf("  object name = %s\n", fileLoader->getNameForPointer(body));   // The Blender object name
    printf("  get position = (%4.3f,%4.3f,%4.3f)\n",
      body->getCenterOfMassPosition().getX(),
      body->getCenterOfMassPosition().getY(),
      body->getCenterOfMassPosition().getZ());         // Blender CoM
   printf("  get local scaling = (%4.3f,%4.3f,%4.3f)\n",
      body->getCollisionShape()->getLocalScaling().getX(),
      body->getCollisionShape()->getLocalScaling().getY(),
      body->getCollisionShape()->getLocalScaling().getZ());      // Blender Dimensions
   if (body->getInvMass() == 0)
      printf("  static object\n");
   else
   {
      printf("  mass = %4.3f\n", 1/body->getInvMass());      // Blender Mass
      printf("  get gravity (z!) = %4.3f\n", body->getGravity().getZ());   // Blender Gravity
   }
   printf("\n");
}


I still don't know how to access the contstraints (i.e. hinges) after importing the .bullet file. Any thoughts on that?

Cheers,
Rob


Top
 Profile  
 
PostPosted: Thu Jan 30, 2014 3:13 pm 
Offline

Joined: Tue Nov 05, 2013 8:51 am
Posts: 5
short Update:
I've managed to access the hinges and it's properties:
Code:
for(int i=0; i < dynamicsWorld->getNumConstraints(); i++)
   {
      btTypedConstraint*   constraint=dynamicsWorld->getConstraint(i);
      printf("  constraint type = %i\n", constraint->getConstraintType());
      printf("  collision shape type = %i\n", constraint->getRigidBodyA().getCollisionShape()->getShapeType());   
      printf("  get partA axisVector (part of quaternion) = (%4.3f,%4.3f,%4.3f)\n",
         constraint->getRigidBodyA().getCenterOfMassTransform().getRotation().getX(),
         constraint->getRigidBodyA().getCenterOfMassTransform().getRotation().getY(),
         constraint->getRigidBodyA().getCenterOfMassTransform().getRotation().getZ());
      printf("  get partA CenterOfGeometry = (%4.3f,%4.3f,%4.3f)\n",
         constraint->getRigidBodyA().getCenterOfMassPosition().getX(),
         constraint->getRigidBodyA().getCenterOfMassPosition().getY(),
         constraint->getRigidBodyA().getCenterOfMassPosition().getZ());
      
   }

Although I still can't find a way how to access a constraint's related rigidbodies names (i.e. hinge->rigidBodyA->name and hinge->rigidBodyB->name).

Any thoughts on this?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
Powered by phpBB® Forum Software © phpBB Group