Bouncing ball in Bullet

2019-05-22 20:03发布

I have two questions with regards to Bullet, but they are related.

In the HelloWorldApp, the objective is to get a ball bouncing on a box right? If I wanted to test a plane, could I just add in a btCollisionObject with a btStaticPlaneShape instead of the box?

How can I set custom restitution, static and kinetic friction per object?

1条回答
手持菜刀,她持情操
2楼-- · 2019-05-22 20:42
  1. Yes, I believe that should be correct
  2. Restitution and friction can be set per object by supplying them to the btRigidBodyConstructionInfo object passed into the btRigidBody constructor

For example:

btBoxShape * box = new btBoxShape(0.5f,0.5f,0.5f);
btVector3 inertia;
float mass = 10.0f;
box->calculateLocalInertia(mass,inertia);
btRigidBodyConstructionInfo info(10.0f,null,mass,inertia); //motion state would actually be non-null in most real usages
info.m_restitution = 1.3f;
info.m_friction = 1.5f;
btRigidBody * rb = new btRigidBody(info);
查看更多
登录 后发表回答