org.jbox2d.dynamics
Class Fixture

java.lang.Object
  extended by org.jbox2d.dynamics.Fixture

public class Fixture
extends Object

A fixture is used to attach a shape to a body for collision detection. A fixture inherits its transform from its parent. Fixtures hold additional non-geometric data such as friction, collision filters, etc. Fixtures are created via b2Body::CreateFixture.

Author:
daniel

Field Summary
 AABB m_aabb
           
 Body m_body
           
 float m_density
           
 Filter m_filter
           
 float m_friction
           
 boolean m_isSensor
           
 Fixture m_next
           
 DynamicTreeNode m_proxy
           
 float m_restitution
           
 Shape m_shape
           
 Object m_userData
           
 
Constructor Summary
Fixture()
           
 
Method Summary
 void create(Body body, FixtureDef def)
           
 void createProxy(BroadPhase broadPhase, Transform xf)
           
 void destroy()
           
 void destroyProxy(BroadPhase broadPhase)
          Internal method
 AABB getAABB()
          Get the fixture's AABB.
 Body getBody()
          Get the parent body of this fixture.
 float getDensity()
           
 Filter getFilterData()
          Get the contact filtering data.
 float getFriction()
          Get the coefficient of friction.
 void getMassData(MassData massData)
          Get the mass data for this fixture.
 Fixture getNext()
          Get the next fixture in the parent body's fixture list.
 float getRestitution()
          Get the coefficient of restitution.
 Shape getShape()
          Get the child shape.
 ShapeType getType()
          Get the type of the child shape.
 Object getUserData()
          Get the user data that was assigned in the fixture definition.
 boolean isSensor()
          Is this fixture a sensor (non-solid)?
 boolean raycast(RayCastOutput output, RayCastInput input)
          Cast a ray against this shape.
 void setDensity(float density)
           
 void setFilterData(Filter filter)
          Set the contact filtering data.
 void setFriction(float friction)
          Set the coefficient of friction.
 void setRestitution(float restitution)
          Set the coefficient of restitution.
 void setSensor(boolean sensor)
          Set if this fixture is a sensor.
 void setUserData(Object data)
          Set the user data.
protected  void synchronize(BroadPhase broadPhase, Transform transform1, Transform transform2)
          Internal method
 boolean testPoint(Vec2 p)
          Test a point for containment in this fixture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_aabb

public final AABB m_aabb

m_density

public float m_density

m_next

public Fixture m_next

m_body

public Body m_body

m_shape

public Shape m_shape

m_friction

public float m_friction

m_restitution

public float m_restitution

m_proxy

public DynamicTreeNode m_proxy

m_filter

public final Filter m_filter

m_isSensor

public boolean m_isSensor

m_userData

public Object m_userData
Constructor Detail

Fixture

public Fixture()
Method Detail

getType

public ShapeType getType()
Get the type of the child shape. You can use this to down cast to the concrete shape.

Returns:
the shape type.

getShape

public Shape getShape()
Get the child shape. You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms.

Returns:

isSensor

public boolean isSensor()
Is this fixture a sensor (non-solid)?

Returns:
the true if the shape is a sensor.

setSensor

public void setSensor(boolean sensor)
Set if this fixture is a sensor.

Parameters:
sensor -

setFilterData

public void setFilterData(Filter filter)
Set the contact filtering data. This is an expensive operation and should not be called frequently. This will not update contacts until the next time step when either parent body is awake.

Parameters:
filter -

getFilterData

public Filter getFilterData()
Get the contact filtering data.

Returns:

getBody

public Body getBody()
Get the parent body of this fixture. This is NULL if the fixture is not attached.

Returns:
the parent body.

getNext

public Fixture getNext()
Get the next fixture in the parent body's fixture list.

Returns:
the next shape.

setDensity

public void setDensity(float density)

getDensity

public float getDensity()

getUserData

public Object getUserData()
Get the user data that was assigned in the fixture definition. Use this to store your application specific data.

Returns:

setUserData

public void setUserData(Object data)
Set the user data. Use this to store your application specific data.

Parameters:
data -

testPoint

public boolean testPoint(Vec2 p)
Test a point for containment in this fixture. This only works for convex shapes.

Parameters:
xf - the shape world transform.
p - a point in world coordinates.
p -
Returns:

raycast

public boolean raycast(RayCastOutput output,
                       RayCastInput input)
Cast a ray against this shape.

Parameters:
output - the ray-cast results.
input - the ray-cast input parameters.
output -
input -

getMassData

public void getMassData(MassData massData)
Get the mass data for this fixture. The mass data is based on the density and the shape. The rotational inertia is about the shape's origin.


getFriction

public float getFriction()
Get the coefficient of friction.

Returns:

setFriction

public void setFriction(float friction)
Set the coefficient of friction.

Parameters:
friction -

getRestitution

public float getRestitution()
Get the coefficient of restitution.

Returns:

setRestitution

public void setRestitution(float restitution)
Set the coefficient of restitution.

Parameters:
restitution -

getAABB

public AABB getAABB()
Get the fixture's AABB. This AABB may be enlarge and/or stale. If you need a more accurate AABB, compute it using the shape and the body transform.

Returns:

create

public void create(Body body,
                   FixtureDef def)

destroy

public void destroy()

createProxy

public void createProxy(BroadPhase broadPhase,
                        Transform xf)

destroyProxy

public void destroyProxy(BroadPhase broadPhase)
Internal method

Parameters:
broadPhase -

synchronize

protected void synchronize(BroadPhase broadPhase,
                           Transform transform1,
                           Transform transform2)
Internal method

Parameters:
broadPhase -
xf1 -
xf2 -


Copyright © 2012. All Rights Reserved.