A rigid body. To add a rigid body to a physics world, create a RigidBody
instance, create and add shapes via RigidBody.addShape
, and add the rigid
body to the physics world through World.addRigidBody
. Rigid bodies have
three motion types: dynamic, static, and kinematic. See RigidBodyType
for
details of motion types.
Constructor
Variables
Methods
inlineaddAngularVelocity(angularVelocityChange:Vec3):Void
Adds angularVelocityChange
to the angular velcity of the rigid body.
inlineaddLinearVelocity(linearVelocityChange:Vec3):Void
Adds linearVelocityChange
to the linear velcity of the rigid body.
applyAngularImpulse(impulse:Vec3):Void
Applies the angular impulse impulse
to the rigid body.
This does not change the linear velocity.
applyForce(force:Vec3, positionInWorld:Vec3):Void
Applies the force force
to positionInWorld
in world position.
applyImpulse(impulse:Vec3, positionInWorld:Vec3):Void
Applies the impulse impulse
to the rigid body at positionInWorld
in world position.
This changes both the linear velocity and the angular velocity.
applyLinearImpulse(impulse:Vec3):Void
Applies the linear impulse impulse
to the rigid body.
This does not change the angular velocity.
inlinegetAngularContactImpulse():Vec3
Returns the total angular impulse applied by contact constraints.
inlinegetAngularContactImpulseTo(angularContactImpulse:Vec3):Void
Sets angularContactImpulse
to the total angular impulse applied by contact constraints.
This does not create a new instance of Vec3
.
inlinegetAngularVelocityTo(angularVelocity:Vec3):Void
Sets angularVelocity
to the angular velocity of the rigid body.
This does not create a new intrance of Vec3
.
inlinegetContactLinkList():ContactLink
Returns the list of the contact links the rigid body is involved.
inlinegetLinearContactImpulse():Vec3
Returns the total linear impulse applied by contact constraints.
inlinegetLinearContactImpulseTo(linearContactImpulse:Vec3):Void
Sets linearContactImpulse
to the total linear impulse applied by contact constraints.
This does not create a new instance of Vec3
.
inlinegetLinearVelocityTo(linearVelocity:Vec3):Void
Sets linearVelocity
to the linear velocity of the rigid body.
This does not create a new intrance of Vec3
.
inlinegetLocalInertiaTo(inertia:Mat3):Void
Sets inertia
to the moment of inertia tensor in local space.
This does not create a new instance of Mat3
inlinegetLocalPoint(worldPoint:Vec3):Vec3
Returns the local coordinates of the point worldPoint
in world coodinates.
inlinegetLocalPointTo(worldPoint:Vec3, localPoint:Vec3):Void
Sets localPoint
to the local coordinates of the point worldPoint
in world coodinates.
This does not create a new instance of Vec3
.
inlinegetLocalVector(worldVector:Vec3):Vec3
Returns the local coordinates of the vector worldVector
in world coodinates.
inlinegetLocalVectorTo(worldVector:Vec3, localVector:Vec3):Void
Sets localVector
to the local coordinates of the vector worldVector
in world coodinates.
This does not create a new instance of Vec3
.
inlinegetMass():Float
Returns the mass of the rigid body.
If the rigid body has infinite mass, 0
will be returned.
inlinegetMassDataTo(massData:MassData):Void
Sets massData
to the mass data of the rigid body.
This does not create a new instance of MassData
.
inlinegetNext():RigidBody
Returns the next rigid body in the world.
If the next one does not exist, null
will be returned.
inlinegetOrientationTo(orientation:Quat):Void
Sets orientation
to the rotation quaternion of the rigid body.
This does not create a new instance of Quat
.
inlinegetPositionTo(position:Vec3):Void
Sets position
to the world position of the rigid body.
This does not create a new instance of Vec3
.
inlinegetPrev():RigidBody
Returns the previous rigid body in the world.
If the previous one does not exist, null
will be returned.
inlinegetRotationTo(rotation:Mat3):Void
Sets rotation
to the rotation matrix of the rigid body.
This does not create a new instance of Mat3
.
inlinegetSleepTime():Float
Returns how long the rigid body is stopping moving. This returns 0
if the body
has already slept.
inlinegetTransformTo(transform:Transform):Void
Sets transform
to the transform of the rigid body.
This does not create a new instance of Transform
.
inlinegetWorldPoint(localPoint:Vec3):Vec3
Returns the world coordinates of the point localPoint
in local coodinates.
inlinegetWorldPointTo(localPoint:Vec3, worldPoint:Vec3):Void
Sets worldPoint
to the world coordinates of the point localPoint
in local coodinates.
This does not create a new instance of Vec3
.
inlinegetWorldVector(localVector:Vec3):Vec3
Returns the world coordinates of the vector localVector
in local coodinates.
inlinegetWorldVectorTo(localVector:Vec3, worldVector:Vec3):Void
Sets worldVector
to the world coordinates of the vector localVector
in local coodinates.
This does not create a new instance of Vec3
.
inlinerotateXyz(eulerAngles:Vec3):Void
Rotates the rigid body by Euler angles eulerAngles
in radians.
inlinesetAutoSleep(autoSleepEnabled:Bool):Void
Sets the rigid body's auto sleep flag.
If auto sleep is enabled, the rigid body will automatically sleep when needed.
inlinesetGravityScale(gravityScale:Float):Void
Sets the gravity scaling factor of the rigid body to gravityScale
.
If 0
is set, the rigid body will not be affected by gravity.
inlinesetMassData(massData:MassData):Void
Sets the mass and moment of inertia of the rigid body by the mass data massData
.
The properties set by this will be overwritten when
- some shapes are added or removed
- the type of the rigid body is changed
inlinesetOrientation(quaternion:Quat):Void
Sets the rotation of the rigid body from a quaternion quaternion
.
inlinesetRotationFactor(rotationFactor:Vec3):Void
Sets the rotation factor of the rigid body to rotationFactor
.
This changes moment of inertia internally, so that the change of
angular velocity in global space along X, Y and Z axis will scale by rotationFactor.x
,
rotationFactor.y
and rotationFactor.z
times respectively.
inlinesetRotationXyz(eulerAngles:Vec3):Void
Sets the rotation of the rigid body by Euler angles eulerAngles
in radians.
inlinesetTransform(transform:Transform):Void
Sets the transform of the rigid body to transform
.
This does not keep any references to transform
.
inlinesleep():Void
Sets the rigid body's sleep flag true.
This also resets the sleeping timer of the rigid body.
inlinewakeUp():Void
Sets the rigid body's sleep flag false.
This also resets the sleeping timer of the rigid body.