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 java.lang.Object
implements ContactListener, JbDeserializer.ObjectListener, JbSerializer.ObjectSigner, UnsupportedListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AABBprivate Bodyprotected static final longprivate booleanprivate final Vec2private final Vec2private floatprivate final TestQueryCallbackprivate final Color3fprivate final Color3fprivate final Color3fprivate final Color3fprivate final Color3fprivate JbDeserializerprotected DestructionListenerprivate booleanprotected static final longprotected Bodyprivate booleanprivate final java.util.LinkedList<QueueItem> private booleanprivate static final org.slf4j.Loggerprotected intprotected WorldOnly visible for compatibility.static final intprivate TestbedModelprotected static final longprivate final Color3fprivate MouseJointprivate final Vec2private final Vec2private final Vec2private final Vec2private intstatic final ContactPoint[]private final AABBprivate booleanprivate booleanprivate JbSerializerprivate final Collision.PointState[]private final Collision.PointState[]private final java.util.List<java.lang.String> private intprivate final Vec2private final java.util.LinkedList<java.lang.String> private java.lang.Stringprivate final Vec2private final Vec2private final WorldManifold -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_load()protected void_reset()protected void_save()voidaddTextLine(java.lang.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 scalejava.lang.StringGets 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 storingintjava.lang.Longjava.lang.Longjava.lang.Longjava.lang.Longjava.lang.Longabstract java.lang.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, java.lang.Long tag) voidprocessFixture(Fixture fixture, java.lang.Long tag) voidprocessJoint(Joint joint, java.lang.Long tag) voidprocessShape(Shape shape, java.lang.Long tag) voidprocessWorld(World world, java.lang.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) voidsetTitle(java.lang.String argTitle) Sets the title of the testvoidCalled when shift-mouse down occursvoidvoidstep(TestbedSettings settings) voidupdate()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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:
-
log
private static final org.slf4j.Logger log -
points
-
m_world
Only visible for compatibility. Should usegetWorld()instead. -
groundBody
-
mouseJoint
-
bomb
-
bombSpawnPoint
-
bombSpawning
private boolean bombSpawning -
mouseWorld
-
pointCount
private int pointCount -
stepCount
private int stepCount -
model
-
destructionListener
-
inputQueue
-
title
private java.lang.String title -
m_textLine
protected int m_textLine -
textList
private final java.util.LinkedList<java.lang.String> textList -
cachedCameraScale
private float cachedCameraScale -
cachedCameraPos
-
hasCachedCamera
private boolean hasCachedCamera -
serializer
-
deserializer
-
dialogOnSaveLoadErrors
private boolean dialogOnSaveLoadErrors -
savePending
private boolean savePending -
loadPending
private boolean loadPending -
resetPending
private boolean resetPending -
color1
-
color2
-
color3
-
color4
-
color5
-
mouseColor
-
p1
-
p2
-
tangent
-
statsList
private final java.util.List<java.lang.String> statsList -
queryAABB
-
callback
-
p
-
v
-
aabb
-
vel
-
state1
-
state2
-
worldManifold
-
-
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
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
-
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
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
-
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
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
-
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)
-