Adding a collision model to an object

06 May Adding a collision model to an object

This post will present different ways to add a collision model to an object in Blender SOFA.

Setting up the scene

 

First of all, we will set-up a small example scene. It will consist of a monkey head falling on an oblique plane.

As usual, go to the Blender Game Engine and activate SOFA as the physics engine. Then create a plane (space and ‘Add Plane’), then scale it and rotate it (resp. ‘S’ and ‘R’). In the Physics panel of the plane, activate Sofa Collision.

Collision1

We now create the object that will fall on the plane. Here we will use the Blender Suzanne’s head (space and ‘Add Monkey’) but any other mesh could be used similarly. Move your object to place it over the oblique plane. Go to the Physics panel and activate Sofa Physics.

Finally, we activate the rendering of the collision models. In the World panel, click in Show physics visualization and then on Collision models.

Collision2

No collision model has been defined for the head. So, if you press ‘P’, the head will fall through the plane.

 

 Using the mesh itself

 

To use the mesh itself as a collision mesh, you just have to enable Sofa Collision in the Physics panel, and check that the Type is set to Mesh.

Collision3

If you press ‘P’, you will see that the collision mesh in yellow is identical to the visual mesh, and the head will now be stopped by the plane.

Note. If the plane does not stop the head, it might be because it is incorrectly oriented.

Collision4a Collision4b

Warning. You can not scale your object if you use this option. This is a bug in Blender SOFA and should be fixed in our next release. If you want to scale your object, you have to use Apply Object Transform on it afterwards (‘space’ and ‘Apply Object Transform’, then click on Scale on the newly appeared menu. The Scale factors should have come back to 1 1 1 ).

 

Using a sphere

 

To use spheres as a collision mesh, you just have to enable Sofa Collision in the Physics panel, and check that the Type is set to Sphere. You set the radius of the sphere by using the Radius widget that appears.

Collision5a Collision5b

Warning. If your model is rigid, only one sphere will be created. Otherwise, one sphere will be created for every point of your mechanical model. For instance, for a regular or a sparse grid, spheres will be placed on every vertices of the grid (this might not be what you expect!).

 

 Using another mesh

 

You can use any other mesh for collision model. What you have to do is set that mesh as a child of your other object. You can do so with drag and drop in the Scene graph, or by selecting you collision object then the mechanical object while pressing shift, the pressing ‘Ctrl + P’ or ‘space’ + ‘Make Parent’. Alternatively, you can use ‘Shift + Ctrl + P’ or ‘space’ + ‘Make Parent without inverse’ (see below).

Once the new mesh is set as a child, activate Sofa Collision for it and disable it for its parent. The new mesh will now be used as a collision model.

Collision6b

A typical application is to use a simplified version of your visual mesh. To do so, you first have to duplicate your visual mesh (‘Shift + D’) and simplify it, by applying a decimate modifier for instance (do not forget to apply the modifier).

Warning. Make sure that Sofa Collision is disabled for the parent mesh.

Warning. Combined transformations are not correctly handled in Blender SOFA. When setting a mesh as a child of the other, you should ensure that the parent mesh is not scaled nor rotated. You can also use ‘Shift + Ctrl + P’ or ‘space’ + ‘Make Parent without inverse’, but you will have to replace the child object manually.

 

 

 

No Comments

Post A Comment