Friday, December 18, 2009

Exploding Ball Physics

Join my Blender 3D forum, where you can network with other Blender friends and get your Blender 3D questions answered.

Download the blend file



You can do many interesting things with Blender's particle system. In addition to allowing meshes to emit particles (either dynamically with Emit or staticly with Hair), one particle system can react to another particle system. This effect is called Reactor. In this tutorial, I will show you how to set up the effect of a glass ball being destroyed by a speeding bullet using both an emitter and reactor particle system.

Start with the default scene. Delete the default cube (Right click to select, press the Delete key, then press Enter to confirm the delete). Press Num1 to go to Front View. This way, Z is up and down, making your view the closest to the real world view. Turn off the 3D Transform widget, which gets in the way of the demonstration.

Add a UV Sphere (Space - Add - Mesh - UVSphere), accepting the default of 32 rings and 32 segments. For the purposes of this demo, the number of rings and segments doesn't matter. This will be the big glass ball that will be destroyed. Make it larger by scaling it 2 times (S - 2 - Enter). Go to the Shading buttons (F5) and add a material. Make it blue (R=0, G=0, B=1). Go to the Edit buttons (F9). Press the Set Smooth buttons to smooth out the ball.

Let's model the bullet. Position the 3D cursor 2 Blender Units in the X direction to the left of the UV Sphere. Add another UV Sphere, accepting the default. Rename the object from Sphere.001 to Bullet by going to the Object buttons and changing its name. This time, scale it down by .3 (S - .3 - Enter).

Add a particle system to the bullet by going to the Object buttons (F7) and clicking the Particle button. This will be an Emitter type particle system. Click the Random button to emit from random faces. Change the Normal velocity to 2. Change the visualization to Circle. Strictly speaking this not necessary, since we will remove the visualization when we obtain the final effect. You can tweak visualization and velocity to get the effect you want. Press Alt-A to watch the circular particles emanate from the sphere. Later on, this will be the path of the exploding fragments of the sphere as it is hit by the bullet. Press Esc to stop the animation.

Now select the big glass spherical ball. Add a particle system to it by pressing F7 and clicking the Particle button. This system will be a Reactor system. The particles are emitted in reaction to the activity of bullet's particle system. You specify the reactor object and its particle system index (starting from 1) in the Target: area. Type Bullet and accept 1, the first particle system on the bullet object. Note that you can have more than one particle system active on an object.

Make the following changes:
a) In the Basic: group, change the reaction type to Near. This makes the particles from the ball emit when the particles from the bullet are near the object.
b) Set Initial Velocity to 5 in the Normal direction and 5 in the Random direction.
c) Set AccZ to -9.8, which simulates the force of gravity downward, in the negative Z direction.

Let's animate the movement of the bullet through the sphere. Split the 3D window horizontally. Change the right window to an IPO Curve Editor window. Select the bullet, the small sphere. Press the I key to insert a location keyframe. Go to Frame 100. Position the bullet 2 Blender Units to the right, along the X axis (Press the G key, then X, then move the sphere along the axis). Press the I key to insert a location keyframe. In the IPO curve window click LocX. You can see the points representing the keyframes highlighted. LocY and LocZ haven't changed.

Go back to Frame 1. Press Shift-Alt-A to animate. The particles in the large sphere are emitted as the particles from the bullet approach the object.

Now for the magic. To make the big ball explode, add the Explode modifier. Go to F9 (Editing). Click Modifiers. Select Explode. The explode modifier is added to the modifier stack. Press Alt-A to animate. The ball shreds into little pieces, into outer space in all directions.

We can simulate the pieces falling onto a flat surface. Position the 3D cursor under the spheres (in the -Z direction). Add a plane (Space - Add - Mesh -Plane). Scale it up 10 times (S - 10 - Enter). Press F7, the Object buttons. Go to the Physics buttons, the one in the middle of the second set of 3 buttons. Click the Collision button, which makes the particle system aware of the plane as a collision object. Press Alt-A to show how the plane now stops the partcles. You can play with the Particle Interaction settings, such as friction and damping.

Now that we have the effect the way we want it, it's time to stop showing the particles. That's easy. Select the small sphere. Go to the particles tab. Make Visualization None. Then Select the large sphere. Go to the Particles tab. Make Visualization None. Press Alt-A.

By the way, if you want to make a video out of this, be sure that you click the Render Emitter button in both particle systems. Otherwise you won't get either the bullet or the big ball to render.

Pretty neat! Now it's time for you to tweak the ball's destruction as you like. I hope you like this demo. If you did, please hit the Subscribe button in Youtube so you won't miss any of my future tutorials. Happy Blendering!