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
,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 AABB
private Body
protected static final long
private boolean
private final Vec2
private final Vec2
private float
private final TestQueryCallback
private final Color3f
private final Color3f
private final Color3f
private final Color3f
private final Color3f
private JbDeserializer
protected DestructionListener
private boolean
protected static final long
protected Body
private boolean
private final java.util.LinkedList
<QueueItem> private boolean
private static final org.slf4j.Logger
protected int
protected World
Only visible for compatibility.static final int
private TestbedModel
protected static final long
private final Color3f
private MouseJoint
private final Vec2
private final Vec2
private final Vec2
private final Vec2
private int
static final ContactPoint[]
private final AABB
private boolean
private boolean
private JbSerializer
private final Collision.PointState[]
private final Collision.PointState[]
private final java.util.List
<java.lang.String> private int
private final Vec2
private final java.util.LinkedList
<java.lang.String> private java.lang.String
private final Vec2
private final Vec2
private final WorldManifold
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
_load()
protected void
_reset()
protected void
_save()
void
addTextLine
(java.lang.String argTextLine) Adds a text line to the reporting areavoid
beginContact
(Contact contact) Called when two fixtures begin to touch.void
void
endContact
(Contact contact) Called when two fixtures cease to touch.void
exit()
called when the tests exitsgetBomb()
Gets the 'bomb' body if it's presentfloat
static ContactPoint[]
Gets the contact points for the current testGets the debug draw for the testbedOverride for a different default camera posfloat
Override for a different default camera scalejava.lang.String
Gets the filename of the current test.Gets the ground body of the world, used for some jointsgetModel()
Gets the testbed modelint
The number of contact points we're storingint
java.lang.Long
java.lang.Long
java.lang.Long
java.lang.Long
java.lang.Long
abstract java.lang.String
The name of the testgetWorld()
Gets the current worldGets the world position of the mousevoid
void
init
(TestbedModel argModel) abstract void
initTest
(boolean deserialized) Initializes the current testboolean
boolean
boolean
Override to enable saving and loading.boolean
isUnsupported
(UnsupportedObjectException exception) Called when an object is unsupported by the de/serializer.void
jointDestroyed
(Joint joint) void
keyPressed
(char keyCar, int keyCode) void
keyReleased
(char keyChar, int keyCode) void
void
launchBomb
(Vec2 position, Vec2 velocity) void
load()
Loads the test from filevoid
Called for mouse-downvoid
Called when mouse is movedvoid
Called for mouse-upvoid
postSolve
(Contact contact, ContactImpulse impulse) This lets you inspect a contact after the solver is finished.void
This is called after a contact is updated.void
processBody
(Body body, java.lang.Long tag) void
processFixture
(Fixture fixture, java.lang.Long tag) void
processJoint
(Joint joint, java.lang.Long tag) void
processShape
(Shape shape, java.lang.Long tag) void
processWorld
(World world, java.lang.Long tag) void
queueKeyPressed
(char c, int code) void
queueKeyReleased
(char c, int code) void
void
void
queueMouseUp
(Vec2 p) void
void
reset()
Resets the testvoid
save()
Saves the testvoid
setCachedCameraPos
(Vec2 argPos) void
setCachedCameraScale
(float cachedCameraScale) void
void
Sets the current testbed cameravoid
setDialogOnSaveLoadErrors
(boolean dialogOnSaveLoadErrors) void
setHasCachedCamera
(boolean hasCachedCamera) void
setTitle
(java.lang.String argTitle) Sets the title of the testvoid
Called when shift-mouse down occursvoid
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 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
Gets the current world- Returns:
-
getModel
Gets the testbed model- Returns:
-
getContactPoints
Gets the contact points for the current test- Returns:
-
getGroundBody
Gets the ground body of the world, used for some joints- Returns:
-
getDebugDraw
Gets the debug draw for the testbed- Returns:
-
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
Gets the 'bomb' body if it's present- Returns:
-
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
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
-
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
Called when shift-mouse down occurs- Parameters:
p
-
-
mouseUp
Called for mouse-up- Parameters:
p
-
-
mouseDown
Called for mouse-down- Parameters:
p
-
-
mouseMove
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
-
spawnBomb
-
completeBombSpawn
-
isSaveLoadEnabled
public boolean isSaveLoadEnabled()Override to enable saving and loading. Remember to also override theJbDeserializer.ObjectListener
andJbSerializer.ObjectSigner
methods if you need to- Returns:
-
getTag
- Specified by:
getTag
in interfaceJbSerializer.ObjectSigner
- Parameters:
body
-- Returns:
- the tag for the body. can be null.
-
getTag
- Specified by:
getTag
in interfaceJbSerializer.ObjectSigner
- Parameters:
fixture
-- Returns:
- the tag for the fixture. can be null.
-
getTag
- Specified by:
getTag
in interfaceJbSerializer.ObjectSigner
- Parameters:
joint
-- Returns:
- the tag for the joint. can be null.
-
getTag
- Specified by:
getTag
in interfaceJbSerializer.ObjectSigner
- Parameters:
shape
-- Returns:
- the tag for the shape. can be null.
-
getTag
- Specified by:
getTag
in interfaceJbSerializer.ObjectSigner
- Parameters:
world
-- Returns:
- the tag for the world. can be null.
-
processBody
- Specified by:
processBody
in interfaceJbDeserializer.ObjectListener
-
processFixture
- Specified by:
processFixture
in interfaceJbDeserializer.ObjectListener
-
processJoint
- Specified by:
processJoint
in interfaceJbDeserializer.ObjectListener
-
processShape
- Specified by:
processShape
in interfaceJbDeserializer.ObjectListener
-
processWorld
- Specified by:
processWorld
in interfaceJbDeserializer.ObjectListener
-
isUnsupported
Description copied from interface:UnsupportedListener
Called when an object is unsupported by the de/serializer.- Specified by:
isUnsupported
in 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:ContactListener
Called when two fixtures begin to touch.- Specified by:
beginContact
in interfaceContactListener
- Parameters:
contact
-
-
endContact
Description copied from interface:ContactListener
Called when two fixtures cease to touch.- Specified by:
endContact
in interfaceContactListener
- Parameters:
contact
-
-
postSolve
Description copied from interface:ContactListener
This 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:
postSolve
in interfaceContactListener
- Parameters:
contact
-impulse
- this is usually a pooled variable, so it will be modified after this call
-
preSolve
Description copied from interface:ContactListener
This 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:
preSolve
in interfaceContactListener
- Parameters:
contact
-oldManifold
-
-
keyPressed
public void keyPressed(char keyCar, int keyCode) -
keyReleased
public void keyReleased(char keyChar, int keyCode)
-