Collision Detection

The collision detection system of Realsoft 3D can detect collisions between any objects. You are not required to define any type of bounding box for an object - just activate collision detection, define suitable physical properties, and play the animation.

Level: Intermediate

Sample project file: 'tutorprojects/simulation/collisions'

Create an analytic sphere near the left edge of the view and one subdivision sphere in the center of the view. Select the subdivision sphere, enter the point editing mode, and move a couple of points to deform the second sphere.

Two spheres to be used for a collision

Select the analytic sphere and choose Tools/Simulation/Define Velocity from the main menu. Enter two points in the View window: enter the first point over the left side of the analytic sphere, and the second point over the right side of the subdivision sphere. The analytic sphere will move the length of this line in one second.

Select both spheres, and then choose Animation/Simulations/Collision Detection from the main menu. This menu function turns on collision detection for the selected objects, and also enables the Simulation property for the parent level.

Now play the animation to see how the spheres bounce after colliding.

Note that collision with the SDS sphere is based on the true surface boundary, not the control polygon. If the shape of a colliding object is irregular and the object moves very fast, it may occasionally penetrate other objects. This can be controlled using the Collision Accuracy attribute (located on the Property window's Sim tab). The default value of zero is usually sufficient. Higher values improve accuracy, but at the cost of animation playback speed. If the Collision Accuracy attribute value is not the same for the two colliding objects, the highest value is used. Try adjusting the value of this attribute and compare the results.

Collision deformations

Level: Intermediate

Sample project file: tutorprojects/simulation/elastic_collision

A collision can also deform the colliding objects. Let's make the previous example more interesting by making the SDS sphere elastic.

Select the SDS sphere, open the Property window to the Phys tab, and set the following attribute values:

  • Elasticity = 4.0

  • Rigidity = 0.1

These attribute settings should make the SDS sphere respond as if it were made of a semi-soft, elastic rubber compound. Play the animation. The collision with the other sphere causes it to jiggle (or oscillate).

A SDS sphere deformed by a collision

[Note] Note
Elasticity is a valid attribute only for freeform objects, such as SDS and NURBS objects. Analytic spheres and cubes, for example, cannot be deformed because their geometry does not contain enough points.

Selective collisions

Level: Intermediate

Sample project file: tutorprojects/simulation/selective_collision

In the previous two examples, collision detection was activated by selecting the objects and using the Animation/Simulations/Collision Detection function from the main menu. This tool causes collisions to be detected between all of the selected objects. It also sets all the necessary collision attributes for the selected objects. You may have noticed that in the previous examples the Collision Detection attribute was set to the value "Both" for the two spheres, meaning that each object both causes and is affected by collisions.

However, it may not always be the case that you want every object to both cause and be affected by collisions, even though in a realistic universe, this is always the case. One reason to be more selective in setting the value of the Collision Detection attribute is animation playback speed. The computational requirements grow much more rapidly than the number of colliding objects—in fact, the demand is proportional to the square of the object count. For example, if you increase the object count by a factor of 10, the number of object pairs (potentially colliding) grows by a factor of 50.

Manually defining which objects cause collisions and which are only affected by collisions can be used to decrease the computational work for collision detection, often without affecting the realism of the scene. The following example demonstrates this situation.

Create one big analytical sphere (a planet) in the middle of the view window. Then create a dozen smaller analytical spheres (meteorites) around it.

Select the planet sphere and open the Property window. On the Phys tab, set the mass to 1 000 000 000 kg, so that it creates a strong gravity field.

Switch to the Sim tab, and set Gravity=Cause and Collision Detection=Cause.

Multi-select all the meteorite spheres, and set Gravity = Affected and Collision Detection = Affected. Close or minimize the Property window.

Select the parent level of all the spheres, and turn on the Simulation property by clicking the button on the tool control bar.

Set the total frame count in the Animation window to, say, 600 frames and play the animation.

Inertia

Level: Intermediate

Sample project file: tutorprojects/simulation/inertia

The Inertia attribute specifies how the mass of an object is distributed inside its volume. If an object's inertia is low, then the mass is located near the center of gravity point; this, in turn causes strong spins during collisions. The higher the inertia, the more the mass is distributed throughout the object's volume, and the stronger the object resists spinning. By default, the program estimates the initial inertia values for an object based on its mass by assuming that the volume is filled with homogeneous matter.

The Inertia attribute is located on the Property window's Phys tab. It is best to use the default inertia as a starting point for experiments. It is easily possible to define inertial values that are physically impossible (at least in this Universe). The result will be that the object exhibits unnatural behavior in collisions, such as wild spinning.

So let's try an experiment with inertial values.

First create three analytical spheres to use as test objects. Stretch two of the spheres so that they become elliptical.

Select the round sphere, open the Property window to the Phys tab, and set the mass to 1 million kg.

Select one of the elliptical objects, and on the Phys tab examine the value of the Inertia attribute. The program sets the default mass of an object to one kilogram; therefore, if the radius of the object is about 10 centimeters, the inertial values will be quite small. Decrease the inertial values along each axis by a factor of 10 by adding a zero after the decimal point. For example, values of 0.05 0.05 0.05 would become 0.005 0.005 0.005. Such values will make this object have an unusually low inertia, making it behave like a heavy lead ball thickly coated with lightweight plastic foam. Make sure that you have defined a suitable number of decimals in the Options Window/Metrics tab.

Select the second elliptical object, and again examine the value of the Inertia attribute. This time increase the value by a factor of ten by removing one zero after each decimal point. For example, values of 0.05 0.05 0.05 become 0.5 0.5 0.5. These values make the second elliptical object have a high inertia, making it behave like a hollow lead sphere having all the mass close to the outer surface.

Close or minimize the Property window, then select all three objects and choose Animation/Simulations/Collision Detection from the main menu.

Define a suitable velocity for both the elliptical objects using the Velocity tool, located on the Simulation tab. The velocity vectors should be drawn in such a manner that each object will hit the heavy sphere during the animation.

Set the total frame count in the Animation window to, say, 500 frames. Play the animation and compare how each of elliptical objects spins after its collision with the heavy sphere.

After experimenting with Inertia values, you can use the Clear button to the right of the Inertia field to restore the original default values, which usually produces quite suitable and natural spinning.

Surface friction

Level: Intermediate

Sample project file: tutorprojects/simulation/surface_friction

An object's surface friction plays an important role in collisions. The following example, a sphere rolling on a table, demonstrates this property. Note that a collision is not always a catastrophic event. A ball rolling on a floor or table is still a collision, albeit, a mild one.

Create a cube to represent a table, and a NURBS sphere slightly above and to the right of the table as shown in the image below. Remember to verify from the side view and top view that the sphere is really aligned with the table.

From the Simulation tab of the toolbar, activate the Distant Gravity tool and draw a vertical line pointing downward. T his defines the direction of gravity, not its strength. The gravity strength value is set on the Spec tab of the Distant Gravity object's property gadget. Set this value to 2.0.

Select the sphere, and from the Simulation tab activate the Velocity tool. Draw a horizontal velocity line from the center of the sphere to about the middle of the table. When you make the sphere affected by gravity, it will fall and collide with the table.

Objects for surface friction simulation

Open the Property window to the Sim tab and define the following properties for the sphere:

Select the cube object representing the table and define the following properties:

Although real world tables are not this heavy, they stand on a firm floor, which in turn is anchored to a house, and hence to the Earth. Therefore, the mass resisting the collision is quite large. Note that even though the table will not move when Collision Detection = Cause, it needs a proper mass to create an impact with the sphere.

Select the parent level of your objects, and make sure the Simulation property is on. Play the animation. The sphere should bounce across the table. It may rotate somewhat due to its initial collision with the table and limited computation accuracy. Try also playing with the Collision Accuracy value. Let's see what happens when we give both the table and the ball a non-zero Surface Friction value.

Select both the cube and the sphere. Open the property window to the Phys tab and set Surface Friction = 0.1.

Play the animation again. The sphere stops bouncing rather quickly, and begins to roll. The Surface Friction attribute has the following properties.

To test this last property of the Surface Friction attribute, set the value for the table and ball to 1.0 and replay the animation.

Rebound energy

Level: Intermediate

Sample project file: tutorprojects/simulation/decreasing_rebound

The Rebound Energy attribute defines how much of an object's kinetic energy is lost in each collision. If an object's rebound energy value equals 1.0, this produces a fully elastic collision; that is, the object does not lose any kinetic energy. For example, if a rubber ball hits a concrete wall, it bounces away with exactly the same speed as it had before the collision. If an object's rebound energy value equals zero, this produces a fully non-elastic collision - the object loses all its kinetic energy, such as an egg hitting a concrete wall. When a collision is non-elastic, the majority of kinetic energy is lost (it is converted to heat). If two objects with zero rebound energy collide, they stick together.

To experiment with rebound energy, set up a scene as follows.

Create two NURBS spheres. Multi-select them both, and from the main menu choose Animation/Simulations/Gravity, followed by Animation/Simulations/Collision Detection. Then set the mass of each sphere to 200 million kg.

Play the animation. The spheres should attract each other until they collide, then continue hitting each other and bouncing apart. If the simulation proceeds too slowly, stop the playback, rewind the animation, then increase the mass of both objects. If you look at the attribute values on the Phys tab for the two spheres, you'll see that the Rebound Energy attribute is set to 1.0 (the default). Try setting the Rebound Energy value of both spheres progressively lower (0.75, 0.5, 0.25), and replay the animation. As the value is lowered, rebounding decreases and finally stops.