PDA

View Full Version : Collision - Bowl of candy



Captain Chaos
09-19-2017, 03:53 PM
Trying to render a container full of candy, just need a single frame. I followed the William Vaughn Cereal bowl tutorial which got me part way there but my candies are crashing into each other and most are falling through the bowl. I've experimented with setting for the FXcollision of the bowl and the HardFX on the candy but haven't fully solved the problem. Are there settings I missed or is it something else.

wingzeta
09-19-2017, 04:11 PM
I would use bullet. The WV tutorial was pre bullet days, if I remember correctly. Look for some of the bullet tutorials. They should help.

speismonqui
09-20-2017, 09:02 PM
I seem to recall something about the size of the cereal/bowl (using HardFX method) but I could be wrong, maybe try and size it up a bit?

pinkmouse
09-20-2017, 10:20 PM
Use Bullet. Scale up the model, (in modeller), so the smallest part is about 10-20cm, and make sure the object have lots of polys to avoid collision errors.

MonroePoteet
09-21-2017, 09:17 AM
If all your candy pieces are spherical, then you can probably get HardFX / Collisions to work OK, but Bullet is a better method. Attached is a sample scene filling a bowl with four types of different-shaped candies.

137969

The cascade of candies was created by modeling a single piece of each of the four candies (VERY large candies, as recommended above) in separate layers, using Random Points to create a point array in Layer 5 which was then scaled to be spread above the bowl and Merge Points used to eliminate points within the largest candy's size (in this case I used 16 cm). Then, I used Mike Green's Random Select LScript (available here: http://www.mikegreen.name/Files/MG_Random_Select_MD.zip) to first select 25% of the points, cut-n-paste the selected points to layer 6, put Layer 1 in the background, invert layers ('), and then PointClonePlus to clone the single candy in Layer 1 to the points in Layer 6, using 180 degrees maximum rotation in H,P and B (the candies are symmetric, so larger than 180 wouldn't produce much variation).

Then, repeat with 34% of the remaining points in Layer 5 for the candy in Layer 2, 50% for the candy in layer 3, and the remaining for the candy in layer 4, then consolidate all of them in Layer 1.

The Bullet setup is Static for the bowl (with a 20mm Collision distance), Static for the ground plane, and Parts with Convex Pieces for the candies. A critical setup is setting the Subdivision Order for the Candies object to After Displacement in the Object Properties panel. Otherwise, the candies don't "detect" the Bullet-calculated motion and remain in their modeled position. The Collision Margin on the candies was set to .1mm (100um) so they don't have gaps between them once they settle.

Since you're aiming for just a still, the last step I did might not be required. Bullet simulations "jitter" endlessly long after the Parts object would have "settled" in reality. I've seen recommendations to separate out the Parts object into separate objects / layers, which I haven't tried. What I end up doing is ramping down the Bounciness, and ramping up the Friction, Angular Damping and Linear Damping using Envelopes. In this case I ramped the Bounciness to 0% and the others up to 100% at Frame 100.

You can also improve collision detection in Bullet by setting the World=>Dynamics Framerate to a higher value than the default 180, such as 600. It slows down the simulation, but the results are better and the pieces settle faster.

Hope it helps, and best of luck!
mTp

jeric_synergy
09-21-2017, 01:24 PM
MP, you da man.

tyrot
09-21-2017, 02:05 PM
Oh man.. i was gonna ask for help exact same problem .. THAAAAAAAAAAAAAAANK you !
i will check the scene file as well!

If the bowl was kinematic ... rotating around itself ... should i change any settings ?

MonroePoteet
09-21-2017, 02:55 PM
Oh man.. i was gonna ask for help exact same problem .. THAAAAAAAAAAAAAAANK you !
i will check the scene file as well!

If the bowl was kinematic ... rotating around itself ... should i change any settings ?

Glad to help.

RE: a rotating bowl, my method of damping the Bullet jittering by ramping up the Linear and Angular Damping will make the candy stop rotating even as the bowl continues to do so. So, you'll need to figure out a different way of dealing with the jittering. As I mentioned, it's been suggested that the jittering is better or eliminated by separating the Parts object into separate objects, but I haven't tried it and with ~400 pieces of candy it might be a little cumbersome. Of course, if the bowl is rotating, it might be expected that the candies in it continue shifting a bit, and the jittering won't be unreasonable.

Another method I've used in the past which *might* work is to use Save Transformed Object to save the Parts object to another .LWO file at a particular frame (e.g. Frame 80). Then, create Envelopes on the Bullet Parts object and the transformed object, make the Bullet object dissolve from frame 79 to 80 and the transformed object appear at frame 80. I'm not sure it will work in this case, though.

mTp

tyrot
09-21-2017, 05:26 PM
great ideas thank you again!