How to Animate Falling Coins with Bullet Dynamics

How to Animate Falling Coins with Bullet Dynamics & Motion Designer MDD Files in LightWave 3D

In this month’s blog post I’ll show you how to animate falling coins with Bullet Dynamics, LightWave 3D’s implementation of Erwin Coumans’ Bullet Physics Library. This is a behind the scenes peek of how I used Bullet Dynamics along with Motion Designer MDD files to animate the falling coins in my recent 3D CGI animated viral video ad – Heads or Tails?

Preparing the Models for LightWave 3D’s Bullet Dynamics

Modeling a coin reeds rigdes in Modo - how to animate falling coins with Bullet DynamicsI originally started investigating how to animate falling coins with Bullet Dynamics by modeling a US gold eagle coin to actual scale of 33 mm in diameter. I then scaled up the size of the coin by 100x. Bullet dynamics calculations are most accurate for objects in the size range of 0.4 – 10 m. Scaling the coin up by 100x yielded a 3.3 m diameter. That is comfortably within the best range for the most accuracy in LightWave 3D’s bullet dynamics. For the table object I created a thin cube rather than a flat plane. Bullet dynamics works best on objects with thickness rather than infinitely thin planes.

Reducing Jitter in LightWave 3D’s Bullet Dynamics

Gimbal Lock - Causing Jitter in Bullet Dynamics - how to animate falling coins with Bullet Dynamics

When exploring how to animate falling coins with Bullet Dynamics I ran into a problem. The coin would continue to jitter when it should have come to rest. I had originally modeled the coin standing on edge. It had the front and back faces parallel to the X-Y plane and perpendicular to the Z-axis. In early tests with bullet dynamics on a spinning and tipping coin it jittered a lot after it tipped over when it should have come to rest on the table. I noticed that when it was tipped on the table the coin was gimbal locked where the heading (red) and bank (blue) axes are both aligned on the same plane as seen in the above screenshot. This causes loss of one degree of motion and leads to large changes in the two axes that are coincident. The gimbal locked axes cause Bullet Dynamics to jitter excessively.

To avoid this jitter issue I rotated the coin model in LightWave 3D Modeler to be laying down flat with the front and back faces parallel to the X-Z plane and perpendicular to the Y plane. This reorients the coin object’s axes so that they are no longer gimbal locked when laying down flat as seen in the screenshot below. This helped reduce the jittering.

Gimbal Lock Fixed - Avoiding Jitter in Bullet Dynamics - how to animate falling coins with Bullet Dynamics

As of LightWave 3D 2015.3, LightWave 3D’s Bullet Dynamics doesn’t work with LightWave 3D’s instances. So in order to animate the jackpot of falling coins I cloned the coin object in the Scene Editor to create 160 coins.

Bullet Dynamics Settings

I performed many experimental animation tests while developing how to animate falling coins with Bullet Dynamics. Luckily I was able to borrow a couple of real coins to use for physical tests of how actual US gold eagle coins spin, fall, bounce and slide on a wooden table as well as on each other. I also used the real coins to record the audio of coins spinning, bouncing and sliding on the wooden table and on each other. I composed the soundtrack using those coin sound recordings.

The more complex the LightWave 3D scene the slower the Bullet Dynamics calculations. So to keep the calculations times low I stripped down the scene to just the required objects for the Bullet Dynamics calculations. I used this stripped down simulation scene to setup and calculate the Bullet Dynamics. I then used Motion Designer MDD files to copy the Bullet Dynamics animation from the stripped down simulation scene into the full animation scene.

The following Bullet Dynamics settings were the final results of the many animation tests I performed during the research and development of how to animate falling coins with Bullet Dynamics. I started with one coin with the settings and then cloned it 160 times using the same Bullet Dynamic settings for all the many coins. I tweaked the settings of the first few coins in order to allow them to stack on top of each other.

Bullet Dynamics World Settings:

LightWav 3D Bullet Dynamics Shape Activation Settings - how to animate falling coins with Bullet Dynamics

  • Gravity Y: -200 m
    • I started setting gravity to the actual value of Earth’s gravity: Y -9.8 m(/s2). But because I had scaled the coin up to facilitate Bullet Dynamics calculations it moved like a giant coin rather than one of actual size. So I then increased gravity and tested the coin motion with various gravity settings. I settled with Y -200 m which created pretty realistic motion of the spinning/falling coins based on the motion of a sample coin I borrowed for testing.
  • Dynamics Framerate (fps): 1000.0
    • The frame rate of the dynamics calculations determines the accuracy of the calculations. Higher frame rates enable more accurate calculations at the expense of calculation speed. 1000 provided the right balance of accuracy vs. speed for what I needed.
  • Start Offset: 0 – 175
    • In order to make the coins stack on each other I calculated the Bullet Dynamics simulation scene in stages. I adjusted the start offset for each set of coins as I progressively calculated the Bullet Dynamics. Then I saved the motion with Motion Designer Baker and then loaded it back in with Motion Designer Reader. I adjusted the Start Offset to start the simulation at different frames based on which sequence I was currently generating.

Bullet Dynamics Item Shape Settings & Properties

LightWav 3D Bullet Dynamics Shape Properties - how to animate falling coins with Bullet Dynamics

  • Type: Rigid
  • Shape: Cylinder
  • Major Axis: Y
  • Collision Margin: 20 mm
    • I experimented with various collision margin settings. Settings too low caused coins to intersect each other and sometimes to fall through the table. Settings too high caused the coins to float above each other too much without coming into contact.
  • Mass Distribution: Soild, Specification: Given Mass
  • Mass (kg) 31.1
    • 1 Troy once of gold is about 31.1 grams. The coin model was scaled up to be within the most accurate sizes for Bullet Dynamics rather than actual size. So I set the Mass to 31.1 kg rather than grams.
      [NOTE: Technically a US gold eagle coin is 33.9 grams because it also includes a little silver and copper for durability. But 31.1 was close enough for my purposes.]
  • Friction: 20.0%
    • I tested various friction settings to allow the coins to slide around on each other without sliding too far. 20% worked well for the bulk of coins. I set a few of the earlier coins as low as 10% to allow them to slide a bit more.
  • Bounciness: 55.0%
    • I tested various bounciness settings until I got realistic motion based on the coins I borrowed for testing. 55% worked best for the majority of coins. I set a few of the early coins as high as 70% to allow them to bounce more.
  • Linear & Angular Damping: 3.0%
    • 3% worked well for the majority of the coins to prevent them from jittering too much as they came to rest. A few of the earlier coins were set as low as 1% to get the motion I wanted.

Bullet Dynamics Activation Settings

LightWav 3D Bullet Dynamics Shape Activation Settings - how to animate falling coins with Bullet Dynamics

  • Initial Activation: Activate On Last Key
    • This allowed me to use key frames to animate the coins’ initial spin/fall and then let Bullet Dynamics take over the motion after the last key frame.
  • Deactivation Time (s): 1.0
    • Deactivation time is supposed to stop the Bullet Dynamics after speed drops below the linear/angle thresholds for the designated amount of time. That didn’t seem to work properly in my tests however. Cranking the thresholds way up or down in tests didn’t seem to let the coins stop. They often continued to jitter slightly for as long as I let the animation continue. To solve this problem I ended up using a hybrid approach. I used Bullet Dynamics to calculate how the coins should fall and bounce until they should stop. Then I exported that motion using Motion Designer Baker. I finally loaded the motion back in with Motion Designer Reader and deactivated the Bullet Dynamics on the coin. That way it wouldn’t jitter past where I wanted it to move.
  • Linear Speed Threshold: 100 mm
  • Angular Speed Threshold: 5.0°

How to Animate Stacking Coins with Bullet Dynamics

In order to animate the early coins stacking on top of themselves I used a hybrid approach. I animated a spinning coin and let it fall with Bullet Dynamics up to the point where it should stop moving.

Motion Designer - MD-Baker

Next I exported the Bullet Dynamics motion using Motion Designer MD-Baker.

Motion Designer - MD-Reader

I then reloaded that calculated motion back in using Motion Designer MD-Reader and deactivated the Bullet Dynamics on the coin. Then I calculated Bullet Dynamics on the next couple of coins and repeated the process until I had a few of them stacking on top of each other.

Once the jackpot deluge of coins starts falling I wanted to let the few stacked coins be bounced and pushed away from all the falling coins. I set a keyframe at the end of the time where I wanted to hold them steady and then let Bullet Dynamics take over. That way when new coins fall down they knock the stacked coins out of the way.

Merging the Coin Motions into the Full Animation Scene

LightWave 3D MD Multi-Baker - how to animate falling coins with Bullet Dynamics

After all the coins were animated in the isolated coin dynamics scene I exported all the coin motions. I used MD Multi Baker to export a full set of “.mdd” motion designer files for all the coins in the Bullet Dynamics simulation scene.

Motion Designer MDD-Multi-Loader

After exporting the MDD files from the simulation scene I then loaded the full animation scene and opened MDD Multi-Loader. I used Scan Folder to load all the “.mdd” motion files into the MDD list of files on the right. There’s currently a bug in the MDD Multi-Loader GUI. You have to toggle the MD-Multi-Baker Clone Names button off and on again. Otherwise it won’t affect the object names listed in the Scene Objects list on the left. Clone names are properly displayed when they end with _#_ rather than (#). You can then click the Match By … button. That will match up the Scene Objects with the associated MDD Files. Objects that have been matched will have a checkmark in front of the object name in the Scene Objects list.

Once I loaded the MDD motions onto the coins in the full animation scene I used the graph editor to remove any keyframes from the coin objects. This way the saved MDD motion files are all that control the coin motion.

Final Results of How to Animate Falling Coins with Bullet Dynamics

And once again, here’s the final results of how to animate falling coins with Bullet Dynamics.

If you enjoyed this tutorial please consider making a donation to fund more!

DreamLight Constellation Network Render Controller

DreamLight Constellation 3D Icon LogoDreamLight® Constellation is our cross-platform network render controller that combined with DLI_SNUB-Launcher™ makes configuring, launching and controlling LightWave 3D ScreamerNet LWSN for standalone, batch, network and internet rendering, drag-and-drop-dead-easy™.

Created by Michael Scaramozzino - LightWave 3D Artist Profile
Author of Creating a 3D Animated CGI Short & Mastering LightWave ScreamerNet

DreamLight wrote the book: Creating a 3D Animated CGI Short. See what we can do for you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.