Package org.jbox2d.collision.shapes
Class ChainShape
- java.lang.Object
-
- org.jbox2d.collision.shapes.Shape
-
- org.jbox2d.collision.shapes.ChainShape
-
public class ChainShape extends Shape
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside and outside collision. Therefore, you may use any winding order. Since there may be many vertices, they are allocated using Alloc. Connectivity information is used to create smooth collisions. WARNING The chain will not collide properly if there are self-intersections.
-
-
Field Summary
Fields Modifier and Type Field Description int
m_count
boolean
m_hasNextVertex
boolean
m_hasPrevVertex
Vec2
m_nextVertex
Vec2
m_prevVertex
Vec2[]
m_vertices
private EdgeShape
pool0
-
Constructor Summary
Constructors Constructor Description ChainShape()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Shape
clone()
void
computeAABB(AABB aabb, Transform xf, int childIndex)
Given a transform, compute the associated axis aligned bounding box for a child shape.void
computeMass(MassData massData, float density)
Compute the mass properties of this shape using its dimensions and density.void
createChain(Vec2[] vertices, int count)
Create a chain with isolated end vertices.void
createLoop(Vec2[] vertices, int count)
Create a loop.int
getChildCount()
Get the number of child primitivesvoid
getChildEdge(EdgeShape edge, int index)
Get a child edge.boolean
raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex)
Cast a ray against a child shape.void
setNextVertex(Vec2 nextVertex)
Establish connectivity to a vertex that follows the last vertex.void
setPrevVertex(Vec2 prevVertex)
Establish connectivity to a vertex that precedes the first vertex.boolean
testPoint(Transform xf, Vec2 p)
Test a point for containment in this shape.
-
-
-
Method Detail
-
getChildCount
public int getChildCount()
Description copied from class:Shape
Get the number of child primitives- Specified by:
getChildCount
in classShape
- Returns:
-
getChildEdge
public void getChildEdge(EdgeShape edge, int index)
Get a child edge.
-
testPoint
public boolean testPoint(Transform xf, Vec2 p)
Description copied from class:Shape
Test a point for containment in this shape. This only works for convex shapes.
-
raycast
public boolean raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex)
Description copied from class:Shape
Cast a ray against a child shape.
-
computeAABB
public void computeAABB(AABB aabb, Transform xf, int childIndex)
Description copied from class:Shape
Given a transform, compute the associated axis aligned bounding box for a child shape.- Specified by:
computeAABB
in classShape
-
computeMass
public void computeMass(MassData massData, float density)
Description copied from class:Shape
Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin.- Specified by:
computeMass
in classShape
- Parameters:
massData
- returns the mass data for this shape.density
- the density in kilograms per meter squared.
-
createLoop
public void createLoop(Vec2[] vertices, int count)
Create a loop. This automatically adjusts connectivity.- Parameters:
vertices
- an array of vertices, these are copiedcount
- the vertex count
-
createChain
public void createChain(Vec2[] vertices, int count)
Create a chain with isolated end vertices.- Parameters:
vertices
- an array of vertices, these are copiedcount
- the vertex count
-
setPrevVertex
public void setPrevVertex(Vec2 prevVertex)
Establish connectivity to a vertex that precedes the first vertex. Don't call this for loops.- Parameters:
prevVertex
-
-
setNextVertex
public void setNextVertex(Vec2 nextVertex)
Establish connectivity to a vertex that follows the last vertex. Don't call this for loops.- Parameters:
nextVertex
-
-
-