Introduction

A Solid contains Shapes. A Shape has Material.
  • Use solid as one indivisible physical entity.
  • Use shapes to define geometry of a solid.
  • Use material to define shape's surface.

Solids

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:
Solid solid = sim.CreateSolid(); 

Note: sim is an initialized Simulator

Once you have a Solid, you can set its various parameters. For example…
solid.LinearDamping = 0.2f;
Matrix transform = Matrix.Identity;
transform.Translation = new Vector3(1.0f, 0.0f, 5.0f);
solid.Transform = transform;
solid.Static = true; 


The last call makes the Solid static, i.e. it will not be physically simulated but still takes part in collision detection.
Force f = new Force();
f.Type = ForceType.GlobalForce;
f.Position = new Vector3(20.0f, 20.0f, 40.0f);
f.Duration = 0.1f;
solid.AddForce(f); 


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:
sim.DestroySolid(solid); 


If other things depends on this Solid, like Joints, Motors, or Sensors, they will automatically be disabled.

Shapes

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:
BoxShapeData boxData = new BoxShapeData();
boxData.Dimensions = new Vector3(1.0f, 1.0f, 2.0f);
solid.AddShape(boxData);
SphereShapeData sphereData = new SphereShapeData();
sphereData.Radius = 2.0f;
sphereData.Offset.Translation = new Vector3(4.0f, 0.0f, 0.0f);
solid.AddShape(sphereData); 


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.

Materials

Each Shape can have different Material properties. Now for a demonstration of using a custom Material:
BoxShapeData boxData = new BoxShapeData();
boxData.Dimensions = new Vector3(1.0f, 1.0f, 2.0f);
boxData.Material.Hardness = 0.2f;
boxData.Material.Bounciness = 0.6f;
boxData.Material.Friction = 1.0f;
boxData.Material.Density = 0.4f;
solid.AddShape(boxData); 


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.

Last edited Oct 12, 2006 at 7:00 PM by KleMiX, version 2

Comments

No comments yet.