Tutorial 2: Solids, Shapes, and Materials
A Solid is analogous to a physical object in the real world. It can be static (just a shape, not physically simulated) or dynamic (has a shape, mass, and is physically simulated). The available Shapes are: boxes, spheres, capsule, planes, and triangular meshes. A Solid contains no moving parts. Complex objects with moving parts can be built from multiple Solids with Joints.
Create a Solid by asking a Simulator to create one:
Once you have a Solid, you can set its various parameters. For example…
The last call makes the Solid static, i.e. it will not be physically simulated but still takes part in collision detection.
You can apply forces and torques to a Solid like this:
This force will be applied to the Solid until its duration expires.
When you are done with a Solid, tell the Simulator to destroy it:
If other things depends on this Solid, like Joints, Motors, or Sensors, they will automatically be disabled.
An important part of creating a Solid is giving it Shapes. A Solid can contain any number of Shapes. To add box and sphere Shapes to the Solid, do the following:
Notice how the sphere’s offset was changed. The offset positions the Shape relative to the Solid’s transform. Shapes are not offset at all by default. Here, we have moved the Sphere away from the Solid’s origin.
Each Shape can have different Material properties. Now for a demonstration of using a custom Material:
Note that Material density affects a Solid’s mass (calculated from each Shape’s density and volume). The rest of the Material properties are described in the API reference.
OPAL is Copyright © 2004-2005 Alan Fischer, Andres Reinot, and Tyler Streeter