Create a dynamic collision between two objects, leaving a dent on one of the objects.
March 31st, 2008 | by Todd Palamar |Soft Body Collisions
Elements:
- NURBS Sphere
- Polygon mesh
- Duplicate polygon mesh
- Gravity Field
Overview: In our first example we have a ball crashing into a moving cube. Upon impact the ball will bounce off the cube leaving a dented surface on the cube. To create this effect, we use a soft body particle system attached to a subdivided polygon mesh.
The ball is made into an active rigid body with which you can establish interaction with the particles of the soft body. Particles themselves do not act upon rigid bodies, meaning they do not affect rigid body transforms.
It only works the other way around. Rigid bodies can move particles! Because of this, we need another element, a second passive rigid body cube for the ball to bounce against. By adding some gravity and two key frames our simulation is complete.
Getting Started…
1. First, lets run through a real simple scene to get acclimated with the tools. (If you are already familiar with soft/rigid body operations jump to the More Advanced section.)
Create a primitive NURBS sphere using the defaults. Rename it to ball.
Transform the sphere. (Figure 1)
- Translate X = -4
- Translate Y = 5
- Scale X = .5
- Scale Y = .5
- Scale Z = .5
2. Create a primitive polygon cube using the defaults. We will keep its name, pCube1.
Transform the cube. (Figure 2)
- Translate Y = .5
- Scale X = 3.5
- Scale Z = 1.6
Change pCube1’s subdivision inputs. Select the cube and in the channel box select the words polyCube1. Change the following inputs:
- Subdivisions Width = 35
- Subdivisions Height = 10
- Subdivisions Depth = 16
This adds more geometry to the entire cube. The purpose is to provide some detail for our dent. Next,
- choose Modify > Freeze Transformations and Edit > Delete By Type > History.
When dealing with simulation it is important to always make sure your geometry is clean of history and transforms.
3. Duplicate pCube1 and use its duplicate name, pCube2.
Transform the cube. (Figure 3)
- Translate Y = -1
- Scale X = .8
- Scale Y = .8
- Scale Z = .8
- Next, choose Modify > Freeze Transformations and Edit > Delete By Type > History.
4. Now, let’s make pCube1 a soft body. This is the important part.
- Choose Soft/Rigid Bodies > Create Soft Body and open the tool options box. Set Create Options to Make Soft.
By doing this all of the other options are grayed out. This creates a soft body object without a goal. Basically, it creates a particle for each vertex, making each one dynamic. At this point, they are at the mercy of Newton’s laws of physics and no longer under your control. To gain some control back, you must set the Conserve on the newly created particles to zero.
***Note*** Open the outliner (Window > Outliner). Click on the plus sign next to pCube1. This reveals the connected particle shape. Select it. In the channel box, under pCube1ParticleShape, find Conserve; the eighth attribute down. Set it to zero. (Figure 4)
You can think of the conserve as Newton’s law, an object in motion tends to stay in motion. By reducing this value you reduce the effects of this law. Setting it to zero, turns it off.
5. Select pCube2 and make it a Passive Rigid Body. (Choose Soft/Rigid Bodies > Create Passive Rigid Body) Use the defaults for all of the settings. Passive rigid bodies are full fledged rigid bodies, but allow you to key frame their transforms.
6. Make pCube2 a child of pCube1.
7. Next, let’s animate pCube1. Set a key in its current position for the translate X. To key just the translate X attribute, click on the words TranslateX in the channel box. Press and hold the right mouse button down, scroll down to the second option in the list, Key Selected, then release the mouse button. For the next key, move forward in the timeline to frame 60. Type a value of -7 for the TranslateX attribute and Key Selected again. (Figure 5)
***Note***
You may have an update issue with your passive rigid body that is a child of pCube1. If pCube2 becomes separated from its parent pCube1, simply type in its correct value. You can get the value from pCube1’s location.
8. Our next step is to get the sphere to interact with our animated cubes.
- Select the ball. Choose Fields > Gravity, keep the defaults. (By selecting the ball first and then choosing a field, Maya automatically makes the necessary connections to the ball.) Press play to view the simulation. At this point, the ball just bounces off pCube2. It is ignoring pCube1 all together. Rigid body collision is automatic in Maya 7, but particle collision is not. Select pCube1 and ball. Choose Particles > Make Collide tool options box. Change the options as follows.
- Resilience = .5
- Friction = .5
9. Play through the animation again. This time the outer box, pCube1 gets dented where the ball makes contact.
- Select pCube2 and hide it. To complete the effect hide pCube2 and the particles. (Figure 6 & QUICKTIME 1)
More Advanced…
1. In this section, we follow the same basic setup as above. We have created a sphere, translated it appropriately, and added gravity to it. In place of the cube, we are using a more detailed piece of geometry, a polygon car. You can substitute the car for anything. (Figure 7)
The first step, is to define the area of the model to be smashed, in this case, the hood. Select faces on the model and choose Edit Polygons > Duplicate Face. Make sure the Separate Duplicated Faces option is checked. Delete the history. Select the new object and add it to a layer for easier selection. This new geometry is what the ball will collide against. Translate it beneath its original faces, scale it if necessary, but position as deep as you want the dent. (Figure
2. The hood itself has very few polygons in it. In order to make the dent look good we need to have a certain amount of faces. This can be done using any method or tool like, smooth or subdivide. For total control however, it is best to hand model the effect with the split polygon tool. To keep the geometry in quads and triangles always start and end at a vertex. Split the geometry up until you have a decent configuration. (Figure 9)
***Note*** It doesn’t matter if the geometry is attached or a separate model. You can parent it back the original. This also gives you the extra ability to alter the geometry freely without taking the entire object into consideration.
3. Next turn the car into a soft body by choosing Make Soft from the Soft Body Creation Options. Remember t o set the Conserve to zero.
4. Animate the object traveling into the path of the falling ball. After you perfect the timing, select the particles or the object they are attached to, and the rigid body ball. Choose Particles Make Collide.
***Note***
If the particle collision or dent effect is not working, it could be due to the passive rigid body collision object too close to the particles. Try moving it a little further away from the them.
5. To change how the ball reacts when it collides you can modify the bounciness and mass of both rigid body objects. Change the ball’s mass to 600 and its bounciness to .1. Play through the simulation. The ball now hits with more of thud. To increase its impact even more change the passive rigid body bounciness to .1 as well.
6. You can also modify the resilience and friction between the particles and active rigid body ball through the geoconnector node. This was created when you chose Make Collide from the Particle pull down menu.
***Note*** This controls how the particles move. Change the settings to a Resilience of 1 and a Friction of 0. The changes are subtly but can affect the way the dent looks.
A quick way to access this node is to type geo* in the quick select box at the end of the status menu bar. By adding the wildcard * (asterisk) you select everything with the geo prefix.
7. For a final touch, add a polygon plane for the floor. Scale it to fit all the elements. Freeze the transforms and Delete history. Make it a passive rigid body.
You must be logged in to post a comment.