Class TestbedTest
java.lang.Object
org.jbox2d.testbed.framework.TestbedTest
- All Implemented Interfaces:
ContactListener, JbDeserializer.ObjectListener, JbSerializer.ObjectSigner, 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 Object
implements ContactListener, JbDeserializer.ObjectListener, JbSerializer.ObjectSigner, UnsupportedListener
- Author:
- Daniel Murphy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final longprotected DestructionListenerprotected static final longprotected Bodyprotected intprotected WorldOnly visible for compatibility.static final intprotected static final longstatic final ContactPoint[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_load()protected void_reset()protected void_save()voidaddTextLine(String argTextLine) Adds a text line to the reporting areavoidbeginContact(Contact contact) Called when two fixtures begin to touch.voidvoidendContact(Contact contact) Called when two fixtures cease to touch.voidexit()called when the tests exitsgetBomb()Gets the 'bomb' body if it's presentfloatstatic ContactPoint[]Gets the contact points for the current testGets the debug draw for the testbedOverride for a different default camera posfloatOverride for a different default camera scaleGets the filename of the current test.Gets the ground body of the world, used for some jointsgetModel()Gets the testbed modelintThe number of contact points we're storingintabstract StringThe name of the testgetWorld()Gets the current worldGets the world position of the mousevoidvoidinit(TestbedModel argModel) abstract voidinitTest(boolean deserialized) Initializes the current testbooleanbooleanbooleanOverride to enable saving and loading.booleanisUnsupported(UnsupportedObjectException exception) Called when an object is unsupported by the de/serializer.voidjointDestroyed(Joint joint) voidkeyPressed(char keyCar, int keyCode) voidkeyReleased(char keyChar, int keyCode) voidvoidlaunchBomb(Vec2 position, Vec2 velocity) voidload()Loads the test from filevoidCalled for mouse-downvoidCalled when mouse is movedvoidCalled for mouse-upvoidpostSolve(Contact contact, ContactImpulse impulse) This lets you inspect a contact after the solver is finished.voidThis is called after a contact is updated.voidprocessBody(Body body, Long tag) voidprocessFixture(Fixture fixture, Long tag) voidprocessJoint(Joint joint, Long tag) voidprocessShape(Shape shape, Long tag) voidprocessWorld(World world, Long tag) voidqueueKeyPressed(char c, int code) voidqueueKeyReleased(char c, int code) voidvoidvoidqueueMouseUp(Vec2 p) voidvoidreset()Resets the testvoidsave()Saves the testvoidsetCachedCameraPos(Vec2 argPos) voidsetCachedCameraScale(float cachedCameraScale) voidvoidSets the current testbed cameravoidsetDialogOnSaveLoadErrors(boolean dialogOnSaveLoadErrors) voidsetHasCachedCamera(boolean hasCachedCamera) voidSets the title of the testvoidCalled when shift-mouse down occursvoidvoidstep(TestbedSettings settings) voidupdate()
-
Field Details
-
MAX_CONTACT_POINTS
public static final int MAX_CONTACT_POINTS- See Also:
-
GROUND_BODY_TAG
protected static final long GROUND_BODY_TAG- See Also:
-
BOMB_TAG
protected static final long BOMB_TAG- See Also:
-
MOUSE_JOINT_TAG
protected static final long MOUSE_JOINT_TAG- See Also:
-
points
-
m_world
Only visible for compatibility. Should usegetWorld()instead. -
groundBody
-
destructionListener
-
m_textLine
protected int m_textLine
-
-
Constructor Details
-
TestbedTest
public TestbedTest()
-
-
Method Details
-
init
-
init
-
getWorld
-
getModel
-
getContactPoints
Gets the contact points for the current test- Returns:
-
getGroundBody
-
getDebugDraw
-
getWorldMouse
-
getStepCount
public int getStepCount() -
getPointCount
public int getPointCount()The number of contact points we're storing- Returns:
-
getBomb
-
getCachedCameraScale
public float getCachedCameraScale() -
setCachedCameraScale
public void setCachedCameraScale(float cachedCameraScale) -
getCachedCameraPos
-
setCachedCameraPos
-
isHasCachedCamera
public boolean isHasCachedCamera() -
setHasCachedCamera
public void setHasCachedCamera(boolean hasCachedCamera) -
isDialogOnSaveLoadErrors
public boolean isDialogOnSaveLoadErrors() -
setDialogOnSaveLoadErrors
public void setDialogOnSaveLoadErrors(boolean dialogOnSaveLoadErrors) -
getDefaultCameraPos
-
getDefaultCameraScale
public float getDefaultCameraScale()Override for a different default camera scale- Returns:
-
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
-
setCamera
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
-
exit
public void exit()called when the tests exits -
update
public void update() -
step
-
queueShiftMouseDown
-
queueMouseUp
-
queueMouseDown
-
queueMouseMove
-
queueKeyPressed
public void queueKeyPressed(char c, int code) -
queueKeyReleased
public void queueKeyReleased(char c, int code) -
shiftMouseDown
-
mouseUp
-
mouseDown
-
mouseMove
-
setTitle
-
addTextLine
Adds a text line to the reporting area- Parameters:
argTextLine-
-
lanchBomb
public void lanchBomb() -
launchBomb
-
spawnBomb
-
completeBombSpawn
-
isSaveLoadEnabled
public boolean isSaveLoadEnabled()Override to enable saving and loading. Remember to also override theJbDeserializer.ObjectListenerandJbSerializer.ObjectSignermethods if you need to- Returns:
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Parameters:
body-- Returns:
- the tag for the body. can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Parameters:
fixture-- Returns:
- the tag for the fixture. can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Parameters:
joint-- Returns:
- the tag for the joint. can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Parameters:
shape-- Returns:
- the tag for the shape. can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Parameters:
world-- Returns:
- the tag for the world. can be null.
-
processBody
- Specified by:
processBodyin interfaceJbDeserializer.ObjectListener
-
processFixture
- Specified by:
processFixturein interfaceJbDeserializer.ObjectListener
-
processJoint
- Specified by:
processJointin interfaceJbDeserializer.ObjectListener
-
processShape
- Specified by:
processShapein interfaceJbDeserializer.ObjectListener
-
processWorld
- Specified by:
processWorldin interfaceJbDeserializer.ObjectListener
-
isUnsupported
Description copied from interface:UnsupportedListenerCalled when an object is unsupported by the de/serializer.- Specified by:
isUnsupportedin interfaceUnsupportedListener- Parameters:
exception- the exception describing the error- Returns:
- if the process should stop and the exception be thrown
-
jointDestroyed
-
beginContact
Description copied from interface:ContactListenerCalled when two fixtures begin to touch.- Specified by:
beginContactin interfaceContactListener- Parameters:
contact-
-
endContact
Description copied from interface:ContactListenerCalled when two fixtures cease to touch.- Specified by:
endContactin interfaceContactListener- Parameters:
contact-
-
postSolve
Description copied from interface:ContactListenerThis lets you inspect a contact after the solver is finished. This is useful for inspecting impulses. Note: the contact manifold does not include time of impact impulses, which can be arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly in a separate data structure. Note: this is only called for contacts that are touching, solid, and awake.- Specified by:
postSolvein interfaceContactListener- Parameters:
contact-impulse- this is usually a pooled variable, so it will be modified after this call
-
preSolve
Description copied from interface:ContactListenerThis is called after a contact is updated. This allows you to inspect a contact before it goes to the solver. If you are careful, you can modify the contact manifold (e.g. disable contact). A copy of the old manifold is provided so that you can detect changes. Note: this is called only for awake bodies. Note: this is called even when the number of contact points is zero. Note: this is not called for sensors. Note: if you set the number of contact points to zero, you will not get an EndContact callback. However, you may get a BeginContact callback the next step. Note: the oldManifold parameter is pooled, so it will be the same object for every callback for each thread.- Specified by:
preSolvein interfaceContactListener- Parameters:
contact-oldManifold-
-
keyPressed
public void keyPressed(char keyCar, int keyCode) -
keyReleased
public void keyReleased(char keyChar, int keyCode)
-