The IBody graph node interface. More...
#include "murl_graph_i_body.h"
Public Member Functions | |
virtual INode * | GetNodeInterface ()=0 |
Get the mutable Graph::INode interface. More... | |
virtual const INode * | GetNodeInterface () const =0 |
Get the constant Graph::INode interface. More... | |
virtual ITransform * | GetTransformInterface ()=0 |
Get the mutable Graph::ITransform interface. More... | |
virtual const ITransform * | GetTransformInterface () const =0 |
Get the constant Graph::ITransform interface. More... | |
virtual Bool | SetTriggerGroupMask (UInt32 mask)=0 |
Set the active collision trigger groups for this body. More... | |
virtual UInt32 | GetTriggerGroupMask () const =0 |
Get the active collision trigger groups for this body. More... | |
virtual Bool | SetResponseGroupMask (UInt32 mask)=0 |
Set the active response groups for this body. More... | |
virtual UInt32 | GetResponseGroupMask () const =0 |
Get the active response groups for this body. More... | |
virtual Bool | SetMass (Real mass)=0 |
Set the body's mass. More... | |
virtual Real | GetMass () const =0 |
Get the body's mass. More... | |
virtual Bool | SetInverseMass (Real inverseMass)=0 |
Set the body's inverse mass. More... | |
virtual Real | GetInverseMass () const =0 |
Get the body's inverse mass. More... | |
virtual Bool | SetDragCoefficient (Real value)=0 |
Set the body's drag coefficient (aka "cw" or "cd" value). More... | |
virtual Real | GetDragCoefficient () const =0 |
Get the body's drag coefficient. More... | |
virtual Bool | SetSize (const Vector &size)=0 |
Set the physical size of the body. More... | |
virtual const Vector & | GetSize () const =0 |
Get the body's physical size. More... | |
virtual Bool | SetForceEffectEnabled (Bool enabled)=0 |
Enable/disable force effects on this body. More... | |
virtual Bool | IsForceEffectEnabled () const =0 |
Check if force effect is enabled. More... | |
virtual Bool | SetTorqueEffectEnabled (Bool enabled)=0 |
Enable/disable torque effects on this body. More... | |
virtual Bool | IsTorqueEffectEnabled () const =0 |
Check if torque effect is enabled. More... | |
virtual Bool | SetCollisionEffectEnabled (Bool enabled)=0 |
Enable/disable collision effect on this body. More... | |
virtual Bool | IsCollisionEffectEnabled () const =0 |
Check if collision effect is enabled. More... | |
virtual Bool | SetCollisionReportingEnabled (Bool enabled)=0 |
Enable/disable collision reporting on this body. More... | |
virtual Bool | IsCollisionReportingEnabled () const =0 |
Check if collision reporting is enabled. More... | |
virtual void | ApplyRelativeForceAndTorqueAtRelativePoint (const Vector &p, const Vector &f)=0 |
Apply both force and torque, given a relative force at a relative position. More... | |
virtual void | ApplyAbsoluteForceAndTorqueAtRelativePoint (const Vector &p, const Vector &f)=0 |
Apply both force and torque, given an absolute force at a relative position. More... | |
virtual void | ApplyRelativeForceAndTorqueAtAbsolutePoint (const Vector &p, const Vector &f)=0 |
Apply both force and torque, given a relative force at an absolute position. More... | |
virtual void | ApplyAbsoluteForceAndTorqueAtAbsolutePoint (const Vector &p, const Vector &f)=0 |
Apply both force and torque, given an absolute force at an absolute position. More... | |
virtual void | ApplyRelativeForceAtRelativePoint (const Vector &p, const Vector &f)=0 |
Apply force only, given a relative force at a relative position. More... | |
virtual void | ApplyAbsoluteForceAtRelativePoint (const Vector &p, const Vector &f)=0 |
Apply force only, given an absolute force at a relative position. More... | |
virtual void | ApplyRelativeForceAtAbsolutePoint (const Vector &p, const Vector &f)=0 |
Apply force only, given a relative force at an absolute position. More... | |
virtual void | ApplyAbsoluteForceAtAbsolutePoint (const Vector &p, const Vector &f)=0 |
Apply force only, given an absolute force at an absolute position. More... | |
virtual void | ApplyRelativeTorqueAtRelativePoint (const Vector &p, const Vector &f)=0 |
Apply torque only, given a relative force at a relative position. More... | |
virtual void | ApplyAbsoluteTorqueAtRelativePoint (const Vector &p, const Vector &f)=0 |
Apply torque only, given an absolute force at a relative position. More... | |
virtual void | ApplyRelativeTorqueAtAbsolutePoint (const Vector &p, const Vector &f)=0 |
Apply torque only, given a relative force at an absolute position. More... | |
virtual void | ApplyAbsoluteTorqueAtAbsolutePoint (const Vector &p, const Vector &f)=0 |
Apply torque only, given an absolute force at an absolute position. More... | |
virtual Vector | GetLinearMomentum () const =0 |
Get the currently acting linear momentum. More... | |
virtual Vector | GetAngularMomentum () const =0 |
Get the currently acting angular momentum. More... | |
virtual Vector | GetLinearVelocity () const =0 |
Get the body's current linear velocity. More... | |
virtual Vector | GetAngularVelocity () const =0 |
Get the body's current angular velocity. More... | |
virtual UInt32 | GetNumberOfCollisions () const =0 |
Get the number of individual collisions. More... | |
virtual const Vector * | GetCollisionWorldPoint (UInt32 collisionIndex) const =0 |
Get the actual incidence point for a specific collision. More... | |
virtual const Vector * | GetCollisionWorldDirection (UInt32 collisionIndex) const =0 |
Get the normal vector of the collision. More... | |
virtual Real | GetCollisionDepth (UInt32 collisionIndex) const =0 |
Get the depth of the collision along the collision's normal vector. More... | |
virtual IBody * | GetCollisionBody (UInt32 collisionIndex, UInt32 bodyIndex) const =0 |
Get a body involved in a specific collision. More... | |
virtual ICollider * | GetCollisionGeometry (UInt32 collisionIndex, UInt32 bodyIndex) const =0 |
Get the actual collider of a body involved in a specific collision. More... | |
virtual UInt32 | GetCollisionSurfaceIndex (UInt32 collisionIndex, UInt32 bodyIndex) const =0 |
Get the surface index of a collision. More... | |
virtual IBody * | GetCollisionPartner (UInt32 collisionIndex) const =0 |
DEPRECATED: Get the partner of a specific collision. More... | |
virtual Vector | ResolveCollisions (const IBody *partner, Real margin) const =0 |
Resolve all collisions, optionally with a given partner only. More... | |
virtual const Matrix & | GetBodyTransform () const =0 |
Get a constant reference to the body's current world transform matrix. More... | |
virtual Matrix & | GetBodyTransform ()=0 |
Get a mutable reference to the body's current world transform matrix. More... | |
virtual UInt32 | GetNumberOfStages () const =0 |
Get the body's number of stages. More... | |
virtual Physics::IBody * | GetPhysicsBodyObject (UInt32 stage) const =0 |
Get the body's internal physics simulator object. More... | |
Detailed Description
The IBody graph node interface.
Body nodes are the basis for objects controlled by the framework's built-in physics engine. A body has several properties that affect how it behaves in the simulated environment, such as mass, friction coefficients, contact softness etc. In addition, to be able to react to collisions with other bodies, it needs to have one or more Graph::ICollider nodes attached, which can have different shapes like planes, spheres or generic triangle meshes.
To gain more control over which bodies can collide with other bodies, it is possible to define up to 32 individual body groups. Each body may belong to any number of these groups (including no group), regarding both triggering of and responding to pending collision events (See SetTriggerGroupMask() and SetResponseGroupMask(), respectively). These groups also determine a body's reaction to the influence of a Graph::IField.
See Graph::ICollidable to define a body's collision surface.
See Graph::IField to define fields acting on a body.
Member Function Documentation
◆ GetNodeInterface() [1/2]
|
pure virtual |
Get the mutable Graph::INode interface.
This method returns a mutable pointer to the node's Graph::INode interface, to be able to query or modify common node properties such as active state, visibility or ID.
- Returns
- The mutable Graph::INode interface, or null if not available
◆ GetNodeInterface() [2/2]
|
pure virtual |
Get the constant Graph::INode interface.
This method returns a constant pointer to the node's Graph::INode interface, to be able to query common node properties such as active state, visibility or ID.
- Returns
- The constant Graph::INode interface, or null if not available
◆ GetTransformInterface() [1/2]
|
pure virtual |
Get the mutable Graph::ITransform interface.
This method returns a mutable pointer to the node's Graph::ITransform interface, to be able to query or modify the node's transformation matrix and depth order.
- Returns
- The mutable Graph::ITransform interface, or null if not available
◆ GetTransformInterface() [2/2]
|
pure virtual |
Get the constant Graph::ITransform interface.
This method returns a constant pointer to the node's Graph::ITransform interface, to be able to query the node's transformation matrix and depth order.
- Returns
- The constant Graph::ITransform interface, or null if not available
◆ SetTriggerGroupMask()
Set the active collision trigger groups for this body.
The group assignment for triggering collisions is performed via a UInt32 bit mask (up to 32 simultaneous groups), any individual bit set in the given mask results in generating a collision event in the respective group (e.g. group #5 for bit 5).
- Parameters
-
mask The group assignment bit mask.
- Returns
- true if successful.
◆ GetTriggerGroupMask()
|
pure virtual |
Get the active collision trigger groups for this body.
- Returns
- The bit mask specifying active trigger groups.
◆ SetResponseGroupMask()
Set the active response groups for this body.
The group assignment for responding to collisions and field influence is performed via a UInt32 bit mask (up to 32 simultaneous groups), any individual bit set in the given mask results in a response to a pending collision event or field influence in the respective group (e.g. group #5 for bit 5).
- Parameters
-
mask The group assignment bit mask.
- Returns
- true if successful.
◆ GetResponseGroupMask()
|
pure virtual |
Get the active response groups for this body.
- Returns
- The bit mask specifying active response groups.
◆ SetMass()
Set the body's mass.
This also affects the internal inverse mass value; therefore it is not possible to set different values for mass and inverse mass.
- Parameters
-
mass The body's mass.
- Returns
- true if successful.
◆ GetMass()
|
pure virtual |
Get the body's mass.
- Returns
- The body's mass.
◆ SetInverseMass()
Set the body's inverse mass.
To define VERY heavy bodies, it is possible to set the inverse mass to zero, which results in an infinite mass for this body. In that case, the body will not show any reaction on collision impacts from other (less heavy) bodies. This also affects the internal mass value; therefore it is not possible to set different values for mass and inverse mass.
- Parameters
-
inverseMass The body's inverse mass.
- Returns
- true if successful.
◆ GetInverseMass()
|
pure virtual |
Get the body's inverse mass.
- Returns
- The body's inverse mass.
◆ SetDragCoefficient()
Set the body's drag coefficient (aka "cw" or "cd" value).
- Parameters
-
value The body's drag coefficient.
- Returns
- true if successful.
◆ GetDragCoefficient()
|
pure virtual |
Get the body's drag coefficient.
- Returns
- The body's drag coefficient.
◆ SetSize()
Set the physical size of the body.
This sets the actual physical size of the body, which is used internally to calculate things like inertia tensor etc. It may actually differ from the "real" size that is defined by the body's attached colliders.
- Parameters
-
size A vector containing the body's size in X, Y and Z dimensions.
- Returns
- true if successful.
◆ GetSize()
|
pure virtual |
Get the body's physical size.
- Returns
- A vector containing the body's size in X, Y and Z dimensions.
◆ SetForceEffectEnabled()
Enable/disable force effects on this body.
For certain special use cases, it may be desired to restrict the way a body reacts on external influences. When both force effect and torque effect (see SetTorqueEffectEnabled()) are enabled, the body reacts normally. When force effect is enabled and torque effect disabled, any applied off-center forces will result in a translation movement only. For disabled force effect and enabled torque effect, the result will be a rotational movement only.
- Parameters
-
enabled If true, force effect is enabled.
- Returns
- true if successful.
◆ IsForceEffectEnabled()
|
pure virtual |
Check if force effect is enabled.
- Returns
- true if enabled.
◆ SetTorqueEffectEnabled()
Enable/disable torque effects on this body.
See SetForceEffectEnabled() for details.
- Parameters
-
enabled If true, torque effect is enabled.
- Returns
- true if successful.
◆ IsTorqueEffectEnabled()
|
pure virtual |
Check if torque effect is enabled.
- Returns
- true if enabled.
◆ SetCollisionEffectEnabled()
Enable/disable collision effect on this body.
- Parameters
-
enabled If true, collision effect is enabled.
- Returns
- true if successful.
◆ IsCollisionEffectEnabled()
|
pure virtual |
Check if collision effect is enabled.
- Returns
- true if enabled.
◆ SetCollisionReportingEnabled()
Enable/disable collision reporting on this body.
- Parameters
-
enabled If true, collision reporting is enabled.
- Returns
- true if successful.
◆ IsCollisionReportingEnabled()
|
pure virtual |
Check if collision reporting is enabled.
- Returns
- true if enabled.
◆ ApplyRelativeForceAndTorqueAtRelativePoint()
|
pure virtual |
Apply both force and torque, given a relative force at a relative position.
The given input force vector is always relative to the untransformed body, e.g. for an untransformed aeroplane with its nose pointing towards the -Z axis, its cockpit towards the +Y axis and its right wing towards the +X axis, a force vector of (0,0,-1) will always produce forward thrust, regardless of the plane's actual orientation in world space. The given position vector specifies the actual point where that force is applied; this point is also relative to the untransformed body. If that point is not equal to (0,0,0), the result will not only be a positional movement of the body, but will also result in some torque value applied to the body, resulting in a spin. For the previous example, if the plane's up vector is along the +Y axis, a position vector of (0,1,0) will apply a torque forcing the plane's nose "down". See also ApplyAbsoluteForceAndTorqueAtRelativePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyAbsoluteForceAndTorqueAtRelativePoint()
|
pure virtual |
Apply both force and torque, given an absolute force at a relative position.
The given input force vector is absolute in world space. Taking the plane example from ApplyRelativeForceAndTorqueAtRelativePoint(), with the world's north direction towards -Z, east towards +X and increasing altitude towards +Y, applying a vector of (1,0,0) will always represent west wind (blowing from west to east) acting on the plane, regardless of its position and orientation in world space. The given position vector specifies the actual point where that force is applied; this point is relative to the untransformed body. If this vector equals (0,0,0), no torque will be applied, and the plane will simply be blown off its course, keeping its orientation. A vector of e.g. (0,0,-1) would result in a torque forcing the plane's nose towards the direction of the wind.
- Parameters
-
p The position vector relative to the untransformed body. f The absolute force direction in world space.
◆ ApplyRelativeForceAndTorqueAtAbsolutePoint()
|
pure virtual |
Apply both force and torque, given a relative force at an absolute position.
See also ApplyRelativeForceAndTorqueAtRelativePoint() and ApplyAbsoluteForceAndTorqueAtRelativePoint(). TODO: Find a nice example.
- Parameters
-
p The absolute position vector in world space. f The absolute force direction in world space.
◆ ApplyAbsoluteForceAndTorqueAtAbsolutePoint()
|
pure virtual |
Apply both force and torque, given an absolute force at an absolute position.
See also ApplyRelativeForceAndTorqueAtRelativePoint() and ApplyAbsoluteForceAndTorqueAtRelativePoint(). TODO: Find a nice example.
- Parameters
-
p The absolute position vector in world space. f The absolute force direction in world space.
◆ ApplyRelativeForceAtRelativePoint()
|
pure virtual |
Apply force only, given a relative force at a relative position.
This method only applies a force influence, without applying any torque. See also ApplyRelativeForceAndTorqueAtRelativePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyAbsoluteForceAtRelativePoint()
|
pure virtual |
Apply force only, given an absolute force at a relative position.
This method only applies a force influence, without applying any torque. See also ApplyAbsoluteForceAndTorqueAtRelativePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyRelativeForceAtAbsolutePoint()
|
pure virtual |
Apply force only, given a relative force at an absolute position.
This method only applies a force influence, without applying any torque. See also ApplyRelativeForceAndTorqueAtAbsolutePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyAbsoluteForceAtAbsolutePoint()
|
pure virtual |
Apply force only, given an absolute force at an absolute position.
This method only applies a force influence, without applying any torque. See also ApplyAbsoluteForceAndTorqueAtAbsolutePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyRelativeTorqueAtRelativePoint()
|
pure virtual |
Apply torque only, given a relative force at a relative position.
This method only applies a torque influence, without applying any force. See also ApplyRelativeForceAndTorqueAtRelativePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyAbsoluteTorqueAtRelativePoint()
|
pure virtual |
Apply torque only, given an absolute force at a relative position.
This method only applies a torque influence, without applying any force. See also ApplyAbsoluteForceAndTorqueAtRelativePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyRelativeTorqueAtAbsolutePoint()
|
pure virtual |
Apply torque only, given a relative force at an absolute position.
This method only applies a torque influence, without applying any force. See also ApplyRelativeForceAndTorqueAtAbsolutePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ ApplyAbsoluteTorqueAtAbsolutePoint()
|
pure virtual |
Apply torque only, given an absolute force at an absolute position.
This method only applies a torque influence, without applying any force. See also ApplyAbsoluteForceAndTorqueAtAbsolutePoint().
- Parameters
-
p The position vector relative to the untransformed body. f The force direction vector relative to the untransformed body.
◆ GetLinearMomentum()
|
pure virtual |
Get the currently acting linear momentum.
- Returns
- A vector containing the current linear momentum.
◆ GetAngularMomentum()
|
pure virtual |
Get the currently acting angular momentum.
- Returns
- A vector containing the current angular momentum.
◆ GetLinearVelocity()
|
pure virtual |
Get the body's current linear velocity.
- Returns
- A vector containing the current linear velocity.
◆ GetAngularVelocity()
|
pure virtual |
Get the body's current angular velocity.
- Returns
- A vector containing the current angular velocity.
◆ GetNumberOfCollisions()
|
pure virtual |
Get the number of individual collisions.
This returns the total number of individual collisions that occurred during the last simulation step on the body. After each step, this number is reset to zero, and new collisions are evaluated.
- Returns
- The total number of individual collisions.
◆ GetCollisionWorldPoint()
|
pure virtual |
Get the actual incidence point for a specific collision.
This returns the incidence point for a given collision in world coordinates.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions().
- Returns
- a constant pointer to the wold collision point, or null if the index was out of range.
◆ GetCollisionWorldDirection()
|
pure virtual |
Get the normal vector of the collision.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions().
- Returns
- a constant pointer to the wold collision normal, or null if the index was out of range.
◆ GetCollisionDepth()
Get the depth of the collision along the collision's normal vector.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions().
- Returns
- The collision depth, or 0.0 if the index was out of range.
◆ GetCollisionBody()
|
pure virtual |
Get a body involved in a specific collision.
Individual collisions always occur between only two bodies; if during a simulation step a body collides with more than one other body (or with the same body at more than one contact point), a number of individual pair-wise collisions are generated.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions(). bodyIndex The index of the collision body, either 0 for this body or 1 for the other one.
- Returns
- a pointer to the involved body, or null if the index was out of range.
◆ GetCollisionGeometry()
|
pure virtual |
Get the actual collider of a body involved in a specific collision.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions(). bodyIndex The index of the collision body, either 0 for this body or 1 for the other one.
- Returns
- a pointer to involved body's collider, or null if the index was out of range.
◆ GetCollisionSurfaceIndex()
|
pure virtual |
Get the surface index of a collision.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions(). bodyIndex The index of the collision body for which to get the index, either 0 for this body or 1 for the other one.
- Returns
- The surface index.
◆ GetCollisionPartner()
DEPRECATED: Get the partner of a specific collision.
Use GetCollisionBody(collisionIndex, 1) instead.
- Parameters
-
collisionIndex The collision index, in the range from 0 to GetNumberOfCollisions().
- Returns
- a pointer to the collision's other involved body, or null if the index was out of range.
◆ ResolveCollisions()
|
pure virtual |
Resolve all collisions, optionally with a given partner only.
This method tries to resolve all pending collisions of this body, optionally restricted to collisions with a given partner only. The result is a direction vector that represents the world space offset to be applied to the body so that it does not collide with any other objects anymore. If no collisions are pending, a zero direction vector is returned. Applying the resulting offset vector to a body's position should be done only on bodies for which the collision/force/torque effect is manually disabled, e.g. a player character that should be precisely controlled by explicitly setting its velocity instead of applying forces. Setting the "margin" parameter to a positive non-zero value pushes all collisions "inward" by that distance. This allows to also detect collisions that do not actually occur, but become relevant during collision resolution. Ideally, this value should be set to the maximum distance a body can be moved between subsequent ticks, but may be lower. However, any collision geometry used must be enlarged by that value to give the same result.
- Parameters
-
partner The collision partner to query, or null if all partners should be queried. margin The collision margin.
- Returns
- The offset vector.
◆ GetBodyTransform() [1/2]
|
pure virtual |
Get a constant reference to the body's current world transform matrix.
- Returns
- The world transform.
◆ GetBodyTransform() [2/2]
|
pure virtual |
Get a mutable reference to the body's current world transform matrix.
- Returns
- The world transform.
◆ GetNumberOfStages()
|
pure virtual |
Get the body's number of stages.
- Returns
- The number of stages.
◆ GetPhysicsBodyObject()
|
pure virtual |
Get the body's internal physics simulator object.
- Parameters
-
stage The stage to query.
- Returns
- The physics simulator object.
The documentation for this interface was generated from the following file:
- murl_graph_i_body.h