Class Shape
java.lang.Object
org.jbox2d.collision.shapes.Shape
- Direct Known Subclasses:
ChainShape, CircleShape, EdgeShape, PolygonShape
public abstract class Shape
extends java.lang.Object
A shape is used for collision detection. You can create a shape however you like. Shapes used for
simulation in World are created automatically when a Fixture is created. Shapes may encapsulate a
one or more child shapes.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Shapeclone()abstract voidcomputeAABB(AABB aabb, Transform xf, int childIndex) Given a transform, compute the associated axis aligned bounding box for a child shape.abstract voidcomputeMass(MassData massData, float density) Compute the mass properties of this shape using its dimensions and density.abstract intGet the number of child primitivesfloatThe radius of the underlying shape.getType()Get the type of this shape.abstract booleanraycast(RayCastOutput output, RayCastInput input, Transform transform, int childIndex) Cast a ray against a child shape.voidsetRadius(float radius) Sets the radius of the underlying shape.abstract booleanTest a point for containment in this shape.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
m_type
-
m_radius
public float m_radius
-
-
Constructor Details
-
Shape
-
-
Method Details
-
getType
Get the type of this shape. You can use this to down cast to the concrete shape.- Returns:
- the shape type.
-
getRadius
public float getRadius()The radius of the underlying shape. This can refer to different things depending on the shape implementation- Returns:
-
setRadius
public void setRadius(float radius) Sets the radius of the underlying shape. This can refer to different things depending on the implementation- Parameters:
radius-
-
getChildCount
public abstract int getChildCount()Get the number of child primitives- Returns:
-
testPoint
-
raycast
public abstract boolean raycast(RayCastOutput output, RayCastInput input, Transform transform, int childIndex) Cast a ray against a child shape.- Parameters:
argOutput- the ray-cast results.argInput- the ray-cast input parameters.argTransform- the transform to be applied to the shape.argChildIndex- the child shape index- Returns:
- if hit
-
computeAABB
-
computeMass
Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin.- Parameters:
massData- returns the mass data for this shape.density- the density in kilograms per meter squared.
-
clone
- Overrides:
clonein classjava.lang.Object
-