Ball Bouncing

mmurphy
Posts: 4
Joined: Sat Nov 26, 2011 12:12 am

Ball Bouncing

Post by mmurphy »

This is kind of two questioner, but related.

In the HelloWorldApp, the object 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?
mmurphy
Posts: 4
Joined: Sat Nov 26, 2011 12:12 am

Re: Ball Bouncing

Post by mmurphy »

Is there perhaps a better place to ask this?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Ball Bouncing

Post by dphil »

mmurphy wrote: In the HelloWorldApp, the object 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?
In the current version of the Hello World tutorial I see, it is already using btStaticPlaneShape, not btBoxShape: http://bulletphysics.org/mediawiki-1.5. ... ello_World
mmurphy wrote:How can I set custom restitution, static and kinetic friction per object?
Check the API Reference:
btCollisionObject::setFriction(btScalar frict)
btCollisionObject::setRestitution(btScalar rest)

Alternatively you can set these values in the btRigidBodyConstructionInfo when the object is set up (rbci.friction = ... , rbci.restitution = ... ).
mmurphy
Posts: 4
Joined: Sat Nov 26, 2011 12:12 am

Re: Ball Bouncing

Post by mmurphy »

dphil wrote:
mmurphy wrote: In the current version of the Hello World tutorial I see, it is already using btStaticPlaneShape, not btBoxShape: http://bulletphysics.org/mediawiki-1.5. ... ello_World
Interesting ... it appears that either the doc or the source is out of date (I have 2.79, which I downloaded about two weeks ago).
dphil wrote:
mmurphy wrote: Alternatively you can set these values in the btRigidBodyConstructionInfo when the object is set up (rbci.friction = ... , rbci.restitution = ... ).
Ah, I must have missed that. The reason I was asking is because for some odd reason, when the ball will hit the box it will just immediately stay there, and never bounce. Do you happen to know of any off chance why this may happen?

Also, I could look into where the collision event is resolved/reported. I do not see where that is though, would you be able to clue me on where that is happening?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Ball Bouncing

Post by dphil »

Hm, you're right. I just tried it out and the sphere bounces nicely on a plane, but only a little bit or not at all when dropped on a box shape (with the exact same rigid body settings as the plane). Offhand I don't know why...though I seem to recall this being discussed before. I know other people have had issues with restitution behaving oddly at times.

[quote=mmurphy]Also, I could look into where the collision event is resolved/reported. I do not see where that is though, would you be able to clue me on where that is happening?[/quote]
I'm not exactly sure; I don't normally dig into that part of the engine, so maybe someone else can help. My naive approach would be to start in btDynamicsWorld's stepSimulation function and go from there, following the relevant-looking calls.
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Ball Bouncing

Post by Mako_energy02 »

I don't really have an answer to this per-se, but I've seen both others on this forum and from my own experiments that some behaviors...friction and restitution especially can vary greatly from the use of one shape to another. As best I can tell this has to do with the different collision algorithms that get set for a given pair of objects which are based on the shape rather then the body.

Usually box shapes are the most reliable. So there being a problem with boxes is a little surprising.
mmurphy
Posts: 4
Joined: Sat Nov 26, 2011 12:12 am

Re: Ball Bouncing

Post by mmurphy »

Does anyone else possibly know why I might be having this issue?