org.jbox2d.testbed
Class ProcessingDebugDraw
java.lang.Object
org.jbox2d.dynamics.DebugDraw
org.jbox2d.testbed.ProcessingDebugDraw
public class ProcessingDebugDraw
- extends DebugDraw
Implementation of DebugDraw using Processing (http://www.processing.org)
- Author:
- ewjordan
Method Summary |
void |
drawCircle(Vec2 center,
float radius,
Color3f color)
|
void |
drawImage(processing.core.PImage image,
Vec2 position,
float rotation,
float localScale,
Vec2 localOffset,
float halfImageWidth,
float halfImageHeight)
First image is centered on position, then
localScale is applied, then localOffset, and
lastly rotation. |
void |
drawPoint(Vec2 position,
float f,
Color3f color)
|
void |
drawPolygon(Vec2[] vertices,
int vertexCount,
Color3f color)
|
void |
drawSegment(Vec2 p1,
Vec2 p2,
Color3f color)
|
void |
drawSolidCircle(Vec2 center,
float radius,
Vec2 axis,
Color3f color)
|
void |
drawSolidPolygon(Vec2[] vertices,
int vertexCount,
Color3f color)
|
void |
drawString(float x,
float y,
String s,
Color3f color)
|
void |
drawXForm(XForm xf)
|
float |
screenToWorld(float screenScale)
|
Vec2 |
screenToWorld(float x,
float y)
|
Vec2 |
screenToWorld(Vec2 screen)
|
Vec2 |
screenToWorldVector(float x,
float y)
|
Vec2 |
screenToWorldVector(Vec2 screen)
|
void |
setCamera(float x,
float y,
float scale)
Stub method to overload for camera movement/zoom. |
float |
worldToScreen(float worldScale)
|
Vec2 |
worldToScreen(float x,
float y)
|
Vec2 |
worldToScreen(Vec2 world)
|
Vec2 |
worldToScreenVector(float x,
float y)
|
Vec2 |
worldToScreenVector(Vec2 world)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
screen
public static ProcessingDebugDraw screen
g
public processing.core.PApplet g
m_font
public processing.core.PFont m_font
fontHeight
public float fontHeight
transX
public float transX
transY
public float transY
scaleFactor
public float scaleFactor
yFlip
public float yFlip
ProcessingDebugDraw
public ProcessingDebugDraw(processing.core.PApplet pApplet)
setCamera
public void setCamera(float x,
float y,
float scale)
- Description copied from class:
DebugDraw
- Stub method to overload for camera movement/zoom.
- Overrides:
setCamera
in class DebugDraw
- Parameters:
x
- - x coordinate of cameray
- - y coordinate of camerascale
- - zoom factor
worldToScreen
public float worldToScreen(float worldScale)
screenToWorld
public float screenToWorld(float screenScale)
worldToScreen
public Vec2 worldToScreen(Vec2 world)
- Overrides:
worldToScreen
in class DebugDraw
- Parameters:
world
- World position
- Returns:
- Screen position
worldToScreen
public Vec2 worldToScreen(float x,
float y)
- Overrides:
worldToScreen
in class DebugDraw
- Parameters:
x
- World x positiony
- World y position
- Returns:
- Screen position
screenToWorld
public Vec2 screenToWorld(Vec2 screen)
- Overrides:
screenToWorld
in class DebugDraw
- Parameters:
screen
- Screen position
- Returns:
- World position
screenToWorld
public Vec2 screenToWorld(float x,
float y)
- Overrides:
screenToWorld
in class DebugDraw
- Parameters:
x
- Screen x positiony
- Screey y position
- Returns:
- World position
drawCircle
public void drawCircle(Vec2 center,
float radius,
Color3f color)
- Specified by:
drawCircle
in class DebugDraw
drawSolidCircle
public void drawSolidCircle(Vec2 center,
float radius,
Vec2 axis,
Color3f color)
- Specified by:
drawSolidCircle
in class DebugDraw
drawPolygon
public void drawPolygon(Vec2[] vertices,
int vertexCount,
Color3f color)
- Specified by:
drawPolygon
in class DebugDraw
drawSolidPolygon
public void drawSolidPolygon(Vec2[] vertices,
int vertexCount,
Color3f color)
- Specified by:
drawSolidPolygon
in class DebugDraw
drawSegment
public void drawSegment(Vec2 p1,
Vec2 p2,
Color3f color)
- Specified by:
drawSegment
in class DebugDraw
drawXForm
public void drawXForm(XForm xf)
- Specified by:
drawXForm
in class DebugDraw
drawString
public void drawString(float x,
float y,
String s,
Color3f color)
- Specified by:
drawString
in class DebugDraw
drawPoint
public void drawPoint(Vec2 position,
float f,
Color3f color)
- Specified by:
drawPoint
in class DebugDraw
drawImage
public void drawImage(processing.core.PImage image,
Vec2 position,
float rotation,
float localScale,
Vec2 localOffset,
float halfImageWidth,
float halfImageHeight)
- First image is centered on position, then
localScale is applied, then localOffset, and
lastly rotation.
Thus localOffset should be specified in world
units before scaling is applied.
For instance, if you want a MxN image to have its corner
at body center and be scaled by S, use a localOffset
of (M*S/2, N*S/2) and a localScale of S.
worldToScreenVector
public Vec2 worldToScreenVector(Vec2 world)
worldToScreenVector
public Vec2 worldToScreenVector(float x,
float y)
screenToWorldVector
public Vec2 screenToWorldVector(Vec2 screen)
screenToWorldVector
public Vec2 screenToWorldVector(float x,
float y)