Package net.dermetfan.gdx.physics.box2d
Class PositionController
java.lang.Object
net.dermetfan.gdx.physics.box2d.PositionController
- Direct Known Subclasses:
PositionController.D,PositionController.P,PositionController.PD
moves a body to a position using forces
- Since:
- 0.11.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classthe derivative control loop componentstatic classthe proportional control loop componentstatic classa proportional-derivative controller -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.dermetfan.utils.Function<Object, PositionController> returns the argument if it is a PositionControllerprotected static final com.badlogic.gdx.math.Vector2shared instance for internal use -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.Vector2applyForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point, boolean wake) applies the necessary force at the given pointcom.badlogic.gdx.math.Vector2applyForceToCenter(com.badlogic.gdx.physics.box2d.Body body, boolean wake) applies the necessary force at the center of mass of the Bodystatic voidapplyForceToCenter(com.badlogic.gdx.physics.box2d.World world, boolean wake) CallsapplyForceToCenterfor every Body with a PositionController in its user data.abstract com.badlogic.gdx.math.Vector2calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point) abstract com.badlogic.gdx.math.Vector2calculateForceToCenter(com.badlogic.gdx.physics.box2d.Body body) static net.dermetfan.utils.Function<Object, PositionController> static voidsetUserDataAccessor(net.dermetfan.utils.Function<Object, PositionController> userDataAccessor)
-
Field Details
-
vec2
protected static final com.badlogic.gdx.math.Vector2 vec2shared instance for internal use -
defaultUserDataAccessor
returns the argument if it is a PositionController
-
-
Constructor Details
-
PositionController
public PositionController()
-
-
Method Details
-
applyForceToCenter
public static void applyForceToCenter(com.badlogic.gdx.physics.box2d.World world, boolean wake) CallsapplyForceToCenterfor every Body with a PositionController in its user data. The PositionController is accessed using theuserDataAccessor.- Parameters:
world- the world which Bodies to iterate over
-
calculateForce
public abstract com.badlogic.gdx.math.Vector2 calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point) - Parameters:
point- the world point at which the force should be applied- Returns:
- the force to apply at the given point
-
calculateForceToCenter
public abstract com.badlogic.gdx.math.Vector2 calculateForceToCenter(com.badlogic.gdx.physics.box2d.Body body) - Returns:
- the force to apply at the center of mass of the Body
-
applyForce
public com.badlogic.gdx.math.Vector2 applyForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point, boolean wake) applies the necessary force at the given point- Parameters:
point- the world point at which to apply the force- Returns:
- the force applied, calculated by
calculateForce(Body, Vector2)
-
applyForceToCenter
public com.badlogic.gdx.math.Vector2 applyForceToCenter(com.badlogic.gdx.physics.box2d.Body body, boolean wake) applies the necessary force at the center of mass of the Body- Returns:
- the force applied, calculated by
calculateForceToCenter(Body)
-
getUserDataAccessor
- Returns:
- the
userDataAccessor
-
setUserDataAccessor
public static void setUserDataAccessor(net.dermetfan.utils.Function<Object, PositionController> userDataAccessor) - Parameters:
userDataAccessor- TheuserDataAccessorto set. If null,defaultUserDataAccessoris set.
-