Class BodyDef

java.lang.Object
org.jbox2d.dynamics.BodyDef

public class BodyDef extends Object
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
Repolink:
Github: erincatto/box2d include/box2d/b2_body.h Lines 50 - 125
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    Does this body start out active?
    boolean
    Set this flag to false if this body should never fall asleep.
    float
    The world angle of the body in radians.
    float
    Angular damping is used to reduce the angular velocity.
    float
    The angular velocity of the body.
    boolean
    Is this body initially awake or sleeping?
    boolean
    Is this a fast moving body that should be prevented from tunneling through other moving bodies?
    boolean
    Should this body be prevented from rotating?
    float
    Scale the gravity applied to this body.
    float
    Linear 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    The world angle of the body in radians.
    float
    Angular damping is used to reduce the angular velocity.
    float
    The angular velocity of the body.
    float
    Experimental: scales the inertia tensor.
    float
    Linear 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.
    boolean
    Does this body start out active?
    boolean
    Set this flag to false if this body should never fall asleep.
    boolean
    Is this body initially sleeping?
    boolean
    Is this a fast moving body that should be prevented from tunneling through other moving bodies?
    boolean
    Should this body be prevented from rotating?
    void
    setActive(boolean active)
    Does this body start out active?
    void
    setAllowSleep(boolean allowSleep)
    Set this flag to false if this body should never fall asleep.
    void
    setAngle(float angle)
    The world angle of the body in radians.
    void
    setAngularDamping(float angularDamping)
    Angular damping is used to reduce the angular velocity.
    void
    setAngularVelocity(float angularVelocity)
    The angular velocity of the body.
    void
    setAwake(boolean awake)
    Is this body initially sleeping?
    void
    setBullet(boolean bullet)
    Is this a fast moving body that should be prevented from tunneling through other moving bodies?
    void
    setFixedRotation(boolean fixedRotation)
    Should this body be prevented from rotating?
    void
    setGravityScale(float gravityScale)
    Experimental: scales the inertia tensor.
    void
    setLinearDamping(float linearDamping)
    Linear damping is used to reduce the linear velocity.
    void
    setLinearVelocity(Vec2 linearVelocity)
    The linear velocity of the body in world co-ordinates.
    void
    setPosition(Vec2 position)
    The world position of the body.
    void
    The body type: static, kinematic, or dynamic.
    void
    setUserData(Object userData)
    Use this to store application specific body data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • BodyDef

      public BodyDef()
  • Method Details

    • getType

      public BodyType getType()
      The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one.
    • setType

      public void setType(BodyType type)
      The body type: static, kinematic, or dynamic. Note: if a dynamic body would have zero mass, the mass is set to one.
    • getUserData

      public Object getUserData()
      Use this to store application specific body data.
    • setUserData

      public void setUserData(Object userData)
      Use this to store application specific body data.
    • getPosition

      public Vec2 getPosition()
      The world position of the body. Avoid creating bodies at the origin since this can lead to many overlapping shapes.
    • setPosition

      public void setPosition(Vec2 position)
      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

      public Vec2 getLinearVelocity()
      The linear velocity of the body in world co-ordinates.
    • setLinearVelocity

      public void setLinearVelocity(Vec2 linearVelocity)
      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.