A RigidBody object represents a dynamic body that physically reacts to collisions with other rigid bodies or with collision objects.
A RigidBody object can be constructed with PhysicsDevice.createRigidBody.
Summary
Calculates the world matrix of the rigid body.
Syntax
var transform = mathDevice.m43BuildIdentity();
var n, rigidBody, node;
for (n = 0; n < numNodes; n += 1)
{
rigidBody = rigidBodies[n];
node = nodes[n];
rigidBody.calculateTransform(transform, node.origin);
drawNode(node, transform);
}
The transform parameter should be a Matrix43 object and it will be set to the world matrix of the rigid body.
The optional origin parameter can be used to offset the world matrix.
Summary
Calculates the world extents of the rigid body.
Syntax
var extents = [];
rigidBody.calculateExtents(extents);
The extents parameter is the world extents of the rigid body.
Summary
Clones the rigid body.
Syntax
var clonedRigidBody = rigidBody.clone();
Returns a new rigid body identical to the original and located at the same position.
Summary
The Matrix43 object representing the rotation and location of the rigid body.
Changing the transform could be an expensive operation because the internal acceleration structures may need updating. Also, it should only be done for kinematic objects.
Syntax
// Get the current location
var matrix = rigidBody.transform;
// Move it to the origin
rigidBody.transform = mathDevice.m43BuildIdentity();
Note
This property is implemented using getters and setters. Setting the property copies the vector values to the RigidBody’s internal storage, and querieng the property generates a new vector and copies the values from the RigidBody’s internal storage.
// THIS WILL NOT WORK!!!
rigidBody.transform[10] = 4;
// THIS WILL NOT WORK!!!
VMath.m43Copy(newTransform, rigidBody.transform);
Summary
The Vector3 object representing the linear velocity of the rigid body in world space.
Syntax
// Get current linear velocity
var linearVelocity = rigidBody.linearVelocity;
// Double it
rigidBody.linearVelocity = mathDevice.v3ScalarMul(linearVelocity, 2.0);
Note
This property is implemented using getters and setters. Setting the property copies the vector values to the RigidBody’s internal storage, and querieng the property generates a new vector and copies the values from the RigidBody’s internal storage.
// THIS WILL NOT WORK!!!
rigidBody.linearVelocity[1] = 4;
// THIS WILL NOT WORK!!!
VMath.v3Copy(newVelocity, rigidBody.linearVelocity);
Summary
The Vector3 object representing the angular velocity of the rigid body.
Syntax
// Get current angular velocity
var angularVelocity = rigidBody.angularVelocity;
// Double it
rigidBody.angularVelocity = mathDevice.v3ScalarMul(angularVelocity, 2.0);
Note
This property is implemented using getters and setters. Setting the property copies the vector values to the RigidBody’s internal storage, and querieng the property generates a new vector and copies the values from the RigidBody’s internal storage.
// THIS WILL NOT WORK!!!
rigidBody.angularVelocity[1] = 4;
// THIS WILL NOT WORK!!!
VMath.v3Copy(newVelocity, rigidBody.angularVelocity);
Summary
The linear damping set to the rigid body.
Syntax
// Get current linear damping
var linearDamping = rigidBody.linearDamping;
// Double it
rigidBody.linearDamping = (2.0 * linearDamping);
Summary
The angular damping set to the rigid body.
Syntax
// Get current angular damping
var angularDamping = rigidBody.angularDamping;
// Double it
rigidBody.angularDamping = (2.0 * angularDamping);
Summary
True if the rigid body is currently flagged as active, false otherwise.
Syntax
// Is the body active
var isActive = rigidBody.active;
// Put to sleep
rigidBody.active = false;
Summary
The Shape object assigned to the rigid body.
Syntax
var shape = rigidBody.shape;
Note
Read Only
Summary
The mass of the rigid body.
Syntax
var mass = rigidBody.mass;
Note
Read Only
Summary
The Vector3 object representing the inertia of the rigid body.
Syntax
var inertia = rigidBody.inertia;
Note
Read Only
Summary
The collision group number assigned to the rigid body.
Syntax
var collisionGroup = rigidBody.group;
Note
Read Only
Summary
The collision mask number assigned to the rigid body.
Syntax
var collisionMask = rigidBody.mask;
Note
Read Only
Summary
The user object associated with the rigid body.
Syntax
// Get current user object
var sceneOwner = rigidBody.userData;
// Set a new one
rigidBody.userData = doorEntity;
Summary
The friction value of the rigid body.
Syntax
// Get current friction
var friction = rigidBody.friction;
// Double it
rigidBody.friction = (2.0 * friction);
Summary
The restitution value of the rigid body.
Syntax
// Get current restitution
var restitution = rigidBody.restitution;
// Half it
rigidBody.restitution = (0.5 * restitution);
Summary
True if the rigid body was created as kinematic, false otherwise.
Syntax
var isKinematic = rigidBody.kinematic;
Note
Read Only