Chipmunk and perfect bounce...

Nibbie
Posts: 3
Joined: 2009.03
Post: #1
hi people , i just want to create a perfect bounce using Chipmunk library;

I create a little wheel that collides againt a rect with INFINITY mass and e = 1.0f (elasticity parameter), i want the bounce to be perfect ; i mean that the wheel should come back after the impact with the same velocity in module but it collides it stops suddenly !!!

Where i'm wrong? what should i do to create a perfect bounce?
Quote this message in a reply
Moderator
Posts: 679
Joined: 2002.11
Post: #2
I had this issue a while back. You need to set elasticIterations to 5 on the space, if I remember correctly. I would give you more if I were inclined to look it up, but this should be enough to aid a quick Googling.

My web site - Games, music, Python stuff
Quote this message in a reply
Moderator
Posts: 452
Joined: 2008.04
Post: #3
Make sure that the wheel and the rect both have an elasticity of 1.0. I think Chipmunk multiplies them together.

From: http://files.slembcke.net/chipmunk/chipmunk-docs.html

"The amount of elasticity applied during a collision is determined by multiplying the elasticity of both shapes together. "

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2009.03
Post: #4
diordna Wrote:I had this issue a while back. You need to set elasticIterations to 5 on the space, if I remember correctly. I would give you more if I were inclined to look it up, but this should be enough to aid a quick Googling.

thank you so much ... i used space elasticIteration and it worked perfectly.

Just an other question Rasp when my wheel runs trought the space it should reduce its speed little by little. how can i reproduce this effect?
Quote this message in a reply
Moderator
Posts: 679
Joined: 2002.11
Post: #5
I think bodies have an angularVelocity attribute or something. I don't remember the exact name. You can multiply it by a constant less than 1 (like 0.9) every frame

I can't remember how to do time-based drag, so someone else should chime in on this.

My web site - Games, music, Python stuff
Quote this message in a reply
Moderator
Posts: 452
Joined: 2008.04
Post: #6
Yeah, angular velocity, or w. Multiplying it by .9 or similar every frame works well.

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2009.03
Post: #7
yeah, something like that:

Code:
cpFloat angularDamping = 0.05;
body->w *= (1.0-angularDamping);
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2009.03
Post: #8
sthaqu Wrote:yeah, something like that:

Code:
cpFloat angularDamping = 0.05;
body->w *= (1.0-angularDamping);

Where i put this code? tnx
Quote this message in a reply
Member
Posts: 89
Joined: 2005.06
Post: #9
Couldn't he just apply damping to his entire space?

Code:
space = cpSpaceNew();
space->damping = 0.01;

Well since everyone else is doing it:
Twilight Coders
CIMyAdmin
Whatever
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #10
You could, but then that affects everything which might not be what he wanted.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  UIScrollView won't bounce, and doesn't respond to touches consistently. groffhibbitz 0 3,202 Jun 3, 2009 11:30 AM
Last Post: groffhibbitz