Packageflare.physics.colliders
Classpublic class Collider
InheritanceCollider Inheritance Object
Implements flare.physics.IShape
Subclasses BoxCollider, MeshCollider, RayCollider, SphereCollider

A collider defines the main behavior and shape of each object in the scene. By default, a collider behaves as a kinematic object (with the exception of MeshCollider which is static by default), which means they can be manually moved or be moved by other objects but no forces are generated from these actions, objects simply push each other until there is no overlapping between them. A collider is Kinemaic unless it is set to be static, rigid body or trigger.

See also

isStatic
isRigidBody
isTrigger


Public Properties
 PropertyDefined By
  angularVelocity : Vector3D
The world space aligned angular velocity (only rigid bodies).
Collider
  collectContacts : Boolean = false
When set to true, the object stores the contact data objects after each physics.step() call.
Collider
  contactData : Vector.<ContactData>
The contact datas information stored after each physics.step() call.
Collider
  contactGroups : uint
Stores the groups in which this collider has been involved during the last physics.step() call.
Collider
  displacement : Vector3D
The world space object displacement used for correcting the position of overlaping objects.
Collider
  enabled : Boolean = true
Enable or disable the collider.
Collider
  friction : Number = 1.0
The friction of the collider from 0 - no friction, to 1 - full friction (only rigid bodies).
Collider
  gravity : Vector3D
The gravity vector.
Collider
  groups : uint = 1
Sets or gets the collision groups for each collider.
Collider
  invInertia : Matrix3D
The world space inverted inertia matrix.
Collider
  invLocalInertia : Matrix3D
The inverted local inertia matrix.
Collider
  invMass : Number = 1
The inverse mass of the collider.
Collider
  invTransform : Matrix3D
The inverse world transform matrix.
Collider
  isRigidBody : Boolean = false
Sets or gets if the collider behaves as a rigid body.
Collider
  isStatic : Boolean = false
Sets or gets if the collider behaves as a static object.
Collider
  isTrigger : Boolean = false
Sets or gets if the collider behaves as a trigger.
Collider
  linearVelocity : Vector3D
The world space aligned linear velocity (only rigid bodies).
Collider
  mass : Number = 1
The mass of the collider.
Collider
  maxX : Number = 0
The maximum position along the Z-Axis in world space.
Collider
  maxY : Number = 0
The maximum position along the Z-Axis in world space.
Collider
  maxZ : Number = 0
The maximum position along the Z-Axis in world space.
Collider
  minX : Number = 0
The minimum position along the X-Axis in world space.
Collider
  minY : Number = 0
The minimum position along the Y-Axis in world space.
Collider
  minZ : Number = 0
The minimum position along the Z-Axis in world space.
Collider
  neverSleep : Boolean = false
Gets or sets if the colider is allowed to enter sleeping mode.
Collider
  numContacts : int
The number of contact datas after each physics.step() call when collectContacts is set to true.
Collider
  offset : Vector3D
Sets or gets an offset position within the parent pivot.
Collider
  orientation : Vector3D
The orientation in world space in quaternion form.
Collider
  parent : Collider
The parent collider.
Collider
  pivot : Pivot3D
The pivot associated to this collider.
Collider
  position : Vector3D
The position in world space.
Collider
  restitution : Number = 0.0
The restitution factor of the collider from 0 - no restitution to 1 - full bouncing (only rigid bodies).
Collider
  scaledPivot : Boolean = true
When the collider pivot is scaled, set this property to true to properly calculate the collider transforms.
Collider
  shape : int
The shape of the collider.
Collider
  sleeping : Boolean = false
Gets or sets whatever the collider is in sleeping mode or not.
Collider
  sleepingFactor : Number = 0.9
A factor property which defines how fast the object will enter in sleeping mode, from 0 to 1.
Collider
  transform : Matrix3D
The world space transform matrix.
Collider
  userData : *
An object to store any custom properties, null by default.
Collider
Public Methods
 MethodDefined By
  
Creates a new Collider object.
Collider
  
addCollisionGroups(... args):void
Adds collision groups to the collider.
Collider
  
applyImpulse(x:Number, y:Number, z:Number, position:Vector3D = null):void
Applies an impulse force on the collider in world space (only rigid bodies).
Collider
  
applyLocalImpulse(x:Number, y:Number, z:Number, position:Vector3D = null):void
Applies an impulse force on the collider in local space (only rigid bodies).
Collider
  
applyLocalTorque(x:Number, y:Number, z:Number):void
Applies a torque force on the collider in local space (only rigid bodies).
Collider
  
applyTorque(x:Number, y:Number, z:Number):void
Applies a torque force on the collider in world space (only rigid bodies).
Collider
  
awake():void
Exit spleeing mode.
Collider
  
Clone this collider.
Collider
  
constrainLocalRotation(x:Number = 1, y:Number = 1, z:Number = 1):void
Allows for constraining rotation angles (only rigid bodies).
Collider
  
dispose():void
Disposes all resources used by this collider.
Collider
  
getSupportPoints(axis:Vector3D, out:Vector.<Vector3D>):int
Get the support points along an arbitraty axis.
Collider
  
hasGroup(index:int):Boolean
Checks if the collider is in the specified group.
Collider
  
project(axis:Vector3D, info:AxisInfo):void
Projects the object along an arbitrary axis.
Collider
  
removeCollisionGroups(... args):void
Removes collision groups from the collider.
Collider
  
Resets both, linear and angular velocities (only rigid bodies).
Collider
  
setCollisionGroups(... args):void
Resets and sets the collision groups to the collider.
Collider
  
setMass(mass:Number):void
Sets the collider mass and inertia for collisions and physics.
Collider
  
sleep():void
Enters in sleeping mode.
Collider
  
update(timeStep:Number):void
Updates the state of the collider properties such as its position, orientation, matrices, boundings.
Collider
  
When multiple colliders are grouped to a parent collider, the parent collider must update its mass and intertia values.
Collider
Public Constants
 ConstantDefined By
  SHAPE_BOX : int
[static]
Collider
  SHAPE_MESH : int
[static]
Collider
  SHAPE_NULL : int
[static]
Collider
  SHAPE_RAY : int
[static]
Collider
  SHAPE_SPHERE : int
[static]
Collider
Property Detail
angularVelocityproperty
public var angularVelocity:Vector3D

The world space aligned angular velocity (only rigid bodies).

collectContactsproperty 
public var collectContacts:Boolean = false

When set to true, the object stores the contact data objects after each physics.step() call. The contacts are stored in the contactData vector.

See also

contactDataproperty 
public var contactData:Vector.<ContactData>

The contact datas information stored after each physics.step() call. Because ContactData objects are reused all the time for this or other objects, use the numContacts property to know how many contacts are stored in the vector. Accessing invalid contacts may contain dirty information from previous frames or even other objects, thus, do not store these references between step() calls.

See also

contactGroupsproperty 
public var contactGroups:uint

Stores the groups in which this collider has been involved during the last physics.step() call. It is a more lightly way to know against what kind of objects this collider has collided than using collectContacts.

See also

displacementproperty 
public var displacement:Vector3D

The world space object displacement used for correcting the position of overlaping objects.

enabledproperty 
public var enabled:Boolean = true

Enable or disable the collider.

frictionproperty 
public var friction:Number = 1.0

The friction of the collider from 0 - no friction, to 1 - full friction (only rigid bodies).

gravityproperty 
public var gravity:Vector3D

The gravity vector. By default it is set to a physics.gravity reference. To change this value, set it to a new Vector3D. changing the vector directly, will affect the gravity of all other objects using the same reference.

groupsproperty 
public var groups:uint = 1

Sets or gets the collision groups for each collider.

There are 32 groups available. Colliders can be set to one or multiple groups.

Only objects within the same groups will be afected each other. If two objects do not have any group in common, all collisions will be ignored between them.

Valid group numbers are 1, 2, 4, 8, 16, 32, etc.. and the sum between them to assing multiple groups (1 + 2), (1 + 4), (2 + 8), (1 + 8 + 16), etc... A value of 0 means it is not within any collision group.

By default all colliders are set to group 1.

invInertiaproperty 
public var invInertia:Matrix3D

The world space inverted inertia matrix.

invLocalInertiaproperty 
public var invLocalInertia:Matrix3D

The inverted local inertia matrix.

invMassproperty 
public var invMass:Number = 1

The inverse mass of the collider. This value is used for kinematic and rigid bodies. To change the mass use setMass() method, do not change this value directly!.

See also

invTransformproperty 
public var invTransform:Matrix3D

The inverse world transform matrix.

isRigidBodyproperty 
public var isRigidBody:Boolean = false

Sets or gets if the collider behaves as a rigid body. Rigid bodies act and react to different forces like gravity, torque and impulses.

See also

isStaticproperty 
public var isStatic:Boolean = false

Sets or gets if the collider behaves as a static object. Static objects can not be moved by any rigid body or kinematic objects, but they can still be moved manually through its pivot or position / orientation.

See also

isTriggerproperty 
public var isTrigger:Boolean = false

Sets or gets if the collider behaves as a trigger. Triggers are commonly used to trigger events that don't need to have any reaction to physics or collisions. They can be manually moved but they wont be affected by other objects as their only purpose is to report contacts. Triggers can report contacts with kinematic, rigid bodies and other triggers, but not with static objects.

See also

linearVelocityproperty 
public var linearVelocity:Vector3D

The world space aligned linear velocity (only rigid bodies).

massproperty 
public var mass:Number = 1

The mass of the collider. This value is used for kinematic and rigid bodies. To change the mass use setMass() method, do not change this value directly!.

See also

maxXproperty 
public var maxX:Number = 0

The maximum position along the Z-Axis in world space.

maxYproperty 
public var maxY:Number = 0

The maximum position along the Z-Axis in world space.

maxZproperty 
public var maxZ:Number = 0

The maximum position along the Z-Axis in world space.

minXproperty 
public var minX:Number = 0

The minimum position along the X-Axis in world space.

minYproperty 
public var minY:Number = 0

The minimum position along the Y-Axis in world space.

minZproperty 
public var minZ:Number = 0

The minimum position along the Z-Axis in world space.

neverSleepproperty 
public var neverSleep:Boolean = false

Gets or sets if the colider is allowed to enter sleeping mode.

See also

numContactsproperty 
public var numContacts:int

The number of contact datas after each physics.step() call when collectContacts is set to true.

See also

offsetproperty 
public var offset:Vector3D

Sets or gets an offset position within the parent pivot. This property only has effect when the collider is attached to a Pivot3D, otherwise, it's get ignored.

orientationproperty 
public var orientation:Vector3D

The orientation in world space in quaternion form.

parentproperty 
public var parent:Collider

The parent collider. Child colliders are not affected directly by other objects, they just throw their changes (impulses, forces, displacement) to their parents colliders.

pivotproperty 
public var pivot:Pivot3D

The pivot associated to this collider.

positionproperty 
public var position:Vector3D

The position in world space.

restitutionproperty 
public var restitution:Number = 0.0

The restitution factor of the collider from 0 - no restitution to 1 - full bouncing (only rigid bodies).

scaledPivotproperty 
public var scaledPivot:Boolean = true

When the collider pivot is scaled, set this property to true to properly calculate the collider transforms.

shapeproperty 
public var shape:int

The shape of the collider.

See also

sleepingproperty 
public var sleeping:Boolean = false

Gets or sets whatever the collider is in sleeping mode or not.

See also

sleepingFactorproperty 
public var sleepingFactor:Number = 0.9

A factor property which defines how fast the object will enter in sleeping mode, from 0 to 1. Smaller values means the collider will enter in sleep mode more quickly.

See also

transformproperty 
public var transform:Matrix3D

The world space transform matrix.

userDataproperty 
public var userData:*

An object to store any custom properties, null by default.

Constructor Detail
Collider()Constructor
public function Collider()

Creates a new Collider object. Empty colliders can be used as a parent for other colliders.

Method Detail
addCollisionGroups()method
public function addCollisionGroups(... args):void

Adds collision groups to the collider. Groups indices should be between 1 and 32.

Parameters

... args

applyImpulse()method 
public function applyImpulse(x:Number, y:Number, z:Number, position:Vector3D = null):void

Applies an impulse force on the collider in world space (only rigid bodies).

Parameters

x:Number — X-Axis impulse in world space.
 
y:Number — Y-Axis impulse in world space.
 
z:Number — Z-Axis impulse in world space.
 
position:Vector3D (default = null) — Position of the impulse in world space. If null, only linear velocity will be affected.

applyLocalImpulse()method 
public function applyLocalImpulse(x:Number, y:Number, z:Number, position:Vector3D = null):void

Applies an impulse force on the collider in local space (only rigid bodies).

Parameters

x:Number — X-Axis impulse in local space.
 
y:Number — Y-Axis impulse in local space.
 
z:Number — Z-Axis impulse in local space.
 
position:Vector3D (default = null) — Position of the impulse in local space. If null, only linear velocity will be affected.

applyLocalTorque()method 
public function applyLocalTorque(x:Number, y:Number, z:Number):void

Applies a torque force on the collider in local space (only rigid bodies).

Parameters

x:Number — X-Axis force in local space.
 
y:Number — Y-Axis force in local space.
 
z:Number — Z-Axis force in local space.

applyTorque()method 
public function applyTorque(x:Number, y:Number, z:Number):void

Applies a torque force on the collider in world space (only rigid bodies).

Parameters

x:Number — X-Axis force in world space.
 
y:Number — Y-Axis force in world space.
 
z:Number — Z-Axis force in world space.

awake()method 
public function awake():void

Exit spleeing mode.

clone()method 
public function clone():Collider

Clone this collider.

Returns
Collider — A new cloned collider.
constrainLocalRotation()method 
public function constrainLocalRotation(x:Number = 1, y:Number = 1, z:Number = 1):void

Allows for constraining rotation angles (only rigid bodies). Values from 0 to infinity. A value of 0 means it can not rotate on certaing angle. A value of 1 menas, it rotates normally, and a higher value than 1 menas it will rotate more slowly.

Parameters

x:Number (default = 1) — The X-Axis constraint value.
 
y:Number (default = 1) — The Y-Axis constraint value.
 
z:Number (default = 1) — The Z-Axis constraint value.

dispose()method 
public function dispose():void

Disposes all resources used by this collider.

getSupportPoints()method 
public function getSupportPoints(axis:Vector3D, out:Vector.<Vector3D>):int

Get the support points along an arbitraty axis.

Parameters

axis:Vector3D — The source axis.
 
out:Vector.<Vector3D> — The result points.

Returns
int — The number of points.
hasGroup()method 
public function hasGroup(index:int):Boolean

Checks if the collider is in the specified group.

Parameters

index:int — The group index.

Returns
Boolean — true if the collider is in the specified group, otherwise, flase.
project()method 
public function project(axis:Vector3D, info:AxisInfo):void

Projects the object along an arbitrary axis.

Parameters

axis:Vector3D — The axis to project.
 
info:AxisInfo — The result information.

removeCollisionGroups()method 
public function removeCollisionGroups(... args):void

Removes collision groups from the collider. Groups indices should be between 1 and 32.

Parameters

... args

resetVelocities()method 
public function resetVelocities():void

Resets both, linear and angular velocities (only rigid bodies).

setCollisionGroups()method 
public function setCollisionGroups(... args):void

Resets and sets the collision groups to the collider. Groups indices should be between 1 and 32.

Parameters

... args

setMass()method 
public function setMass(mass:Number):void

Sets the collider mass and inertia for collisions and physics. invMass will also be calculated.

Parameters

mass:Number — The mass of the collider.

sleep()method 
public function sleep():void

Enters in sleeping mode.

update()method 
public function update(timeStep:Number):void

Updates the state of the collider properties such as its position, orientation, matrices, boundings. If the timeStep is greater than 0, the collider position and orientation will be incremented by its linearVelocity and angularVelocity.

Parameters

timeStep:Number

updateInertia()method 
public function updateInertia():void

When multiple colliders are grouped to a parent collider, the parent collider must update its mass and intertia values.

Constant Detail
SHAPE_BOXConstant
public static const SHAPE_BOX:int

SHAPE_MESHConstant 
public static const SHAPE_MESH:int

SHAPE_NULLConstant 
public static const SHAPE_NULL:int

SHAPE_RAYConstant 
public static const SHAPE_RAY:int

SHAPE_SPHEREConstant 
public static const SHAPE_SPHERE:int