Class PhysicBody3D
PhysicBody3D enable 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 physic manager.
Declaration
[BindSceneManager(false, true)]
protected PhysicManager3D PhysicManager3D
Field Value
Type | Description |
---|---|
PhysicManager3D |
Transform3D
The transform 3D.
Declaration
[BindComponent(true, true, BindComponentSource.Owner, null, true)]
public Transform3D Transform3D
Field Value
Type | Description |
---|---|
Transform3D |
colliderList
The collider list.
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 (squared to avoid taking square roots) velocity threshold. 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 on an embedded sphere of radius, make sure this radius is embedded inside the convex objects, preferably smaller.
ColliderList
Gets the list of colliders associated to 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, usually 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 physic body.
Declaration
public abstract IPhysicBody3D InternalBody { get; }
Property Value
Type | Description |
---|---|
IPhysicBody3D |
IsSensor
Gets or sets a value indicating whether this body raise 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 collision of 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. |
Collider3D | otherBodyCollider | The collider in the specified body. |
ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
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. |
ICollection<ContactPoint3D> | resultsOutput | The collection where the contact results will be included. |
Returns
Type | Description |
---|---|
int | The number of contacts detected. |
ContactTest(ICollection<ContactPoint3D>)
Performs a discrete collision test between this body against all bodies in the physic 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 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 all 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 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 other body 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)
World 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)
World 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 begin collision
Declaration
public event EventHandler<CollisionInfo3D> BeginCollision
Event Type
Type | Description |
---|---|
EventHandler<CollisionInfo3D> |
EndCollision
The end 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> |