public abstract class FBody extends FDrawable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_allowSleep |
protected float |
m_angle |
protected float |
m_angularDamping |
protected float |
m_angularVelocity |
protected org.jbox2d.dynamics.Body |
m_body |
protected boolean |
m_bullet |
protected int |
m_categoryBits |
protected float |
m_density |
protected int |
m_filterBits |
protected org.jbox2d.common.Vec2 |
m_force |
protected float |
m_friction |
protected boolean |
m_grabbable |
protected int |
m_groupIndex |
protected boolean |
m_isSleeping |
protected float |
m_linearDamping |
protected org.jbox2d.common.Vec2 |
m_linearVelocity |
protected String |
m_name |
protected FBody |
m_parent |
protected org.jbox2d.common.Vec2 |
m_position |
protected float |
m_restitution |
protected boolean |
m_rotatable |
protected boolean |
m_sensor |
protected org.jbox2d.collision.shapes.Shape |
m_shape |
protected boolean |
m_static |
protected float |
m_torque |
protected FWorld |
m_world |
m_drawable, m_fill, m_fillColor, m_image, m_imageAlpha, m_mask, m_stroke, m_strokeColor, m_strokeWeight| Constructor and Description |
|---|
FBody() |
| Modifier and Type | Method and Description |
|---|---|
void |
addForce(float fx,
float fy)
Aply a force on the center of the body.
|
void |
addForce(float fx,
float fy,
float px,
float py)
Apply a force to a given point of the body.
|
void |
addImpulse(float fx,
float fy)
Apply an impulse on the center of the body.
|
void |
addImpulse(float fx,
float fy,
float px,
float py)
Apply an impulse to a given point of the body.
|
void |
addTorque(float torque)
Add a rotation force (a torque) to the body.
|
void |
addToWorld(FWorld world) |
void |
adjustAngularVelocity(float dw)
Adjust the rotation velocity of the body.
|
void |
adjustPosition(float dx,
float dy)
Adjust the position of the body.
|
void |
adjustRotation(float dw)
Adjust the rotation of the body.
|
void |
adjustVelocity(float dvx,
float dvy)
Adjust the velocity of the body.
|
protected void |
applyMatrix(def.processing.core.PGraphics applet) |
protected org.jbox2d.collision.AABB |
getAABB() |
float |
getAngularVelocity()
Returns the rotation velocity of the body.
|
protected org.jbox2d.collision.AABB |
getBB() |
protected ArrayList |
getBodies() |
org.jbox2d.dynamics.Body |
getBox2dBody()
WARNING: This method is internal only and may change someday.
|
int |
getCategoryBits() |
ArrayList |
getContacts()
Return a list of contacts currently involving the body.
|
float |
getDensity()
Get the density of the body.
|
int |
getFilterBits() |
float |
getForceX()
Get the x coordinate of the force applied to the center of the body.
|
float |
getForceY()
Get the y coordinate of the force applied to the center of the body.
|
int |
getGroupIndex()
Get the group to which this body belongs.
|
ArrayList |
getJoints()
Returns a list with all the joints with a connection to the body
|
protected org.jbox2d.common.Vec2 |
getLocalWorldPoint(org.jbox2d.common.Vec2 p) |
float |
getMass()
Returns the mass of the body.
|
String |
getName()
Get the name of the body.
|
FBody |
getParent() |
protected org.jbox2d.collision.shapes.ShapeDef |
getProcessedShapeDef() |
float |
getRotation()
Returns the rotation of the body.
|
protected org.jbox2d.collision.shapes.ShapeDef |
getShapeDef() |
protected ArrayList |
getShapeDefs() |
ArrayList |
getTouching()
Return a list of bodies currently touching the body.
|
protected org.jbox2d.collision.shapes.ShapeDef |
getTransformedShapeDef() |
float |
getVelocityX()
Returns the horizontal velocity of the body.
|
float |
getVelocityY()
Returns the vertical velocity of the body.
|
float |
getX()
Returns the horizontal position of the body.
|
float |
getY()
Returns the vertical position of the body.
|
boolean |
isConnected(FBody other)
Returns true if the body is joint to the body passed as argument
|
boolean |
isResting()
Deprecated.
|
boolean |
isSensor()
Returns whether the body is a sensor.
|
boolean |
isSleeping()
Indicates whether the body is in a sleeping state.
|
boolean |
isStatic()
Returns whether the body is static.
|
boolean |
isTouchingBody(FBody b)
Return whether the body is currently touching the body passed as argument.
|
protected void |
postDraw(def.processing.core.PGraphics applet) |
protected void |
postDrawDebug(def.processing.core.PGraphics applet) |
protected void |
preDraw(def.processing.core.PGraphics applet) |
protected void |
preDrawDebug(def.processing.core.PGraphics applet) |
protected void |
processBody(org.jbox2d.dynamics.Body bd,
org.jbox2d.collision.shapes.ShapeDef sd) |
protected org.jbox2d.collision.shapes.ShapeDef |
processShapeDef(org.jbox2d.collision.shapes.ShapeDef sd) |
void |
recreateInWorld() |
void |
removeFromWorld() |
void |
resetForces()
Remove all the forces that are applied to the body.
|
void |
setAllowSleeping(boolean allowSleep)
Set whether the body can sleep.
|
void |
setAngularDamping(float damping)
Set the damping of the rotation movement of the body.
|
void |
setAngularVelocity(float w)
Set the rotation velocity of the body.
|
void |
setBullet(boolean value)
Set whether the body is a bullet.
|
void |
setCategoryBits(int mask) |
void |
setDamping(float damping)
Set the damping of the translation movement of the body.
|
void |
setDensity(float density)
Set the density of the body.
|
void |
setFilterBits(int mask) |
void |
setForce(float fx,
float fy)
Set the force applied to the center of the body.
|
void |
setFriction(float friction)
Set the friction of the body.
|
void |
setGrabbable(boolean value)
Control if this body can be grabbed by the mouse, when clicked on.
|
void |
setGroupIndex(int index)
Control the group to which this body belongs.
|
void |
setName(String name)
Set the name of the body.
|
void |
setParent(FBody b) |
void |
setPosition(float x,
float y)
Set the position of the body.
|
protected void |
setPosition(org.jbox2d.common.Vec2 position) |
void |
setRestitution(float restitution)
Set the restitution of the body.
|
void |
setRotatable(boolean rotatable)
Set whether the body can rotate.
|
void |
setRotation(float w)
Set the rotation of the body.
|
void |
setSensor(boolean value)
Set whether the body is a sensor.
|
void |
setState(FBody b) |
void |
setStateFromWorld() |
void |
setStatic(boolean value)
Set whether the body is static.
|
void |
setStaticBody(boolean value)
Set whether the body is static.
|
void |
setVelocity(float vx,
float vy)
Set the velocity of the body.
|
protected void |
updateMass() |
void |
wakeUp()
Wake up the body from a sleeping state.
|
appletFill, appletFillStroke, appletStroke, attachImage, dettachImage, draw, drawDebug, drawImage, getFillColor, getImageAlpha, isDrawable, setDrawable, setFill, setFill, setFill, setFill, setFillColor, setImageAlpha, setNoFill, setNoStroke, setStroke, setStroke, setStroke, setStroke, setStrokeColor, setStrokeWeight, updateStyleprotected float m_density
protected float m_restitution
protected float m_friction
protected boolean m_bullet
protected boolean m_sensor
protected boolean m_static
protected float m_linearDamping
protected float m_angularDamping
protected boolean m_rotatable
protected boolean m_allowSleep
protected boolean m_isSleeping
protected int m_groupIndex
protected int m_filterBits
protected int m_categoryBits
protected org.jbox2d.common.Vec2 m_linearVelocity
protected float m_angularVelocity
protected org.jbox2d.common.Vec2 m_force
protected float m_torque
protected org.jbox2d.common.Vec2 m_position
protected float m_angle
protected String m_name
protected org.jbox2d.dynamics.Body m_body
protected FWorld m_world
protected FBody m_parent
protected boolean m_grabbable
protected org.jbox2d.collision.shapes.Shape m_shape
protected void processBody(org.jbox2d.dynamics.Body bd,
org.jbox2d.collision.shapes.ShapeDef sd)
public org.jbox2d.dynamics.Body getBox2dBody()
public int getGroupIndex()
public void addToWorld(FWorld world)
public void setState(FBody b)
public void setStateFromWorld()
public void recreateInWorld()
public void removeFromWorld()
protected org.jbox2d.collision.shapes.ShapeDef getShapeDef()
protected org.jbox2d.collision.shapes.ShapeDef getTransformedShapeDef()
protected org.jbox2d.collision.shapes.ShapeDef getProcessedShapeDef()
protected ArrayList getShapeDefs()
protected ArrayList getBodies()
protected org.jbox2d.collision.shapes.ShapeDef processShapeDef(org.jbox2d.collision.shapes.ShapeDef sd)
protected void preDraw(def.processing.core.PGraphics applet)
protected void postDraw(def.processing.core.PGraphics applet)
protected void preDrawDebug(def.processing.core.PGraphics applet)
protected void postDrawDebug(def.processing.core.PGraphics applet)
protected org.jbox2d.collision.AABB getAABB()
protected org.jbox2d.collision.AABB getBB()
protected void applyMatrix(def.processing.core.PGraphics applet)
public void setGroupIndex(int index)
index - the index of the grouppublic void setFilterBits(int mask)
public void setCategoryBits(int mask)
public int getCategoryBits()
public int getFilterBits()
public void setParent(FBody b)
public FBody getParent()
public void setGrabbable(boolean value)
value - if true and the world it belongs to is grabbable, then the body is grabbable by the mouseFWorld.setGrabbable(boolean)public void setForce(float fx,
float fy)
fx - the x coordinate of the forcefy - the y coordinate of the forceaddForce(float,float)public float getForceX()
addForce(float,float),
getForceY()public float getForceY()
addForce(float,float),
getForceX()public void addTorque(float torque)
torque - the value of the torqueaddForce(float,float),
addForce(float,float,float,float)public void addForce(float fx,
float fy)
fx - the x coordinate of the forcefy - the y coordinate of the forceaddTorque(float),
addForce(float,float,float,float)public void addImpulse(float fx,
float fy)
fx - the x coordinate of the forcefy - the y coordinate of the forceaddTorque(float),
addForce(float,float,float,float)public void addForce(float fx,
float fy,
float px,
float py)
fx - the x coordinate of the forcefy - the y coordinate of the forcepx - the x position relative to the body's center, where to apply the forcepy - the y position relative to the body's center, where to apply the forceaddTorque(float),
addImpulse(float,float,float,float)public void addImpulse(float fx,
float fy,
float px,
float py)
fx - the x coordinate of the forcefy - the y coordinate of the forcepx - the x position relative to the body's center, where to apply the forcepy - the y position relative to the body's center, where to apply the forceaddTorque(float),
addForce(float,float,float,float)public void resetForces()
public float getVelocityX()
public float getVelocityY()
public void setVelocity(float vx,
float vy)
vx - the horizontal velocity of the body in pixels per secondvy - the vertical velocity of the body in pixels per secondpublic void adjustVelocity(float dvx,
float dvy)
dvx - the horizontal velocity to be added to the body in pixels per seconddvy - the vertical velocity to be added to the body in pixels per secondpublic float getX()
getY(),
setPosition(float,float)public float getY()
getX(),
setPosition(float,float)public void setPosition(float x,
float y)
x - the horizontal position of the body in pixelsy - the vertical position of the body in pixelsprotected void setPosition(org.jbox2d.common.Vec2 position)
public void adjustPosition(float dx,
float dy)
dx - the horizontal position to be added to the body in pixelsdy - the vertical position to be added to the body in pixelspublic float getRotation()
setRotation(float)public void setRotation(float w)
w - the rotation of the body in radiansgetRotation()public void adjustRotation(float dw)
dw - the rotation to be added to the body in radiansgetRotation(),
setRotation(float)public boolean isResting()
public boolean isSleeping()
wakeUp(),
setAllowSleeping(boolean)public void wakeUp()
isSleeping(),
setAllowSleeping(boolean)public float getAngularVelocity()
setAngularVelocity(float),
adjustAngularVelocity(float)public void setAngularVelocity(float w)
w - the rotation velocity of the body in radians per secondpublic void adjustAngularVelocity(float dw)
dw - the rotation velocity to be added to the body in radians per secondgetAngularVelocity(),
setAngularVelocity(float)public void setAngularDamping(float damping)
damping - the damping of the rotation movement of the bodysetDamping(float)public void setDamping(float damping)
damping - the damping of the translation movement of the bodysetAngularDamping(float)public void setName(String name)
name - the name of the bodypublic String getName()
public void setDensity(float density)
density - the density of the bodypublic float getDensity()
protected void updateMass()
public void setSensor(boolean value)
value - if true the body will be a sensor. It will not collide when enters contact with other bodiespublic boolean isSensor()
true the body is a sensor. It will not collide when enters contact with other bodiespublic void setStaticBody(boolean value)
setPosition or setRotation.value - if true the body will be staticpublic void setStatic(boolean value)
setPosition or setRotation.value - if true the body will be staticpublic float getMass()
public boolean isStatic()
setPosition or setRotation.true the body is staticpublic void setBullet(boolean value)
value - if true the body will be a bulletpublic void setRestitution(float restitution)
restitution - a positive value. A value of 0 means no bounce after a collision, and a value of 1 means bounce with it's full speed from a collisionpublic void setFriction(float friction)
friction - a positive value. A value of 0 means no friction and thus the body will not be slown down if no other forces are appliedpublic void setRotatable(boolean rotatable)
rotatable - if true the body will not rotatepublic void setAllowSleeping(boolean allowSleep)
allowSleep - if true the body will be able to sleeppublic ArrayList getTouching()
public ArrayList getContacts()
public ArrayList getJoints()
public boolean isConnected(FBody other)
other - the other bodytrue the body is connected to otherpublic boolean isTouchingBody(FBody b)
b - the body for which we want to know if there is contacttrue the body is touching bprotected org.jbox2d.common.Vec2 getLocalWorldPoint(org.jbox2d.common.Vec2 p)