test
test..\..\bin\BulletWorldImporter_vs2010_debug.lib
..\..\bin\BulletFileLoader_vs2010_debug.lib
..\..\Extras\Serialize\BulletWorldImporter
#include "btBulletWorldImporter.h"
btBulletWorldImporter* fileLoader = new btBulletWorldImporter(dynamicsWorld);
printf("loading file.\n");
const char* fileName = "C:\\Users\\Lenovo\\Desktop\\alibakh\\mybullet\\data\\slope.bullet";
//const char* fileName = "C:\\Users\\Lenovo\\Desktop\\alibakh\\ground.bullet";
//const char* fileName = "C:\\Users\\Lenovo\\Desktop\\alibakh\\wreckingBall.bullet";
//const char* fileName = "C:\\Users\\Lenovo\\Desktop\\alibakh\\2SpanWreckingBall.bullet";
bool ok = fileLoader->loadFile(fileName);
if (!ok)
{
printf("Error loading file %s.\n", fileName);
exit(0);
}
printf("access rigid body properties\n");
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");
}
printf("access the hinges and it's properties.\n");
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());
}