Hi Norbo, i need your help again. For now i've only experimented with simple boxes 1x1x1, my code arrange them as pyramid after i specify the pyramid level (lines), then i can break it down (funny!): the simulation is pretty fine ('though seems to me margins aren't exactly 1, it's about defaultMargin parameter??). Now i want to arrange a cylinder pyramid, here is the problem: when the cylinders come down they rebound&rebound&rebound ad libitum on the floor, it seems like dancing!! What's the matter??
Another question: how can i draw a boundingBox so i can see it? I've seen your Demo but i'm still confused...
Draw boundingBox and dancing cylinders... [RESOLVED]
-
- Posts: 13
- Joined: Sun Jan 11, 2009 6:34 pm
Draw boundingBox and dancing cylinders... [RESOLVED]
Last edited by AlmostNoob on Tue Feb 10, 2009 5:13 pm, edited 1 time in total.
Re: Draw boundingBox and dancing cylinders...
What type of object are you using to draw your floor? If it's a StaticTriangleGroup, you can modify the coefficientOfRestitution property to change the "bounciness."
-
- Posts: 13
- Joined: Sun Jan 11, 2009 6:34 pm
Re: Draw boundingBox and dancing cylinders...
No, the floor is a flat box i built in Lightwave (like everything), it is a box entity.
Re: Draw boundingBox and dancing cylinders...
Assuming everything has a bounciness value of 0, the leading suspect would be the size of the ground and/or cylinders. The box-box collision detection is handled by a special case which performs much, much more accurately with large objects. Cylinder-box falls back to the default MPR/GJK methods which are more sensitive to odd shapes (such as giant flat boxes). If it is large, try shrinking it down to the scales in the demos.
For reference, I duplicated your results with a 1000x1000 box as the ground. 200x200 pretty much got rid of all the artifacts. I would recommend below 100x100 for total robustness, though.
The bounding boxes are drawn in one of the demo's draw method regions. Basically, it compiles a list of the endpoints for lines and passes it into a DrawUserPrimitives call.
For reference, I duplicated your results with a 1000x1000 box as the ground. 200x200 pretty much got rid of all the artifacts. I would recommend below 100x100 for total robustness, though.
The bounding boxes are drawn in one of the demo's draw method regions. Basically, it compiles a list of the endpoints for lines and passes it into a DrawUserPrimitives call.
-
- Posts: 13
- Joined: Sun Jan 11, 2009 6:34 pm
Re: Draw boundingBox and dancing cylinders...
I've scaled the box and now it works, but still there are some issues...
If a cylinder falls standing, its behavior is pretty much like when you drop a coin, it rotates&rotates... until it stops.
If a cylinder falls on its side, it rolls on the floor continuosly, it never stops.
I've tried modifying both cylinder and floor parameters: mass, bounciness, dynamicFriction, density... Which is the right parameter? (if it's about parameter, of course... )
If a cylinder falls standing, its behavior is pretty much like when you drop a coin, it rotates&rotates... until it stops.
If a cylinder falls on its side, it rolls on the floor continuosly, it never stops.
I've tried modifying both cylinder and floor parameters: mass, bounciness, dynamicFriction, density... Which is the right parameter? (if it's about parameter, of course... )
Re: Draw boundingBox and dancing cylinders...
The quickest way to fix the odd rotation is to use conservative angular motion and RK4 angular integration. You can enable them using:
space.simulationSettings.conserveAngularMomentum = true;
space.simulationSettings.useRK4AngularIntegration = true;
There's a marginal performance hit, but it is quite a bit more accurate.
A cylinder laying down and rolling forever won't be stopped by more friction (since it's rolling, every point in contact with the ground is stationary due to friction already). To slow it down over time, you could add some damping using Entity.linearDamping or Entity.angularDamping.
space.simulationSettings.conserveAngularMomentum = true;
space.simulationSettings.useRK4AngularIntegration = true;
There's a marginal performance hit, but it is quite a bit more accurate.
A cylinder laying down and rolling forever won't be stopped by more friction (since it's rolling, every point in contact with the ground is stationary due to friction already). To slow it down over time, you could add some damping using Entity.linearDamping or Entity.angularDamping.
-
- Posts: 13
- Joined: Sun Jan 11, 2009 6:34 pm
Re: Draw boundingBox and dancing cylinders...
Thank you for your precious help, my code comes more robust day after day...
Although i've setted the right parameters, there's a little gap between cylinders (picture below), how can i fix that?
Although i've setted the right parameters, there's a little gap between cylinders (picture below), how can i fix that?
Re: Draw boundingBox and dancing cylinders...
That's caused by the collision margin. You can scale up the graphics or reduce the shape size or margin (but avoid going too small with the margin or accuracy/performance will suffer). You can find more information in this post: http://bepu-games.com/forums/viewtopic.php?f=4&t=409.