Package | Box2D.Collision.Shapes |
Class | public class b2Shape |
Subclasses | b2CircleShape, b2EdgeShape, b2PolygonShape |
Source | b2Shape.as |
Warning: you cannot reuse shapes.
Method | Defined by | ||
---|---|---|---|
Given a transform, compute the associated axis aligned bounding box for this shape.
| b2Shape | ||
ComputeMass(massData:b2MassData):void
Compute the mass properties of this shape using its dimensions and density.
| b2Shape | ||
Given two transforms, compute the associated swept axis aligned bounding box for this shape.
| b2Shape | ||
Get the parent body of this shape.
| b2Shape | ||
Get the contact filtering data.
| b2Shape | ||
GetFriction():Number
Get the coefficient of friction.
| b2Shape | ||
Get the next shape in the parent body's shape list.
| b2Shape | ||
GetRestitution():Number
Get the coefficient of restitution.
| b2Shape | ||
GetSweepRadius():Number
Get the maximum radius about the parent body's center of mass.
| b2Shape | ||
GetType():int
Get the type of this shape.
| b2Shape | ||
GetUserData():*
Get the user data that was assigned in the shape definition.
| b2Shape | ||
IsSensor():Boolean
Is this shape a sensor (non-solid)?
| b2Shape | ||
SetFilterData(filter:b2FilterData):void
Set the contact filtering data.
| b2Shape | ||
SetFriction(friction:Number):void
Set the coefficient of friction.
| b2Shape | ||
SetRestitution(restitution:Number):void
Set the coefficient of restitution.
| b2Shape | ||
SetUserData(data:*):void
Set the user data.
| b2Shape | ||
Test a point for containment in this shape.
| b2Shape | ||
Perform a ray cast against this shape.
| b2Shape |
Constant | Defined by | ||
---|---|---|---|
e_hitCollide : int = 1 [static] Return value for TestSegment indicating a hit.
| b2Shape | ||
e_missCollide : int = 0 [static] Return value for TestSegment indicating a miss.
| b2Shape | ||
e_startsInsideCollide : int = -1 [static] Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.
| b2Shape |
ComputeAABB | () | method |
public function ComputeAABB(aabb:b2AABB, xf:b2XForm):void
Given a transform, compute the associated axis aligned bounding box for this shape.
Parametersaabb:b2AABB — returns the axis aligned box.
|
|
xf:b2XForm — the world transform of the shape.
|
ComputeMass | () | method |
public function ComputeMass(massData:b2MassData):void
Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.
ParametersmassData:b2MassData — returns the mass data for this shape.
|
ComputeSweptAABB | () | method |
public function ComputeSweptAABB(aabb:b2AABB, xf1:b2XForm, xf2:b2XForm):void
Given two transforms, compute the associated swept axis aligned bounding box for this shape.
Parametersaabb:b2AABB — returns the axis aligned box.
|
|
xf1:b2XForm — the starting shape world transform.
|
|
xf2:b2XForm — the ending shape world transform.
|
GetBody | () | method |
public function GetBody():b2Body
Get the parent body of this shape. This is NULL if the shape is not attached.
Returnsb2Body —
the parent body.
|
GetFilterData | () | method |
GetFriction | () | method |
public function GetFriction():Number
Get the coefficient of friction.
ReturnsNumber |
GetNext | () | method |
public function GetNext():b2Shape
Get the next shape in the parent body's shape list.
Returnsb2Shape —
the next shape.
|
GetRestitution | () | method |
public function GetRestitution():Number
Get the coefficient of restitution.
ReturnsNumber |
GetSweepRadius | () | method |
public function GetSweepRadius():Number
Get the maximum radius about the parent body's center of mass.
ReturnsNumber |
GetType | () | method |
public function GetType():int
Get the type of this shape. You can use this to down cast to the concrete shape.
Returnsint — the shape type.
|
GetUserData | () | method |
public function GetUserData():*
Get the user data that was assigned in the shape definition. Use this to store your application specific data.
Returns* |
IsSensor | () | method |
public function IsSensor():Boolean
Is this shape a sensor (non-solid)?
ReturnsBoolean — the true if the shape is a sensor.
|
SetFilterData | () | method |
public function SetFilterData(filter:b2FilterData):void
Set the contact filtering data. You must call b2World.Refilter to correct existing contacts/non-contacts.
Parametersfilter:b2FilterData |
See also
SetFriction | () | method |
public function SetFriction(friction:Number):void
Set the coefficient of friction.
Parametersfriction:Number |
SetRestitution | () | method |
public function SetRestitution(restitution:Number):void
Set the coefficient of restitution.
Parametersrestitution:Number |
SetUserData | () | method |
public function SetUserData(data:*):void
Set the user data. Use this to store your application specific data.
Parametersdata:* |
TestPoint | () | method |
public function TestPoint(xf:b2XForm, p:b2Vec2):Boolean
Test a point for containment in this shape. This only works for convex shapes.
Parametersxf:b2XForm — the shape world transform.
|
|
p:b2Vec2 — a point in world coordinates.
|
Boolean |
TestSegment | () | method |
public function TestSegment(xf:b2XForm, lambda:Array, normal:b2Vec2, segment:b2Segment, maxLambda:Number):int
Perform a ray cast against this shape.
Parametersxf:b2XForm — the shape world transform.
|
|
lambda:Array — returns the hit fraction. You can use this to compute the contact point:
p = (1 - lambda) segment.p1 + lambda segment.p2.
lambda should be an array with one member. After calling TestSegment, you can retrieve the output value with
lambda[0].
|
|
normal:b2Vec2 — returns the normal at the contact point. If there is no intersection, the normal
is not set.
|
|
segment:b2Segment — defines the begin and end point of the ray cast.
|
|
maxLambda:Number — a number typically in the range [0,1].
|
int — b2Shape.e_hitCollide if there was an intersection, b2Shape.e_startsInsideCollide if the point is inside and b2Shape.e_missCollide otherwise.
|
e_hitCollide | constant |
public static const e_hitCollide:int = 1
Return value for TestSegment indicating a hit.
e_missCollide | constant |
public static const e_missCollide:int = 0
Return value for TestSegment indicating a miss.
e_startsInsideCollide | constant |
public static const e_startsInsideCollide:int = -1
Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.