Click or drag to resize
DigitalRuneRigidBody Class
Represents a rigid body.
Inheritance Hierarchy
SystemObject
  DigitalRune.PhysicsRigidBody

Namespace: DigitalRune.Physics
Assembly: DigitalRune.Physics (in DigitalRune.Physics.dll) Version: 1.10.0.0 (1.10.0.14427)
Syntax
public class RigidBody : IGeometricObject, INamedObject

The RigidBody type exposes the following members.

Constructors
  NameDescription
Public methodRigidBody
Initializes a new instance of the RigidBody class.
Public methodRigidBody(Shape)
Initializes a new instance of the RigidBody class.
Public methodRigidBody(Shape, MassFrame, IMaterial)
Initializes a new instance of the RigidBody class.
Top
Methods
  NameDescription
Public methodAddForce(Vector3F)
Applies a force at the center of mass of the rigid body.
Public methodAddForce(Vector3F, Vector3F)
Applies a force to the rigid body.
Public methodAddTorque
Applies a torque at the center of mass of the rigid body.
Public methodApplyAngularImpulse
Applies an angular impulse at the center of mass
Public methodApplyImpulse
Applies an impulse at a given position.
Public methodApplyLinearImpulse
Applies a linear impulse at the center of mass
Public methodClearForces
Clears all forces that were set with AddForce(Vector3F, Vector3F), AddForce(Vector3F) or AddTorque(Vector3F).
Public methodClone
Creates a new RigidBody that is a clone (deep copy) of the current instance.
Protected methodCloneCore
Makes the instance a clone (deep copy) of the specified RigidBody.
Protected methodCreateInstanceCore
When implemented in a derived class, creates a new instance of the RigidBody derived class.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetVelocityOfLocalPoint
Gets the velocity of a point on the rigid body.
Public methodGetVelocityOfWorldPoint
Gets the velocity of a point on the rigid body.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnAddToSimulation
Called when this rigid body is added to a simulation.
Protected methodOnPoseChanged
Raises the PoseChanged event.
Protected methodOnRemoveFromSimulation
Called when this rigid body is removed from a simulation.
Protected methodOnShapeChanged
Raises the ShapeChanged event.
Public methodSleep
Deactivates this rigid body.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWakeUp
Wakes the rigid body up from sleeping.
Top
Extension Methods
  NameDescription
Public Extension MethodComputeKMatrix
Computes the K matrix needed by sequential impulse-based methods.
(Defined by ConstraintHelper.)
Public Extension MethodSetVelocityOfWorldPoint
Applies an impulse so that the velocity of point on the body is changed.
(Defined by ConstraintHelper.)
Top
Properties
  NameDescription
Public propertyAabb
Gets the axis-aligned bounding box (AABB).
Public propertyAngularVelocity
Gets or sets the angular velocity about the center of mass in world space.
Public propertyAutoUpdateMass
Gets or sets a value indicating whether the MassFrame is automatically updated if the Shape or Scale of this body is changed.
Public propertyCanSleep
Gets or sets a value indicating whether this body can sleep.
Public propertyCcdEnabled
Gets or sets a value indicating whether Continuous Collision Detection (CCD) is enabled.
Public propertyCollisionObject
Gets the collision object.
Public propertyCollisionResponseEnabled
Gets or sets a value indicating whether collision response is enabled.
Public propertyInertiaInverseWorld
Gets the effective inverse inertia.
Public propertyIsSleeping
Gets a value indicating whether this rigid body is sleeping.
Public propertyKineticEnergy
Gets the kinetic energy.
Public propertyLinearVelocity
Gets or sets the linear velocity of this body in world space.
Public propertyLockRotationX
Gets or sets a value indicating whether the body can rotate around its local mass frame x-axis.
Public propertyLockRotationY
Gets or sets a value indicating whether the body can rotate around its local mass frame y-axis.
Public propertyLockRotationZ
Gets or sets a value indicating whether the body can rotate around its local mass frame z-axis.
Public propertyMassFrame
Gets or sets the mass frame which defines the mass properties of this body.
Public propertyMassInverse
Gets the effective inverse mass.
Public propertyMaterial
Gets or sets the material.
Public propertyMotionType
Gets or sets the motion type.
Public propertyName
Gets the name.
Public propertyPose
Gets or sets the pose (position and orientation).
Public propertyPoseCenterOfMass
Gets or sets the pose (position and orientation) of the center of mass.
Public propertyRotationalEnergy
Gets the rotational kinetic energy.
Public propertyScale
Gets or sets the scale.
Public propertyShape
Gets or sets the shape.
Public propertySimulation
Gets the simulation.
Public propertyTranslationalEnergy
Gets the translational kinetic energy.
Public propertyUserData
Gets or sets the user data.
Top
Events
  NameDescription
Public eventPoseChanged
Occurs when the pose was changed.
Public eventShapeChanged
Occurs when the Shape or Scale was changed.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodIGeometricObjectClone
Creates a new IGeometricObject that is a clone (deep copy) of the current instance.
Top
Remarks

A rigid body is a body that is simulated by rigid body dynamics. The body has a Shape that is constant for the simulation (although the shape can be exchanged by the user). No deformations are computed, therefore this body cannot model a soft body like cloth or fluids.

The body also has a mass properties defined in MassFrame and a Material that defines friction, bounciness and other material properties.

Center Of Mass: The body has a Pose that defines its position and orientation in world space. The origin of the local space of the body can be different from its center of mass. The body has a PoseCenterOfMass that defines the pose of the center of mass in world space. The center of mass is automatically computed from the shape of the rigid body when the body's MassFrame is created. To move the rigid body to a new pose the properties Pose or PoseCenterOfMass can be used; the two properties are synchronized automatically.

Collision Detection: The rigid body class implements IGeometricObject and it automatically creates a CollisionObject for the rigid body. This collision object is automatically added to the CollisionDomain of the simulation.

Important: An IGeometricObject instance registers event handlers for the Changed event of the contained Shape. Therefore, a Shape will have an indirect reference to the IGeometricObject. This is no problem if the geometric object exclusively owns the shape. However, this could lead to problems ("life extension bugs" a.k.a. "memory leaks") when multiple geometric objects share the same shape: One geometric object is no longer used but it cannot be collected by the garbage collector because the shape still holds a reference to the object.

Therefore, when Shapes are shared between multiple IGeometricObjects: Always set the property Shape to Empty when the IGeometricObject is no longer used. Empty is a special immutable shape that never raises any Changed events. Setting Shape to Empty ensures that the internal event handlers are unregistered and the object can be garbage-collected properly.

Cloning: The rigid body can be cloned using the Clone method. Cloning creates a deep copy of the object. The UserData and the Material are copied and not cloned, so the clone will refer to the same UserData and Material instances. All other properties are properly cloned.

Sleeping: See also SleepingSettings. The rigid body automatically wakes up if important properties are changed - for example, if the Shape is changed, the body wakes up.

See Also