Class RigidBodyBehavior
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
physicsHandlerPhysicsHandler
Properties
AngularVelocity
Gets or sets the angular and linear velocity of the rigid body
public Vector3 AngularVelocity { get; set; }
Property Value
Friction
Gets or sets the friction of the rigid body
public float Friction { get; set; }
Property Value
LinearVelocity
Gets or sets the linear velocity of the rigid body
public Vector3 LinearVelocity { get; set; }
Property Value
Offset
The offset of the rigid body
public Vector3 Offset { get; set; }
Property Value
Parent
The parent game element
public GameElement Parent { get; set; }
Property Value
Restitution
Gets or sets the restitution of the rigid body
public float Restitution { get; set; }
Property Value
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
forceVector3
ApplyCentralImpulse(Vector3)
Applies a central impulse to the rigid body
public void ApplyCentralImpulse(Vector3 impulse)
Parameters
impulseVector3
ApplyForce(Vector3, Vector3)
Applies a force to the rigid body at a specified position
public void ApplyForce(Vector3 force, Vector3 relPos)
Parameters
ApplyImpulse(Vector3, Vector3)
Applies an impulse to the rigid body at a specified position
public void ApplyImpulse(Vector3 impulse, Vector3 relPos)
Parameters
ApplyTorque(Vector3)
Applies a torque to the rigid body
public void ApplyTorque(Vector3 torque)
Parameters
torqueVector3
CalculateForwardVector(float)
Calculates the forward vector of the rigid body based on its rotation and a specified distance.
public Vector3 CalculateForwardVector(float distance)
Parameters
distancefloatThe 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
distancefloatThe 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
distancefloatThe 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
GetAngularVelocity()
Returns the current angular velocity of the rigid body
public Vector3 GetAngularVelocity()
Returns
GetElement()
Gets the game element
public override GameElement GetElement()
Returns
GetLinearVelocity()
Returns the current linear velocity of the rigid body
public Vector3 GetLinearVelocity()
Returns
GetLocation()
public Vector3 GetLocation()
Returns
GetPhysicsObject()
Gets the physics object
public override object GetPhysicsObject()
Returns
GetRotation()
public Quaternion GetRotation()
Returns
OnCollide(Collision)
On collide event
public override void OnCollide(Collision collision)
Parameters
collisionCollision
OnDispose(BaseScene, IRenderDevice)
Disposes the rigid body
public override void OnDispose(BaseScene scene, IRenderDevice renderer)
Parameters
sceneBaseScenerendererIRenderDevice
OnInit(BaseScene, Viewport, IRenderDevice)
Initializes the rigid body
public override void OnInit(BaseScene scene, Viewport viewport, IRenderDevice renderer)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevice
OnRender(BaseScene, Viewport, IRenderDevice, Camera)
Renders the rigid body
public override void OnRender(BaseScene scene, Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevicecameraCamera
OnUpdate(BaseScene, float)
Updates the rigid body
public override void OnUpdate(BaseScene scene, float dt)
Parameters
RemoveRigidBody()
Removes the rigid body
public virtual void RemoveRigidBody()
Rotate(Quaternion)
Rotates the rigid body
public void Rotate(Quaternion rotation)
Parameters
rotationQuaternion
Rotate(Vector3)
Rotates the rigid body
public void Rotate(Vector3 rotation)
Parameters
rotationVector3
SetAngularFactor(Vector3)
Sets the angular factor of the rigid body
public void SetAngularFactor(Vector3 factor)
Parameters
factorVector3
SetAngularVelocity(Vector3)
Sets the angular velocity of the rigid body
public void SetAngularVelocity(Vector3 velocity)
Parameters
velocityVector3
SetElement(GameElement)
Sets the game element
public override void SetElement(GameElement gameElement)
Parameters
gameElementGameElement
SetLinearFactor(Vector3)
Sets the linear factor of the rigid body
public void SetLinearFactor(Vector3 factor)
Parameters
factorVector3
SetLinearVelocity(Vector3)
Sets the linear velocity of the rigid body
public void SetLinearVelocity(Vector3 velocity)
Parameters
velocityVector3
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
translationVector3