Table Of Contents

Previous topic

9.18. The CollisionObject Object

Next topic

9.20. The Constraint Object

This Page

9.19. The RigidBody Object

A RigidBody object represents a dynamic body that physically reacts to collisions with other rigid bodies or with collision objects.

9.19.1. Constructor

A RigidBody object can be constructed with PhysicsDevice.createRigidBody.

9.19.2. Methods

9.19.2.1. calculateExtents

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.

9.19.2.2. clone

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.

9.19.3. Properties

9.19.3.1. transform

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();

9.19.3.2. linearVelocity

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);

9.19.3.3. angularVelocity

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);

9.19.3.4. linearDamping

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);

9.19.3.5. angularDamping

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);

9.19.3.6. active

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;

9.19.3.7. shape

Summary

The Shape object assigned to the rigid body.

Syntax

var shape = rigidBody.shape;

Note

Read Only

9.19.3.8. mass

Summary

The mass of the rigid body.

Syntax

var mass = rigidBody.mass;

Note

Read Only

9.19.3.9. inertia

Summary

The Vector3 object representing the inertia of the rigid body.

Syntax

var inertia = rigidBody.inertia;

Note

Read Only

9.19.3.10. group

Summary

The collision group number assigned to the rigid body.

Syntax

var collisionGroup = rigidBody.group;

Note

Read Only

9.19.3.11. mask

Summary

The collision mask number assigned to the rigid body.

Syntax

var collisionMask = rigidBody.mask;

Note

Read Only

9.19.3.12. userData

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;

9.19.3.13. friction

Summary

The friction value of the rigid body.

Syntax

// Get current friction
var friction = rigidBody.friction;

// Double it
rigidBody.friction = (2.0 * friction);

9.19.3.14. restitution

Summary

The restitution value of the rigid body.

Syntax

// Get current restitution
var restitution = rigidBody.restitution;

// Half it
rigidBody.restitution = (0.5 * restitution);

9.19.3.15. kinematic

Summary

True if the rigid body was created as kinematic, false otherwise.

Syntax

var isKinematic = rigidBody.kinematic;

Note

Read Only