org.jbox2d.testbed.framework
Class TestbedTest

java.lang.Object
  extended by org.jbox2d.testbed.framework.TestbedTest
All Implemented Interfaces:
org.jbox2d.callbacks.ContactListener, org.jbox2d.serialization.JbDeserializer.ObjectListener, org.jbox2d.serialization.JbSerializer.ObjectSigner, org.jbox2d.serialization.UnsupportedListener
Direct Known Subclasses:
ApplyForce, BlobTest4, BodyTypes, Breakable, Cantilever, Car, Chain, CharacterCollision, CircleStress, CollisionFiltering, CollisionProcessing, CompoundShapes, ConfinedTest, ContinuousTest, ConvexHull, ConveyorBelt, DistanceTest, DominoTest, DominoTower, DynamicTreeTest, EdgeShapes, FixedPendulumTest, FreePendulumTest, Gears, LiquidTest, OneSidedTest, PistonTest, PolyShapes, PrismaticTest, Pulleys, PyramidTest, RayCastTest, RevoluteTest, RopeTest, SensorTest, ShapeEditing, SliderCrankTest, SphereStack, TheoJansen, Tumbler, VaryingFrictionTest, VaryingRestitution, VerticalStack, Web

public abstract class TestbedTest
extends java.lang.Object
implements org.jbox2d.callbacks.ContactListener, org.jbox2d.serialization.JbDeserializer.ObjectListener, org.jbox2d.serialization.JbSerializer.ObjectSigner, org.jbox2d.serialization.UnsupportedListener

Author:
Daniel Murphy

Field Summary
protected static long BOMB_TAG
           
protected  org.jbox2d.callbacks.DestructionListener destructionListener
           
protected static long GROUND_BODY_TAG
           
protected  org.jbox2d.dynamics.Body groundBody
           
protected  int m_textLine
           
protected  org.jbox2d.dynamics.World m_world
          Only visible for compatibility.
static int MAX_CONTACT_POINTS
           
protected static long MOUSE_JOINT_TAG
           
static ContactPoint[] points
           
 
Constructor Summary
TestbedTest()
           
 
Method Summary
protected  void _load()
           
protected  void _reset()
           
protected  void _save()
           
 void addTextLine(java.lang.String argTextLine)
          Adds a text line to the reporting area
 void beginContact(org.jbox2d.dynamics.contacts.Contact contact)
           
 void completeBombSpawn(org.jbox2d.common.Vec2 p)
           
 void endContact(org.jbox2d.dynamics.contacts.Contact contact)
           
 void exit()
          called when the tests exits
 org.jbox2d.dynamics.Body getBomb()
          Gets the 'bomb' body if it's present
 org.jbox2d.common.Vec2 getCachedCameraPos()
           
 float getCachedCameraScale()
           
static ContactPoint[] getContactPoints()
          Gets the contact points for the current test
 org.jbox2d.callbacks.DebugDraw getDebugDraw()
          Gets the debug draw for the testbed
 org.jbox2d.common.Vec2 getDefaultCameraPos()
          Override for a different default camera pos
 float getDefaultCameraScale()
          Override for a different default camera scale
 java.lang.String getFilename()
          Gets the filename of the current test.
 org.jbox2d.dynamics.Body getGroundBody()
          Gets the ground body of the world, used for some joints
 TestbedModel getModel()
          Gets the testbed model
 int getPointCount()
          The number of contact points we're storing
 int getStepCount()
           
 java.lang.Long getTag(org.jbox2d.dynamics.Body body)
           
 java.lang.Long getTag(org.jbox2d.dynamics.Fixture fixture)
           
 java.lang.Long getTag(org.jbox2d.dynamics.joints.Joint joint)
           
 java.lang.Long getTag(org.jbox2d.collision.shapes.Shape shape)
           
 java.lang.Long getTag(org.jbox2d.dynamics.World world)
           
abstract  java.lang.String getTestName()
          The name of the test
 org.jbox2d.dynamics.World getWorld()
          Gets the current world
 org.jbox2d.common.Vec2 getWorldMouse()
          Gets the world position of the mouse
 void init(TestbedModel argModel)
           
 void init(org.jbox2d.dynamics.World argWorld, boolean argDeserialized)
           
abstract  void initTest(boolean deserialized)
          Initializes the current test
 boolean isDialogOnSaveLoadErrors()
           
 boolean isHasCachedCamera()
           
 boolean isSaveLoadEnabled()
          Override to enable saving and loading.
 boolean isUnsupported(org.jbox2d.serialization.UnsupportedObjectException exception)
           
 void jointDestroyed(org.jbox2d.dynamics.joints.Joint joint)
           
 void keyPressed(char keyCar, int keyCode)
           
 void keyReleased(char keyChar, int keyCode)
           
 void lanchBomb()
           
 void launchBomb(org.jbox2d.common.Vec2 position, org.jbox2d.common.Vec2 velocity)
           
 void load()
          Loads the test from file
 void mouseDown(org.jbox2d.common.Vec2 p)
          Called for mouse-down
 void mouseMove(org.jbox2d.common.Vec2 p)
          Called when mouse is moved
 void mouseUp(org.jbox2d.common.Vec2 p)
          Called for mouse-up
 void postSolve(org.jbox2d.dynamics.contacts.Contact contact, org.jbox2d.callbacks.ContactImpulse impulse)
           
 void preSolve(org.jbox2d.dynamics.contacts.Contact contact, org.jbox2d.collision.Manifold oldManifold)
           
 void processBody(org.jbox2d.dynamics.Body body, java.lang.Long tag)
           
 void processFixture(org.jbox2d.dynamics.Fixture fixture, java.lang.Long tag)
           
 void processJoint(org.jbox2d.dynamics.joints.Joint joint, java.lang.Long tag)
           
 void processShape(org.jbox2d.collision.shapes.Shape shape, java.lang.Long tag)
           
 void processWorld(org.jbox2d.dynamics.World world, java.lang.Long tag)
           
 void queueKeyPressed(char c, int code)
           
 void queueKeyReleased(char c, int code)
           
 void queueMouseDown(org.jbox2d.common.Vec2 p)
           
 void queueMouseMove(org.jbox2d.common.Vec2 p)
           
 void queueMouseUp(org.jbox2d.common.Vec2 p)
           
 void queueShiftMouseDown(org.jbox2d.common.Vec2 p)
           
 void reset()
          Resets the test
 void save()
          Saves the test
 void setCachedCameraPos(org.jbox2d.common.Vec2 argPos)
           
 void setCachedCameraScale(float cachedCameraScale)
           
 void setCamera(org.jbox2d.common.Vec2 argPos)
           
 void setCamera(org.jbox2d.common.Vec2 argPos, float scale)
          Sets the current testbed camera
 void setDialogOnSaveLoadErrors(boolean dialogOnSaveLoadErrors)
           
 void setHasCachedCamera(boolean hasCachedCamera)
           
 void setTitle(java.lang.String argTitle)
          Sets the title of the test
 void shiftMouseDown(org.jbox2d.common.Vec2 p)
          Called when shift-mouse down occurs
 void spawnBomb(org.jbox2d.common.Vec2 worldPt)
           
 void step(TestbedSettings settings)
           
 void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_CONTACT_POINTS

public static final int MAX_CONTACT_POINTS
See Also:
Constant Field Values

GROUND_BODY_TAG

protected static final long GROUND_BODY_TAG
See Also:
Constant Field Values

BOMB_TAG

protected static final long BOMB_TAG
See Also:
Constant Field Values

MOUSE_JOINT_TAG

protected static final long MOUSE_JOINT_TAG
See Also:
Constant Field Values

points

public static final ContactPoint[] points

m_world

protected org.jbox2d.dynamics.World m_world
Only visible for compatibility. Should use getWorld() instead.


groundBody

protected org.jbox2d.dynamics.Body groundBody

destructionListener

protected org.jbox2d.callbacks.DestructionListener destructionListener

m_textLine

protected int m_textLine
Constructor Detail

TestbedTest

public TestbedTest()
Method Detail

init

public void init(TestbedModel argModel)

init

public void init(org.jbox2d.dynamics.World argWorld,
                 boolean argDeserialized)

getWorld

public org.jbox2d.dynamics.World getWorld()
Gets the current world

Returns:

getModel

public TestbedModel getModel()
Gets the testbed model

Returns:

getContactPoints

public static ContactPoint[] getContactPoints()
Gets the contact points for the current test

Returns:

getGroundBody

public org.jbox2d.dynamics.Body getGroundBody()
Gets the ground body of the world, used for some joints

Returns:

getDebugDraw

public org.jbox2d.callbacks.DebugDraw getDebugDraw()
Gets the debug draw for the testbed

Returns:

getWorldMouse

public org.jbox2d.common.Vec2 getWorldMouse()
Gets the world position of the mouse

Returns:

getStepCount

public int getStepCount()

getPointCount

public int getPointCount()
The number of contact points we're storing

Returns:

getBomb

public org.jbox2d.dynamics.Body getBomb()
Gets the 'bomb' body if it's present

Returns:

getCachedCameraScale

public float getCachedCameraScale()

setCachedCameraScale

public void setCachedCameraScale(float cachedCameraScale)

getCachedCameraPos

public org.jbox2d.common.Vec2 getCachedCameraPos()

setCachedCameraPos

public void setCachedCameraPos(org.jbox2d.common.Vec2 argPos)

isHasCachedCamera

public boolean isHasCachedCamera()

setHasCachedCamera

public void setHasCachedCamera(boolean hasCachedCamera)

isDialogOnSaveLoadErrors

public boolean isDialogOnSaveLoadErrors()

setDialogOnSaveLoadErrors

public void setDialogOnSaveLoadErrors(boolean dialogOnSaveLoadErrors)

getDefaultCameraPos

public org.jbox2d.common.Vec2 getDefaultCameraPos()
Override for a different default camera pos

Returns:

getDefaultCameraScale

public float getDefaultCameraScale()
Override for a different default camera scale

Returns:

getFilename

public java.lang.String getFilename()
Gets the filename of the current test. Default implementation uses the test name with no spaces".

Returns:

reset

public void reset()
Resets the test


save

public void save()
Saves the test


load

public void load()
Loads the test from file


_reset

protected void _reset()

_save

protected void _save()

_load

protected void _load()

setCamera

public void setCamera(org.jbox2d.common.Vec2 argPos)

setCamera

public void setCamera(org.jbox2d.common.Vec2 argPos,
                      float scale)
Sets the current testbed camera

Parameters:
argPos -
scale -

initTest

public abstract void initTest(boolean deserialized)
Initializes the current test

Parameters:
argDeserialized - if the test was deserialized from a file. If so, all physics objects were already added.

getTestName

public abstract java.lang.String getTestName()
The name of the test

Returns:

exit

public void exit()
called when the tests exits


update

public void update()

step

public void step(TestbedSettings settings)

queueShiftMouseDown

public void queueShiftMouseDown(org.jbox2d.common.Vec2 p)

queueMouseUp

public void queueMouseUp(org.jbox2d.common.Vec2 p)

queueMouseDown

public void queueMouseDown(org.jbox2d.common.Vec2 p)

queueMouseMove

public void queueMouseMove(org.jbox2d.common.Vec2 p)

queueKeyPressed

public void queueKeyPressed(char c,
                            int code)

queueKeyReleased

public void queueKeyReleased(char c,
                             int code)

shiftMouseDown

public void shiftMouseDown(org.jbox2d.common.Vec2 p)
Called when shift-mouse down occurs

Parameters:
p -

mouseUp

public void mouseUp(org.jbox2d.common.Vec2 p)
Called for mouse-up

Parameters:
p -

mouseDown

public void mouseDown(org.jbox2d.common.Vec2 p)
Called for mouse-down

Parameters:
p -

mouseMove

public void mouseMove(org.jbox2d.common.Vec2 p)
Called when mouse is moved

Parameters:
p -

setTitle

public void setTitle(java.lang.String argTitle)
Sets the title of the test

Parameters:
argTitle -

addTextLine

public void addTextLine(java.lang.String argTextLine)
Adds a text line to the reporting area

Parameters:
argTextLine -

lanchBomb

public void lanchBomb()

launchBomb

public void launchBomb(org.jbox2d.common.Vec2 position,
                       org.jbox2d.common.Vec2 velocity)

spawnBomb

public void spawnBomb(org.jbox2d.common.Vec2 worldPt)

completeBombSpawn

public void completeBombSpawn(org.jbox2d.common.Vec2 p)

isSaveLoadEnabled

public boolean isSaveLoadEnabled()
Override to enable saving and loading. Remember to also override the JbDeserializer.ObjectListener and JbSerializer.ObjectSigner methods if you need to

Returns:

getTag

public java.lang.Long getTag(org.jbox2d.dynamics.Body body)
Specified by:
getTag in interface org.jbox2d.serialization.JbSerializer.ObjectSigner

getTag

public java.lang.Long getTag(org.jbox2d.dynamics.Fixture fixture)
Specified by:
getTag in interface org.jbox2d.serialization.JbSerializer.ObjectSigner

getTag

public java.lang.Long getTag(org.jbox2d.dynamics.joints.Joint joint)
Specified by:
getTag in interface org.jbox2d.serialization.JbSerializer.ObjectSigner

getTag

public java.lang.Long getTag(org.jbox2d.collision.shapes.Shape shape)
Specified by:
getTag in interface org.jbox2d.serialization.JbSerializer.ObjectSigner

getTag

public java.lang.Long getTag(org.jbox2d.dynamics.World world)
Specified by:
getTag in interface org.jbox2d.serialization.JbSerializer.ObjectSigner

processBody

public void processBody(org.jbox2d.dynamics.Body body,
                        java.lang.Long tag)
Specified by:
processBody in interface org.jbox2d.serialization.JbDeserializer.ObjectListener

processFixture

public void processFixture(org.jbox2d.dynamics.Fixture fixture,
                           java.lang.Long tag)
Specified by:
processFixture in interface org.jbox2d.serialization.JbDeserializer.ObjectListener

processJoint

public void processJoint(org.jbox2d.dynamics.joints.Joint joint,
                         java.lang.Long tag)
Specified by:
processJoint in interface org.jbox2d.serialization.JbDeserializer.ObjectListener

processShape

public void processShape(org.jbox2d.collision.shapes.Shape shape,
                         java.lang.Long tag)
Specified by:
processShape in interface org.jbox2d.serialization.JbDeserializer.ObjectListener

processWorld

public void processWorld(org.jbox2d.dynamics.World world,
                         java.lang.Long tag)
Specified by:
processWorld in interface org.jbox2d.serialization.JbDeserializer.ObjectListener

isUnsupported

public boolean isUnsupported(org.jbox2d.serialization.UnsupportedObjectException exception)
Specified by:
isUnsupported in interface org.jbox2d.serialization.UnsupportedListener

jointDestroyed

public void jointDestroyed(org.jbox2d.dynamics.joints.Joint joint)

beginContact

public void beginContact(org.jbox2d.dynamics.contacts.Contact contact)
Specified by:
beginContact in interface org.jbox2d.callbacks.ContactListener

endContact

public void endContact(org.jbox2d.dynamics.contacts.Contact contact)
Specified by:
endContact in interface org.jbox2d.callbacks.ContactListener

postSolve

public void postSolve(org.jbox2d.dynamics.contacts.Contact contact,
                      org.jbox2d.callbacks.ContactImpulse impulse)
Specified by:
postSolve in interface org.jbox2d.callbacks.ContactListener

preSolve

public void preSolve(org.jbox2d.dynamics.contacts.Contact contact,
                     org.jbox2d.collision.Manifold oldManifold)
Specified by:
preSolve in interface org.jbox2d.callbacks.ContactListener

keyPressed

public void keyPressed(char keyCar,
                       int keyCode)

keyReleased

public void keyReleased(char keyChar,
                        int keyCode)


Copyright © 2013. All Rights Reserved.