Creating Rigid Bodies

nierth
Posts: 4
Joined: Mon Mar 30, 2009 7:02 pm

Creating Rigid Bodies

Post by nierth »

Hello,

as an absolute beginner some of my questions may sound stupid, nevertheless I would appreciate it if someone bothers to answer me.
- after exporting an .obj file from Blender, I want to create a concave object. I have all the faces but don't know what to do with them now. I tried to use a triangleMesShape but don't know where to enter all the triangles.
- what does "localCreateRigidBody" exactly do? What is the difference to creating a rigidBody via a rigidBodyConstructionInfo?
- when creating the localInertia, what does the vector (mostly 0,0,0) exactly mean?

Thanks for your replies,

Thomas

EDIT: just to know: how did you learn Bullet? Only studying the examples (as I do at the moment) - or is there also a more efficient way?
nierth
Posts: 4
Joined: Mon Mar 30, 2009 7:02 pm

Re: Creating Rigid Bodies

Post by nierth »

another question: is it also possible to give objects an inertial speed?
Sorlaize
Posts: 18
Joined: Sun Mar 29, 2009 5:00 pm

Re: Creating Rigid Bodies

Post by Sorlaize »

nierth wrote:Hello,

as an absolute beginner some of my questions may sound stupid, nevertheless I would appreciate it if someone bothers to answer me.
- after exporting an .obj file from Blender, I want to create a concave object. I have all the faces but don't know what to do with them now. I tried to use a triangleMesShape but don't know where to enter all the triangles.
- what does "localCreateRigidBody" exactly do? What is the difference to creating a rigidBody via a rigidBodyConstructionInfo?
- when creating the localInertia, what does the vector (mostly 0,0,0) exactly mean?

Thanks for your replies,

Thomas

EDIT: just to know: how did you learn Bullet? Only studying the examples (as I do at the moment) - or is there also a more efficient way?
1) Use btTriangleMesh::addTriangle to add each vertex to a new btTriangleMesh, and then pass this to a constructor for a collision shape like btBvhTriangleMeshShape. The documentation says to use classes derived from btTriangleMeshShape.
The btTriangleMeshShape is an internal concave triangle mesh interface. Don't use this class directly, use btBvhTriangleMeshShape instead.
2) That's a demo helper function.

3) The inertia tensor is used internally by bullet, some collision objects(correct term?) need to have this set as 0 for example capsule-shaped character rigid bodies that we don't want to roll about in the simulation.

I'm not sure what you mean by inertial speed, I would try experimenting with constraints depending on what you're after, the demos should give good examples.
nierth
Posts: 4
Joined: Mon Mar 30, 2009 7:02 pm

Re: Creating Rigid Bodies

Post by nierth »

thanks for your reply, it helped me a lot.

After getting a little bit deeper into Bullet, another question occured:
- I added a btBvhTriangleMeshShape and a dynamic rigidBody (ball) to my world so that the ball should fall at the triangleMeshShape. Nevertheless, every time I run the simulation the ball just drops through it and I get the error message: warning btCollisionDispatcher::needsCollision: static-static collision!
I used the defaultDispatcher...

here is the important code snippet:

Code: Select all

	float startx=0, starty=1, startz=10;
	float radius=0.1;
	btCollisionShape* colShape = new btSphereShape(btScalar(radius));
	btTransform startTransform;
	startTransform.setIdentity();
	btScalar mass2(1.f);
	btVector3 localInertia2(0,0,0);
	colShape->calculateLocalInertia(mass2,localInertia2);
	startTransform.setOrigin(btVector3(startx,starty,startz));
	btDefaultMotionState *myMotionState2 = new btDefaultMotionState(startTransform);
	btRigidBody::btRigidBodyConstructionInfo rbInfo2(mass2,myMotionState2,colShape,localInertia2);
	btRigidBody* body2 = new btRigidBody(rbInfo2);
	body2->setRestitution(0.2);
	dynamicsWorld->addRigidBody(body2);


	btTriangleMesh *mTriMesh = new btTriangleMesh();
    btVector3 v0(-100,-100,0);
    btVector3 v1(100,-100,0);
    btVector3 v2(-100,100,0);
	btVector3 v3(100,100,0);
    mTriMesh->addTriangle(v0,v1,v2);
	mTriMesh->addTriangle(v3,v1,v2);
	btCollisionShape *mTriMeshShape = new btBvhTriangleMeshShape(mTriMesh,false);
	btTransform triTrans;
	triTrans.setIdentity();
	btCollisionObject *colObj = new btCollisionObject();
	colObj->setCollisionShape(mTriMeshShape);
	dynamicsWorld->addCollisionObject(colObj);
Sorlaize
Posts: 18
Joined: Sun Mar 29, 2009 5:00 pm

Re: Creating Rigid Bodies

Post by Sorlaize »

Actually I'm having that same problem at the moment: http://www.bulletphysics.com/Bullet/php ... f=9&t=3408

I'm not getting that error, does it stop the simulation?

In another thread it says to use a btGImpactMeshShape instead of btBvhTriangleMeshShape, for static vs static collision. But like you I only want to use 1 static object.

Yeah I'm just looking at the demo code, I've also used Havok which is similar in a way, so that helps.
Sorlaize
Posts: 18
Joined: Sun Mar 29, 2009 5:00 pm

Re: Creating Rigid Bodies

Post by Sorlaize »

Have you tried using collision groups/masks?
nierth
Posts: 4
Joined: Mon Mar 30, 2009 7:02 pm

Re: Creating Rigid Bodies

Post by nierth »

not yet...
Sorlaize
Posts: 18
Joined: Sun Mar 29, 2009 5:00 pm

Re: Creating Rigid Bodies

Post by Sorlaize »

Look at the character controller demo. You need to add collision objects to a group and give them a mask. These determine the other types of objects to collide with. Bullet wouldn't be very fast if it checked each object against every other object.