Class RigidBodyBehavior3D
Abstract base class for defining behaviors of 3D rigid bodies in a physics simulation.
Inheritance
Inherited Members
Namespace: Genesis.Physics
Assembly: Genesis.dll
Syntax
public abstract class RigidBodyBehavior3D : PhysicsBehavior
Constructors
RigidBodyBehavior3D(PhysicHandler)
Constructor for initializing the RigidBodyBehavior3D.
Declaration
public RigidBodyBehavior3D(PhysicHandler handler)
Parameters
Type | Name | Description |
---|---|---|
PhysicHandler | handler | The physics handler managing this rigid body. |
Properties
Offset
Offset from the parent element's location to apply to the rigid body.
Declaration
public Vec3 Offset { get; set; }
Property Value
Type | Description |
---|---|
Vec3 |
PhysicHandler
The physics handler responsible for managing this rigid body.
Declaration
public PhysicHandler PhysicHandler { get; set; }
Property Value
Type | Description |
---|---|
PhysicHandler |
RigidBody
The BulletSharp RigidBody associated with this behavior.
Declaration
public RigidBody RigidBody { get; set; }
Property Value
Type | Description |
---|---|
RigidBody |
Methods
AngularVelocity(Vec3)
Sets the angular velocity of the rigid body.
Declaration
public virtual void AngularVelocity(Vec3 value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | value | Angular velocity vector. |
AngularVelocity(float, float, float)
Sets the angular velocity of the rigid body.
Declaration
public virtual void AngularVelocity(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | Angular velocity around the X-axis. |
float | y | Angular velocity around the Y-axis. |
float | z | Angular velocity around the Z-axis. |
CalculateForwardVector(float)
Calculates the forward vector of the rigid body based on its rotation and a specified distance.
Declaration
public Vec3 CalculateForwardVector(float distance)
Parameters
Type | Name | Description |
---|---|---|
float | distance | The distance to scale the forward vector. |
Returns
Type | Description |
---|---|
Vec3 | 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.
Declaration
public Vec3 CalculateRightVector(float distance)
Parameters
Type | Name | Description |
---|---|---|
float | distance | The distance to scale the right vector. |
Returns
Type | Description |
---|---|
Vec3 | 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.
Declaration
public Vec3 CalculateUpVector(float distance)
Parameters
Type | Name | Description |
---|---|---|
float | distance | The distance to scale the up vector. |
Returns
Type | Description |
---|---|
Vec3 | The up vector scaled by the specified distance. |
CreateRigidBody(float, int, int)
Abstract method to create the rigid body. Implement this method in derived classes to define the specific behavior for creating a rigid body.
Declaration
public abstract void CreateRigidBody(float mass, int collisionGroup = -1, int collisionMask = -1)
Parameters
Type | Name | Description |
---|---|---|
float | mass | |
int | collisionGroup | |
int | collisionMask |
GetLinearVelocity()
Gets the current linear velocity of the rigid body.
Declaration
public Vec3 GetLinearVelocity()
Returns
Type | Description |
---|---|
Vec3 | A vector representing the linear velocity. |
GetLocation()
Gets the current location of the rigid body.
Declaration
public Vec3 GetLocation()
Returns
Type | Description |
---|---|
Vec3 | A vector representing the position of the rigid body. |
GetPhysicsObject()
Retrieves the physics object associated with this behavior.
Declaration
public override object GetPhysicsObject()
Returns
Type | Description |
---|---|
object | The rigid body associated with this behavior. |
Overrides
GetPhysicsObject<T>()
Retrieves the physics object associated with this behavior, cast to the specified type.
Declaration
public override T GetPhysicsObject<T>()
Returns
Type | Description |
---|---|
T | The rigid body associated with this behavior, cast to the specified type. |
Type Parameters
Name | Description |
---|---|
T | The type to cast the physics object to. |
Overrides
GetRotation()
Gets the current rotation of the rigid body as a quaternion.
Declaration
public Quaternion GetRotation()
Returns
Type | Description |
---|---|
Quaternion | The quaternion representing the rotation of the rigid body. |
LinearVelocity(Vec3)
Sets the linear velocity of the rigid body.
Declaration
public virtual void LinearVelocity(Vec3 value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | value | Linear velocity vector. |
LinearVelocity(float, float, float)
Sets the linear velocity of the rigid body.
Declaration
public virtual void LinearVelocity(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | Linear velocity along the X-axis. |
float | y | Linear velocity along the Y-axis. |
float | z | Linear velocity along the Z-axis. |
OnDestroy(Game, GameElement)
Cleanup method called when the behavior is destroyed. Override this method to provide custom cleanup logic.
Declaration
public override void OnDestroy(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent game element. |
Overrides
OnInit(Game, GameElement)
Initialization method called when the behavior is initialized. Override this method to provide custom initialization logic.
Declaration
public override void OnInit(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent game element. |
Overrides
OnRender(Game, GameElement)
Rendering method called during the render phase. Override this method to provide custom rendering logic.
Declaration
public override void OnRender(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent game element. |
Overrides
OnUpdate(Game, GameElement)
Updates the rigid body's position and rotation based on its current state in the physics simulation.
Declaration
public override void OnUpdate(Game game, GameElement parent)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
GameElement | parent | The parent game element. |
Overrides
Rotate(Vec3)
Rotates the rigid body by the specified vector of Euler angles.
Declaration
public virtual void Rotate(Vec3 value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | value | A vector containing rotation angles for X, Y, and Z axes. |
Rotate(float, float, float)
Rotates the rigid body by the specified Euler angles.
Declaration
public virtual void Rotate(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The rotation angle around the X-axis. |
float | y | The rotation angle around the Y-axis. |
float | z | The rotation angle around the Z-axis. |
Translate(Vec3)
Translates the rigid body by the specified vector.
Declaration
public virtual void Translate(Vec3 value)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | value | The translation vector. |
Translate(float, float, float)
Translates the rigid body by the specified distances.
Declaration
public virtual void Translate(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The distance to translate along the X-axis. |
float | y | The distance to translate along the Y-axis. |
float | z | The distance to translate along the Z-axis. |