Package org.jbox2d.dynamics
Class BodyDef
java.lang.Object
org.jbox2d.dynamics.BodyDef
A body definition holds all the data needed to construct a rigid body. You
can safely re-use body definitions. Shapes are added to a body after
construction.
- Author:
- Daniel Murphy
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanDoes this body start out active?booleanSet this flag to false if this body should never fall asleep.floatThe world angle of the body in radians.floatAngular damping is used to reduce the angular velocity.floatThe angular velocity of the body.booleanIs this body initially awake or sleeping?booleanIs this a fast moving body that should be prevented from tunneling through other moving bodies?booleanShould this body be prevented from rotating?floatScale the gravity applied to this body.floatLinear damping is used to reduce the linear velocity.The linear velocity of the body in world co-ordinates.The world position of the body.The body type: static, kinematic, or dynamic.Use this to store application specific body data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatgetAngle()The world angle of the body in radians.floatAngular damping is used to reduce the angular velocity.floatThe angular velocity of the body.floatExperimental: scales the inertia tensor.floatLinear damping is used to reduce the linear velocity.The linear velocity of the body in world co-ordinates.The world position of the body.getType()The body type: static, kinematic, or dynamic.Use this to store application specific body data.booleanisActive()Does this body start out active?booleanSet this flag to false if this body should never fall asleep.booleanisAwake()Is this body initially sleeping?booleanisBullet()Is this a fast moving body that should be prevented from tunneling through other moving bodies?booleanShould this body be prevented from rotating?voidsetActive(boolean active) Does this body start out active?voidsetAllowSleep(boolean allowSleep) Set this flag to false if this body should never fall asleep.voidsetAngle(float angle) The world angle of the body in radians.voidsetAngularDamping(float angularDamping) Angular damping is used to reduce the angular velocity.voidsetAngularVelocity(float angularVelocity) The angular velocity of the body.voidsetAwake(boolean awake) Is this body initially sleeping?voidsetBullet(boolean bullet) Is this a fast moving body that should be prevented from tunneling through other moving bodies?voidsetFixedRotation(boolean fixedRotation) Should this body be prevented from rotating?voidsetGravityScale(float gravityScale) Experimental: scales the inertia tensor.voidsetLinearDamping(float linearDamping) Linear damping is used to reduce the linear velocity.voidsetLinearVelocity(Vec2 linearVelocity) The linear velocity of the body in world co-ordinates.voidsetPosition(Vec2 position) The world position of the body.voidThe body type: static, kinematic, or dynamic.voidsetUserData(Object userData) Use this to store application specific body data.
-
Field Details
-
type
The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one. -
position
The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes. -
angle
public float angleThe world angle of the body in radians. -
linearVelocity
The linear velocity of the body in world co-ordinates. -
angularVelocity
public float angularVelocityThe angular velocity of the body. -
linearDamping
public float linearDampingLinear damping is used to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. Units are1 / time. -
angularDamping
public float angularDampingAngular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. Units are1 / time. -
allowSleep
public boolean allowSleepSet this flag to false if this body should never fall asleep. Note that this increases CPU usage. -
awake
public boolean awakeIs this body initially awake or sleeping? -
fixedRotation
public boolean fixedRotationShould this body be prevented from rotating? Useful for characters. -
bullet
public boolean bulletIs this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.- Repolink:
- Github: erincatto/box2d include/box2d/b2_body.h Lines 111 - 115
- Warning:
- You should use this flag sparingly since it increases processing time.
-
active
public boolean activeDoes this body start out active? TODO: rename to enabled -
userData
Use this to store application specific body data. -
gravityScale
public float gravityScaleScale the gravity applied to this body.
-
-
Constructor Details
-
BodyDef
public BodyDef()
-
-
Method Details
-
getType
The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one. -
setType
The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one. -
getUserData
Use this to store application specific body data. -
setUserData
Use this to store application specific body data. -
getPosition
The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes. -
setPosition
The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes. -
getAngle
public float getAngle()The world angle of the body in radians. -
setAngle
public void setAngle(float angle) The world angle of the body in radians. -
getLinearVelocity
The linear velocity of the body in world co-ordinates. -
setLinearVelocity
The linear velocity of the body in world co-ordinates. -
getAngularVelocity
public float getAngularVelocity()The angular velocity of the body. -
setAngularVelocity
public void setAngularVelocity(float angularVelocity) The angular velocity of the body. -
getLinearDamping
public float getLinearDamping()Linear damping is used to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. -
setLinearDamping
public void setLinearDamping(float linearDamping) Linear damping is used to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. -
getAngularDamping
public float getAngularDamping()Angular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. -
setAngularDamping
public void setAngularDamping(float angularDamping) Angular damping is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large. -
isAllowSleep
public boolean isAllowSleep()Set this flag to false if this body should never fall asleep. Note that this increases CPU usage. -
setAllowSleep
public void setAllowSleep(boolean allowSleep) Set this flag to false if this body should never fall asleep. Note that this increases CPU usage. -
isAwake
public boolean isAwake()Is this body initially sleeping? -
setAwake
public void setAwake(boolean awake) Is this body initially sleeping? -
isFixedRotation
public boolean isFixedRotation()Should this body be prevented from rotating? Useful for characters. -
setFixedRotation
public void setFixedRotation(boolean fixedRotation) Should this body be prevented from rotating? Useful for characters. -
isBullet
public boolean isBullet()Is this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.- Warning:
- You should use this flag sparingly since it increases processing time.
-
setBullet
public void setBullet(boolean bullet) Is this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.- Warning:
- You should use this flag sparingly since it increases processing time.
-
isActive
public boolean isActive()Does this body start out active? -
setActive
public void setActive(boolean active) Does this body start out active? -
getGravityScale
public float getGravityScale()Experimental: scales the inertia tensor. -
setGravityScale
public void setGravityScale(float gravityScale) Experimental: scales the inertia tensor.
-