i am having a problem with the collisions here. I need to know the collision force to determine if i have to play a sound or not.
in my postSolve i am using cpArbiterTotalImpulse to get that. but it always returns 0,0 when letting a ball go and colliding with another one. If i drag one into another it does return another values.
Looking into the function on debug, con->jnAcc is always 0 so that is the problem i guess, the thing is i don't know why this happens. Any ideas?
kinetic balls
-
- Posts: 22
- Joined: Mon May 18, 2009 7:31 pm
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: kinetic balls
Unfortunately, enabling elastic iterations changes how the solver caching works. I haven't figured out a good way to make it work nicely with it. If you set elastic iterations to 0, it will use a single iteration pass to solve both the elastic and non-elastic collisions, this might turn out OK (though they aren't going to rest against each other as nicely) and will allow you to get the correct impulse.
From the documentation:
From the documentation:
Another possibility is simply to get the relative velocity of the two bodies and use that to guess the collision impulse. Because the balls are hanging from joints, they should always be hitting straight on with each other anyway.Returns the impulse that was applied this step to resolve the collision. Calling this function outside of a postStep callback function is undefined. Enabling elastic iterations will cause you to get incorrect results, this is a known bug.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 22
- Joined: Mon May 18, 2009 7:31 pm
- Contact:
Re: kinetic balls
Yes, it is true, i set elastic iterations to 0 and it works fine. thanks
Another test case. if i drag 2 balls and let go, most times the simulation is wrong. In real life 2 balls push the 3 remaing and then when they go back they push the other. So you always have 2 and 3 balls moving evenly.
In the simulation it is like the 2 balls hit the middle one and it pushes the 4th and then the 5th. so the 3 move at different paces and the last one separates. then when they come back it messes up.
What could this be?
Sorry for all the questions i don't know much about physics
Another test case. if i drag 2 balls and let go, most times the simulation is wrong. In real life 2 balls push the 3 remaing and then when they go back they push the other. So you always have 2 and 3 balls moving evenly.
In the simulation it is like the 2 balls hit the middle one and it pushes the 4th and then the 5th. so the 3 move at different paces and the last one separates. then when they come back it messes up.
What could this be?
Sorry for all the questions i don't know much about physics

-
- Posts: 33
- Joined: Mon Mar 30, 2009 3:06 am
- Contact:
Re: kinetic balls
I used to have a Newton's Cradle on my desk, and in my experience when you lift two balls from one side and release them, they swing to the center, collide, and then the two balls on the other side swing out (with the center ball staying in place). If you want three balls to bounce out from one side, you need to pull three balls out from the other side to begin with. In this situation, the center ball is in constant motion. (This is the situation that my example code demonstrates.)pabloruiz55 wrote:In real life 2 balls push the 3 remaing and then when they go back they push the other. So you always have 2 and 3 balls moving evenly.
So, perhaps your simulation is working correctly?...
EDIT: I just had a quick look on YouTube, and this video seems to demonstrate the principle pretty well: http://www.youtube.com/watch?v=sLZV0Y-VtGw
[url=http://www.xboxlc.com/profile/Rawlyn][img]http://www.xboxlc.com/cards/sig/black/Rawlyn.jpg[/img][/url]
-
- Posts: 22
- Joined: Mon May 18, 2009 7:31 pm
- Contact:
Re: kinetic balls
Yes sorry i was wrong about that. but then it is not owrking correctly what happens when letting 2 go is: middle ball remains in place, 4th one moves and 5th one moves further. So 4th and 5th get separated and when the last one which travels faster goes back it ruins the simulation.
Who is online
Users browsing this forum: No registered users and 7 guests