Package org.jbox2d.testbed.framework
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,BulletTest,Cantilever,Car,Chain,CharacterCollision,CircleStress,CollisionFiltering,CollisionProcessing,CompoundShapes,ConfinedTest,ContinuousTest,ConvexHull,ConveyorBelt,DamBreak,DistanceTest,DominoTest,DominoTower,DrawingParticles,DynamicTreeTest,EdgeShapes,EdgeTest,FixedPendulumTest,FreePendulumTest,Gears,HelloWorld,LiquidTimer,MotorTest,OneSidedTest,Particles,ParticleTypes,PistonTest,PolyShapes,PrismaticTest,Pulleys,PyramidTest,RayCastTest,RevoluteTest,RopeTest,SensorTest,ShapeEditing,SliderCrankTest,SphereStack,TheoJansen,Tumbler,VaryingFrictionTest,VaryingRestitution,VerticalStack,WaveMachine,Web
public abstract class TestbedTest
extends Object
implements ContactListener, JbDeserializer.ObjectListener, JbSerializer.ObjectSigner, UnsupportedListener
- Author:
- Daniel Murphy
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected static final longprotected DestructionListenerprotected static final longprotected Bodystatic final intstatic final intprotected static final longprotected booleanprotected ParticleDestructionListenerfinal ContactPoint[]static final intstatic final intprotected intprotected WorldOnly visible for compatibility.static final float -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTextLine(String line) Adds a text line to the reporting areavoidbeginContact(Contact contact) Called when two fixtures begin to touch.voidendContact(Contact contact) Called when two fixtures cease to touch.voidexit()called when the tests exitvoidfixtureDestroyed(Fixture fixture) getBomb()Gets the 'bomb' body if it's presentGets the contact points for the current testGets the debug draw for the testbedOverride for a different default camera positionfloatOverride for a different default camera scaleprotected JbDeserializerGets the filename of the current test.Gets the ground body of the world, used for some jointsgetModel()Get the testbed model.intThe number of contact points we're storingprotected JbSerializerintabstract StringThe name of the testgetWorld()Get the current world.Gets the world position of the mousevoidvoidinit(TestbedModel model) abstract voidinitTest(boolean deserialized) Initializes the current test.booleanbooleanOverride to enable saving and loading.booleanisUnsupported(UnsupportedObjectException exception) Called when an object is unsupported by the de/serializer.voidjointDestroyed(Joint joint) voidkeyPressed(char keyChar, int keyCode) voidkeyReleased(char keyChar, int keyCode) voidvoidvoidvoidvoidCalled for mouse-upvoidparticleDestroyed(int particle) voidvoidpostSolve(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) voidDeprecated.voidDeprecated.usegetCamera()voidstep(TestbedSettings settings)
-
Field Details
-
MAX_CONTACT_POINTS
public static final int MAX_CONTACT_POINTS- See Also:
-
ZOOM_SCALE_DIFF
public static final float ZOOM_SCALE_DIFF- See Also:
-
TEXT_LINE_SPACE
public static final int TEXT_LINE_SPACE- See Also:
-
TEXT_SECTION_SPACE
public static final int TEXT_SECTION_SPACE- See Also:
-
MOUSE_JOINT_BUTTON
public static final int MOUSE_JOINT_BUTTON- See Also:
-
BOMB_SPAWN_BUTTON
public static final int BOMB_SPAWN_BUTTON- 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
-
world
Only visible for compatibility. Should usegetWorld()instead. -
groundBody
-
mouseTracing
protected boolean mouseTracing -
destructionListener
-
particleDestructionListener
-
textLine
protected int textLine
-
-
Constructor Details
-
TestbedTest
public TestbedTest()
-
-
Method Details
-
init
-
init
-
getSerializer
-
getDeserializer
-
getWorld
Get the current world. -
getModel
Get the testbed model. -
getContactPoints
Gets the contact points for the current test -
getGroundBody
Gets the ground body of the world, used for some joints -
getDebugDraw
Gets the debug draw for the testbed -
getWorldMouse
Gets the world position of the mouse -
getStepCount
public int getStepCount() -
getPointCount
public int getPointCount()The number of contact points we're storing -
getCamera
-
getBomb
Gets the 'bomb' body if it's present -
getDefaultCameraPos
Override for a different default camera position -
getDefaultCameraScale
public float getDefaultCameraScale()Override for a different default camera scale -
isMouseTracing
public boolean isMouseTracing() -
getMouseTracerPosition
-
getMouseTracerVelocity
-
getFilename
Gets the filename of the current test. The default implementation uses the test name with no spaces. -
setCamera
Deprecated.usegetCamera() -
setCamera
Deprecated.usegetCamera() -
initTest
public abstract void initTest(boolean deserialized) Initializes the current test.- Parameters:
deserialized- If the test was deserialized from a file. If so, all physics objects are already added.
-
getTestName
The name of the test -
addTextLine
Adds a text line to the reporting area -
exit
public void exit()called when the tests exit -
step
-
mouseUp
Called for mouse-up -
keyPressed
public void keyPressed(char keyChar, int keyCode) -
keyReleased
public void keyReleased(char keyChar, int keyCode) -
mouseDown
-
mouseMove
-
mouseDrag
-
launchBomb
public void launchBomb() -
isSaveLoadEnabled
public boolean isSaveLoadEnabled()Override to enable saving and loading. Remember to also override theJbDeserializer.ObjectListenerandJbSerializer.ObjectSignermethods if you need to -
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Returns:
- The tag for the body. Can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Returns:
- The tag for the fixture. Can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Returns:
- The tag for the joint. Can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- Returns:
- The tag for the shape. Can be null.
-
getTag
- Specified by:
getTagin interfaceJbSerializer.ObjectSigner- 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.
-
fixtureDestroyed
-
jointDestroyed
-
beginContact
Description copied from interface:ContactListenerCalled when two fixtures begin to touch.- Specified by:
beginContactin interfaceContactListener
-
endContact
Description copied from interface:ContactListenerCalled when two fixtures cease to touch.- Specified by:
endContactin interfaceContactListener
-
particleDestroyed
public void particleDestroyed(int particle) -
particleGroupDestroyed
-
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 interfaceContactListenerimpulse- 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
-
getCamera()