Table of Contents

Class RigidBodyBehavior

Namespace
LibGFX.Physics.Behaviors
Assembly
LibGFX.dll

Represents a 3D rigid body

public abstract class RigidBodyBehavior : PhysicsBehavior, IGameBehavior
Inheritance
RigidBodyBehavior
Implements
Derived
Inherited Members

Constructors

RigidBodyBehavior(PhysicsHandler)

Creates a new 3D rigid body

public RigidBodyBehavior(PhysicsHandler physicsHandler)

Parameters

physicsHandler PhysicsHandler

Properties

AngularVelocity

Gets or sets the angular and linear velocity of the rigid body

public Vector3 AngularVelocity { get; set; }

Property Value

Vector3

Friction

Gets or sets the friction of the rigid body

public float Friction { get; set; }

Property Value

float

LinearVelocity

Gets or sets the linear velocity of the rigid body

public Vector3 LinearVelocity { get; set; }

Property Value

Vector3

Offset

The offset of the rigid body

public Vector3 Offset { get; set; }

Property Value

Vector3

Parent

The parent game element

public GameElement Parent { get; set; }

Property Value

GameElement

Restitution

Gets or sets the restitution of the rigid body

public float Restitution { get; set; }

Property Value

float

RigidBody

The rigid body

public RigidBody RigidBody { get; set; }

Property Value

RigidBody

Methods

ApplyCentralForce(Vector3)

Applies a central force to the rigid body

public void ApplyCentralForce(Vector3 force)

Parameters

force Vector3

ApplyCentralImpulse(Vector3)

Applies a central impulse to the rigid body

public void ApplyCentralImpulse(Vector3 impulse)

Parameters

impulse Vector3

ApplyForce(Vector3, Vector3)

Applies a force to the rigid body at a specified position

public void ApplyForce(Vector3 force, Vector3 relPos)

Parameters

force Vector3
relPos Vector3

ApplyImpulse(Vector3, Vector3)

Applies an impulse to the rigid body at a specified position

public void ApplyImpulse(Vector3 impulse, Vector3 relPos)

Parameters

impulse Vector3
relPos Vector3

ApplyTorque(Vector3)

Applies a torque to the rigid body

public void ApplyTorque(Vector3 torque)

Parameters

torque Vector3

CalculateForwardVector(float)

Calculates the forward vector of the rigid body based on its rotation and a specified distance.

public Vector3 CalculateForwardVector(float distance)

Parameters

distance float

The distance to scale the forward vector.

Returns

Vector3

The forward vector scaled by the specified distance.

CalculateRightVector(float)

Calculates the right vector of the rigid body based on its rotation and a specified distance.

public Vector3 CalculateRightVector(float distance)

Parameters

distance float

The distance to scale the right vector.

Returns

Vector3

The right vector scaled by the specified distance.

CalculateUpVector(float)

Calculates the up vector of the rigid body based on its rotation and a specified distance.

public Vector3 CalculateUpVector(float distance)

Parameters

distance float

The distance to scale the up vector.

Returns

Vector3

The up vector scaled by the specified distance.

EnableContinuousCollisionDetection(float, float)

Enables continuous collision detection for the rigid body

public void EnableContinuousCollisionDetection(float motionThreshold = 0.1, float sweptSphereRadius = 0.2)

Parameters

motionThreshold float
sweptSphereRadius float

GetAngularVelocity()

Returns the current angular velocity of the rigid body

public Vector3 GetAngularVelocity()

Returns

Vector3

GetElement()

Gets the game element

public override GameElement GetElement()

Returns

GameElement

GetLinearVelocity()

Returns the current linear velocity of the rigid body

public Vector3 GetLinearVelocity()

Returns

Vector3

GetLocation()

public Vector3 GetLocation()

Returns

Vector3

GetPhysicsObject()

Gets the physics object

public override object GetPhysicsObject()

Returns

object

GetRotation()

public Quaternion GetRotation()

Returns

Quaternion

OnCollide(Collision)

On collide event

public override void OnCollide(Collision collision)

Parameters

collision Collision

OnDispose(BaseScene, IRenderDevice)

Disposes the rigid body

public override void OnDispose(BaseScene scene, IRenderDevice renderer)

Parameters

scene BaseScene
renderer IRenderDevice

OnInit(BaseScene, Viewport, IRenderDevice)

Initializes the rigid body

public override void OnInit(BaseScene scene, Viewport viewport, IRenderDevice renderer)

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice

OnRender(BaseScene, Viewport, IRenderDevice, Camera)

Renders the rigid body

public override void OnRender(BaseScene scene, Viewport viewport, IRenderDevice renderer, Camera camera)

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice
camera Camera

OnUpdate(BaseScene, float)

Updates the rigid body

public override void OnUpdate(BaseScene scene, float dt)

Parameters

scene BaseScene
dt float

RemoveRigidBody()

Removes the rigid body

public virtual void RemoveRigidBody()

Rotate(Quaternion)

Rotates the rigid body

public void Rotate(Quaternion rotation)

Parameters

rotation Quaternion

Rotate(Vector3)

Rotates the rigid body

public void Rotate(Vector3 rotation)

Parameters

rotation Vector3

SetAngularFactor(Vector3)

Sets the angular factor of the rigid body

public void SetAngularFactor(Vector3 factor)

Parameters

factor Vector3

SetAngularVelocity(Vector3)

Sets the angular velocity of the rigid body

public void SetAngularVelocity(Vector3 velocity)

Parameters

velocity Vector3

SetElement(GameElement)

Sets the game element

public override void SetElement(GameElement gameElement)

Parameters

gameElement GameElement

SetLinearFactor(Vector3)

Sets the linear factor of the rigid body

public void SetLinearFactor(Vector3 factor)

Parameters

factor Vector3

SetLinearVelocity(Vector3)

Sets the linear velocity of the rigid body

public void SetLinearVelocity(Vector3 velocity)

Parameters

velocity Vector3

Sync()

Syncs the rigid body with the parent game element and offset

public void Sync()

Translate(Vector3)

Translates the rigid body

public void Translate(Vector3 translation)

Parameters

translation Vector3