public abstract class DebugDraw

  1. Object
  2. DebugDraw
Implement this abstract class to allow JBox2d to automatically draw your physics for debugging purposes. Not intended to replace your own custom rendering routines!

Fields

public static final int e_shapeBit = 1
public static final int e_jointBit = 2< draw shapes
public static final int e_aabbBit = 4< draw joint connections
public static final int e_pairBit = 8< draw core (TOI) shapes
public static final int e_centerOfMassBit = 16< draw axis aligned bounding boxes
public static final int e_dynamicTreeBit = 32< draw center of mass frame
protected int m_drawFlags< draw dynamic tree.
protected final IViewportTransform viewportTransform

Constructors

public DebugDraw(IViewportTransform viewport)

Methods

public void setFlags(int flags)
public int getFlags()
public void appendFlags(int flags)
public void clearFlags(int flags)
public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color)Draw a closed polygon provided in CCW order.
public abstract void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor)
public abstract void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color)Draw a solid closed polygon provided in CCW order.
public abstract void drawCircle(Vec2 center, float radius, Color3f color)Draw a circle.
public abstract void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color)Draw a solid circle.
public abstract void drawSegment(Vec2 p1, Vec2 p2, Color3f color)Draw a line segment.
public abstract void drawTransform(Transform xf)Draw a transform.
public abstract void drawString(float x, float y, String s, Color3f color)Draw a string.
public void drawString(Vec2 pos, String s, Color3f color)
public IViewportTransform getViewportTranform()
public void setCamera(float x, float y, float scale)
public void getScreenToWorldToOut(Vec2 argScreen, Vec2 argWorld)
public void getWorldToScreenToOut(Vec2 argWorld, Vec2 argScreen)
public void getWorldToScreenToOut(float worldX, float worldY, Vec2 argScreen)Takes the world coordinates and puts the corresponding screen coordinates in argScreen.
public Vec2 getWorldToScreen(Vec2 argWorld)takes the world coordinate (argWorld) and returns the screen coordinates.
public Vec2 getWorldToScreen(float worldX, float worldY)Takes the world coordinates and returns the screen coordinates.
public void getScreenToWorldToOut(float screenX, float screenY, Vec2 argWorld)takes the screen coordinates and puts the corresponding world coordinates in argWorld.
public Vec2 getScreenToWorld(Vec2 argScreen)takes the screen coordinates (argScreen) and returns the world coordinates
public Vec2 getScreenToWorld(float screenX, float screenY)takes the screen coordinates and returns the world coordinates.

Inherited methods

Field details

e_shapeBit

public static final int e_shapeBit = 1

e_jointBit

public static final int e_jointBit = 2
< draw shapes

e_aabbBit

public static final int e_aabbBit = 4
< draw joint connections

e_pairBit

public static final int e_pairBit = 8
< draw core (TOI) shapes

e_centerOfMassBit

public static final int e_centerOfMassBit = 16
< draw axis aligned bounding boxes

e_dynamicTreeBit

public static final int e_dynamicTreeBit = 32
< draw center of mass frame

m_drawFlags

protected int m_drawFlags
< draw dynamic tree.

viewportTransform

protected final IViewportTransform viewportTransform

Constructor details

DebugDraw

public DebugDraw(IViewportTransform viewport)

Method details

setFlags

public void setFlags(int flags)

getFlags

public int getFlags()

appendFlags

public void appendFlags(int flags)

clearFlags

public void clearFlags(int flags)

drawPolygon

public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color)
Draw a closed polygon provided in CCW order. This implementation uses drawSegment(Vec2, Vec2, Color3f) to draw each side of the polygon.

drawPoint

public abstract void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor)

drawSolidPolygon

public abstract void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color)
Draw a solid closed polygon provided in CCW order.

drawCircle

public abstract void drawCircle(Vec2 center, float radius, Color3f color)
Draw a circle.

drawSolidCircle

public abstract void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color)
Draw a solid circle.

drawSegment

public abstract void drawSegment(Vec2 p1, Vec2 p2, Color3f color)
Draw a line segment.

drawTransform

public abstract void drawTransform(Transform xf)
Draw a transform. Choose your own length scale

drawString

public abstract void drawString(float x, float y, String s, Color3f color)
Draw a string.

drawString

public void drawString(Vec2 pos, String s, Color3f color)

getViewportTranform

public IViewportTransform getViewportTranform()

setCamera

public void setCamera(float x, float y, float scale)

getScreenToWorldToOut

public void getScreenToWorldToOut(Vec2 argScreen, Vec2 argWorld)

getWorldToScreenToOut

public void getWorldToScreenToOut(Vec2 argWorld, Vec2 argScreen)

getWorldToScreenToOut

public void getWorldToScreenToOut(float worldX, float worldY, Vec2 argScreen)
Takes the world coordinates and puts the corresponding screen coordinates in argScreen.

getWorldToScreen

public Vec2 getWorldToScreen(Vec2 argWorld)
takes the world coordinate (argWorld) and returns the screen coordinates.

getWorldToScreen

public Vec2 getWorldToScreen(float worldX, float worldY)
Takes the world coordinates and returns the screen coordinates.

getScreenToWorldToOut

public void getScreenToWorldToOut(float screenX, float screenY, Vec2 argWorld)
takes the screen coordinates and puts the corresponding world coordinates in argWorld.

getScreenToWorld

public Vec2 getScreenToWorld(Vec2 argScreen)
takes the screen coordinates (argScreen) and returns the world coordinates

getScreenToWorld

public Vec2 getScreenToWorld(float screenX, float screenY)
takes the screen coordinates and returns the world coordinates.