Class PhysicBody3D
PhysicBody3D enables your entities to act under the control of physics.
Inheritance
Implements
Inherited Members
Namespace: Evergine.Framework.Physics3D
Assembly: Evergine.Framework.dll
Syntax
public abstract class PhysicBody3D : Behavior, IDependencyObject
Constructors
PhysicBody3D()
Initializes a new instance of the PhysicBody3D class.
Declaration
public PhysicBody3D()
Fields
PhysicManager3D
The physics manager.
Declaration
[BindSceneManager(false, true)]
protected PhysicManager3D PhysicManager3D
Field Value
Type | Description |
---|---|
PhysicManager3D |
Transform3D
The 3D transform.
Declaration
[BindComponent(true, true, BindComponentSource.Owner, null, true)]
public Transform3D Transform3D
Field Value
Type | Description |
---|---|
Transform3D |
colliderList
The list of colliders.
Declaration
protected List<Collider3D> colliderList
Field Value
Type | Description |
---|---|
List<Collider3D> |
Properties
BodyDef
Gets the body definition.
Declaration
protected abstract PhysicBodyDef3D BodyDef { get; }
Property Value
Type | Description |
---|---|
PhysicBodyDef3D |
CcdMotionThreshold
Gets or sets the CCD motion threshold.
Declaration
[RenderProperty(Tooltip = "CCD motion clamping activates for convex objects that exceed a (squared to avoid taking square roots) velocity threshold. By default this threshold is zero, which means this feature is disabled for rigid bodies.")]
public float CcdMotionThreshold { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
CCD motion clamping activates for convex objects that exceed a velocity threshold (squared to avoid taking square roots). By default, this threshold is zero, which means this feature is disabled for rigid bodies.
CcdSweptSphereRadius
Gets or sets the CCD swept sphere radius.
Declaration
[RenderProperty(Tooltip = "CCD works on an embedded sphere of radius, make sure this radius is embedded inside the convex objects, preferably smaller")]
public float CcdSweptSphereRadius { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
CCD works with an embedded sphere of radius; make sure this radius is embedded inside the convex objects, and preferably smaller.
ColliderList
Gets the list of colliders associated with this body.
Declaration
public IReadOnlyList<Collider3D> ColliderList { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Collider3D> |
CollisionCategories
Gets or sets the collision category bits.
Declaration
public CollisionCategory3D CollisionCategories { get; set; }
Property Value
Type | Description |
---|---|
CollisionCategory3D |
Friction
Gets or sets the friction coefficient, typically in the range [0,1].
Declaration
[RenderProperty(Tooltip = "Friction coefficient, usually in the range [0,1]")]
public float Friction { get; set; }
Property Value
Type | Description |
---|---|
float |
InternalBody
Gets the physical body.
Declaration
public abstract IPhysicBody3D InternalBody { get; }
Property Value
Type | Description |
---|---|
IPhysicBody3D |
IsSensor
Gets or sets a value indicating whether this body raises contact events but never generates a collision response.
Declaration
[RenderProperty(Tooltip = "This body raise contact events but never generates a collision response")]
public bool IsSensor { get; set; }
Property Value
Type | Description |
---|---|
bool |
MaskBits
Gets or sets the collision mask bits.
Declaration
public CollisionCategory3D MaskBits { get; set; }
Property Value
Type | Description |
---|---|
CollisionCategory3D |
ProcessCollision
Gets a value indicating whether we need to process collisions for this entity.
Declaration
public bool ProcessCollision { get; }
Property Value
Type | Description |
---|---|
bool |
Restitution
Gets or sets the restitution (elasticity), usually in the range [0,1].
Declaration
public float Restitution { get; set; }
Property Value
Type | Description |
---|---|
float |
RollingFriction
Gets or sets the rolling friction coefficient, usually in the range [0, 1].
Declaration
[RenderProperty(Tooltip = "rolling friction coefficient, usually in the range [0,1]")]
public float RollingFriction { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
ContactPairTest(Collider3D, PhysicBody3D, Collider3D, ICollection<ContactPoint3D>)
Performs a discrete collision test between this body and the specified body, considering only the specified colliders.
Declaration
public int ContactPairTest(Collider3D collider, PhysicBody3D otherBody, Collider3D otherBodyCollider, ICollection<ContactPoint3D> resultsOutput)
Parameters
Type | Name | Description |
---|---|---|
Collider3D | collider | The collider in this body. |
PhysicBody3D | otherBody | The other body to detect contact with. |
Collider3D | otherBodyCollider | The collider in the specified body. |
ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be recorded. |
Returns
Type | Description |
---|---|
int | The number of contacts detected. |
ContactPairTest(PhysicBody3D, ICollection<ContactPoint3D>)
Performs a discrete collision test between this body and the specified body.
Declaration
public int ContactPairTest(PhysicBody3D otherBody, ICollection<ContactPoint3D> resultsOutput)
Parameters
Type | Name | Description |
---|---|---|
PhysicBody3D | otherBody | The other body to detect contact with. |
ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be recorded. |
Returns
Type | Description |
---|---|
int | The number of contacts detected. |
ContactTest(ICollection<ContactPoint3D>)
Performs a discrete collision test between this body and all bodies in the physics world.
Declaration
public int ContactTest(ICollection<ContactPoint3D> resultsOutput)
Parameters
Type | Name | Description |
---|---|---|
ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
Returns
Type | Description |
---|---|
int | The number of contacts detected. |
OnActivated()
Invoked when the object is activated once it is attached.
Declaration
protected override void OnActivated()
Overrides
OnAttached()
Invoked when the object is attached to the system.
Declaration
protected override bool OnAttached()
Returns
Type | Description |
---|---|
bool | True if everything is OK. |
Overrides
OnDeactivated()
Invoked when the object is deactivated.
Declaration
protected override void OnDeactivated()
Overrides
OnDetach()
Invoked when the object is detached.
Declaration
protected override void OnDetach()
Overrides
OnTransformChanged(object, EventArgs)
The rotation has been changed.
Declaration
protected void OnTransformChanged(object sender, EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
object | sender | The sender. |
EventArgs | e | The event arguments. |
PointTest(Vector3)
Tests if a point is inside this body.
Declaration
public bool PointTest(Vector3 position)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | The position to detect contact. |
Returns
Type | Description |
---|---|
bool | True if this position is inside this body. |
ResetTransform(Vector3, Quaternion, Vector3)
Sets the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.
Declaration
public void ResetTransform(Vector3 position, Quaternion orientation, Vector3 scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | The world position of the body's local origin. |
Quaternion | orientation | The world rotation as a quaternion. |
Vector3 | scale | The world scale. |
Update(TimeSpan)
Allows this instance to execute custom logic during its Update
.
Declaration
protected override void Update(TimeSpan gameTime)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | gameTime | The game time. |
Overrides
Remarks
WorldToLocalPosition(Vector3)
Converts world position to local position.
Declaration
public Vector3 WorldToLocalPosition(Vector3 worldPosition)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | worldPosition | The world position. |
Returns
Type | Description |
---|---|
Vector3 | The local position. |
WorldToLocalPosition(ref Vector3, out Vector3)
Converts world position to local position.
Declaration
public void WorldToLocalPosition(ref Vector3 worldPosition, out Vector3 localPosition)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | worldPosition | The world position. |
Vector3 | localPosition | The local position. |
Events
BeginCollision
The beginning of the collision
Declaration
public event EventHandler<CollisionInfo3D> BeginCollision
Event Type
Type | Description |
---|---|
EventHandler<CollisionInfo3D> |
EndCollision
The end of collision event
Declaration
public event EventHandler<CollisionInfo3D> EndCollision
Event Type
Type | Description |
---|---|
EventHandler<CollisionInfo3D> |
UpdateCollision
The update collision event.
Declaration
public event EventHandler<CollisionInfo3D> UpdateCollision
Event Type
Type | Description |
---|---|
EventHandler<CollisionInfo3D> |