Destroying a Wall Using Rigid Bodies and Particles in Maya
Application Used: Autodesk Maya
Author: Bogdan Amidzic
Destroying a wall using rigid bodies and particles
This tutorial will explain how to use rigid bodies, forces and particles to create shatter effect in Maya.
First, create NURBS or poly plane and make it look like simple terrain, nothing fancyÖalso create some lights.
Then create wall using cube with some decent number of divisions. Texture it if you want.
Duplicate it. Why? Because one will be the original wall, and the second will be the one we are going to destroy. The first wall will appear in the animation before the explosion and second will appear during the explosion.
Hide the first wall (you can put it in a layer). Create another cube. This cube will be used to create the area of shattering.
Deform it and duplicate it.
Duplicate the second wall. Now you have three copies of the same wall. The second will be the wall after the explosion, and third will be part of the wall that will fly around.
So now select the second wall and cube and apply mesh/Booleans/difference
Then select the third wall and the second cube and do mesh/Booleans/intersection
Note, before using Booleans, delete history on objects.
Then select the second wall (wall with hole) and go to the dynamics menu set, delete its history and apply default lambert1 material to it. Go to effects/create shatter options box. In tabs, select solid shatter and for post operation, select shapes. Change the count to desired number of pieces.
After a few seconds of calculation you will get a few pieces.
Now select terrain and go to soft/rigid bodies/create passive rigid body. Passive rigid body is the object that is interacting with other rigid bodies, but it's not affected by any force. Two passive rigid bodies won't interact, passive rigid bodies interact only with active rigid bodies.
Then select shards and go to soft/rigid bodies/create active rigid body. Active rigid body is affected by forces, and it is interacting with active and passive rigid bodies.
Select all shards and in the channel box click in inputs, click rigidbodyXX, and a list of attributes will appear. Scroll down and turn the collisions off. If you don't do this, the shards will penetrate each other, because the distance between them is 0. All dynamics operate with offset which is by default 0,1.
Also you can change the mass of the bodies. I did this according to the size of the objects.
Select the second wall and make it a passive rigid body.
Now unhide the first wall. I wanted the explosion to start at frame 25. That means that wall will be normal for the first 24 frames. So at frame 24, in the channel box set visibility to 1 (on) then right click on visibility and in the popup menu click key selected. In frame 25, set it to 0 (off) and key it. For the second wall and shards, do the opposite.
Select shards and go to fields/radial. Radial field creates force from one point to all directions. Move it, and key magnitude for 5 frames since it's only going to add impulse to shards. So at frame 24 magnitude is 0, at 25 it will be 300 and at 30 will be 0.
Select shards and go to fields/gravity. Key magnitude at frame 24 to be 0, and in 25 set it to 9.8 (or any value you need).
Also in playback settings (last icon in the range slider) set playback rate to play every frame. All dynamics require this.
Also you can create turbulence field to give shards a bit of randomness. Key it like you did with the radial field.
In my case it went really high, but lasted very short.
When the shards fly away from each other and from the wall, key their collisions attribute to be on.
Sometimes you might need to key them one by one, because there might be some parts that are close to the ground, and others that are still close one to another.
So, I got nice collision with the ground.
I tweaked mass further.
You can create camera to get a nice shot. It's cool when shards get close to the camera.
Then create one polygon (create polygon tool). This polygon will be used to emit small pieces of the wall. This object will be hidden. You can hide it later or just turn it's primary visibility off.
Select that polygon and go to particles/emit from object. This will create an omni particle emitter, and particle system.
Change emitter type to surface, set the speed to 0, min distance to 0, and max distance to .2 or something like that. This will offset particles from that plane.
Key the rate attribute. In my case it was 0 at frame 24, 3000 at frame 25 and 0 at frame 26. Rate is the number of particles emitted in one second (24 frames). So the real number of particles emitted here is 3000/24.
Select particle1, and in attribute editor scroll down to per particle attributes. Right click on mass, a menu will pop up. Choose creation expression.
The Expression Editor will appear. Check creation. This means that the expression will be applied only when the particle is born. Type particleShape1.mass=rand(1,30);
Rand is command that gives random number between the two argument numbers. In this case particle mass will be some number between 1 to 30.
Go to window/relationship editors/dynamic relationships. Find particle1. Select all three fields on the right. This means that all three fields will affect particles.
If you playit back, you should get something like this.
Now it's time to shape our particles. Create poly cube and make 4 or more stones.
Then select all 4 stones and particle1 and go to particles/instancer option box.
Remove particle1 from list and set cycle to none.
If you play, lot of stones will fly. All of them have the same orientation and size because they are all the same.
Scroll down to per particle attributes and click general. Then select particle tab. Scroll down to userScalar1PP. This will create a new attribute it the list. We will use this attribute to change the id of particles, so they will use all four stones.
Then right click userScalar1pp in per particle list and choose creation expression (like you did with the mass). In expression editor type particleShape1.userScalarPP=rand(0,3);
If you look at instancer1 node, you will see that there are four objects with id's 0,1,2,3. Rand is choosing randomly between these id's for every particle when they're born.
Then scroll up to instancer tab and change object index to userScalar1pp.
Then add another attribute, but this time it will be userVector1PP.
Also go to creation expression like you did with mass and userScalar1pp.
Now userVector1pp will be used to determine size of particles. That size shall be proportional to mass. So I created variable $m which generates random mass, and for size I just divided it by 100.
Now every particle has random mass and size. Note, on the picture there's no user scalar1PP because I forgot to add it earlier.
[Click Here for Larger Image]
So change scale to userVector1PP
Create another attribute userVector2PP and create creation expression like this:
Scroll up to instancer tab and set rotation to userVector2PP
This means that every particle shall get random rotation at start.
[Click Here for Larger Image]
Now if you play it back, it's looking better. The only thing left is to give spin to the particles.
So, create runtime before dynamics expression (in the same menu where is creation expression). Type:
+= means that values are adding at every frame (same as particleShape1.userVector2PP= particleShape1.userVector2PP +<<15,15,15>>)
so our particles are rotating 15 degrees per frame on all axes. This is not the best way to do it, but I just wanted to give a simple example. It's up to you to explore.
Select particles, and select ground and go to particles/make collide. Set resilience to .7;
That's it. At this point you can add explosion, and smoke?