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

Author:
Daniel Murphy
  • Field Details

  • Constructor Details

    • TestbedTest

      public TestbedTest()
  • Method Details

    • init

      public void init(TestbedModel model)
    • init

      public void init(World world, boolean deserialized)
    • getSerializer

      protected JbSerializer getSerializer()
    • getDeserializer

      protected JbDeserializer getDeserializer()
    • getWorld

      public World getWorld()
      Get the current world.
    • getModel

      public TestbedModel getModel()
      Get the testbed model.
    • getContactPoints

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

      public Body getGroundBody()
      Gets the ground body of the world, used for some joints
    • getDebugDraw

      public DebugDraw getDebugDraw()
      Gets the debug draw for the testbed
    • getWorldMouse

      public Vec2 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

      public TestbedCamera getCamera()
    • getBomb

      public Body getBomb()
      Gets the 'bomb' body if it's present
    • getDefaultCameraPos

      public Vec2 getDefaultCameraPos()
      Override for a different default camera position
    • getDefaultCameraScale

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

      public boolean isMouseTracing()
    • getMouseTracerPosition

      public Vec2 getMouseTracerPosition()
    • getMouseTracerVelocity

      public Vec2 getMouseTracerVelocity()
    • getFilename

      public String getFilename()
      Gets the filename of the current test. The default implementation uses the test name with no spaces.
    • setCamera

      public void setCamera(Vec2 argPos)
      Deprecated.
    • setCamera

      public void setCamera(Vec2 argPos, float scale)
      Deprecated.
    • 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

      public abstract String getTestName()
      The name of the test
    • addTextLine

      public void addTextLine(String line)
      Adds a text line to the reporting area
    • exit

      public void exit()
      called when the tests exit
    • step

      public void step(TestbedSettings settings)
    • mouseUp

      public void mouseUp(Vec2 p, int button)
      Called for mouse-up
    • keyPressed

      public void keyPressed(char keyChar, int keyCode)
    • keyReleased

      public void keyReleased(char keyChar, int keyCode)
    • mouseDown

      public void mouseDown(Vec2 p, int button)
    • mouseMove

      public void mouseMove(Vec2 p)
    • mouseDrag

      public void mouseDrag(Vec2 p, int button)
    • launchBomb

      public void launchBomb()
    • 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
    • getTag

      public Long getTag(Body body)
      Specified by:
      getTag in interface JbSerializer.ObjectSigner
      Returns:
      The tag for the body. Can be null.
    • getTag

      public Long getTag(Fixture fixture)
      Specified by:
      getTag in interface JbSerializer.ObjectSigner
      Returns:
      The tag for the fixture. Can be null.
    • getTag

      public Long getTag(Joint joint)
      Specified by:
      getTag in interface JbSerializer.ObjectSigner
      Returns:
      The tag for the joint. Can be null.
    • getTag

      public Long getTag(Shape shape)
      Specified by:
      getTag in interface JbSerializer.ObjectSigner
      Returns:
      The tag for the shape. Can be null.
    • getTag

      public Long getTag(World world)
      Specified by:
      getTag in interface JbSerializer.ObjectSigner
      Returns:
      The tag for the world. Can be null.
    • processBody

      public void processBody(Body body, Long tag)
      Specified by:
      processBody in interface JbDeserializer.ObjectListener
    • processFixture

      public void processFixture(Fixture fixture, Long tag)
      Specified by:
      processFixture in interface JbDeserializer.ObjectListener
    • processJoint

      public void processJoint(Joint joint, Long tag)
      Specified by:
      processJoint in interface JbDeserializer.ObjectListener
    • processShape

      public void processShape(Shape shape, Long tag)
      Specified by:
      processShape in interface JbDeserializer.ObjectListener
    • processWorld

      public void processWorld(World world, Long tag)
      Specified by:
      processWorld in interface JbDeserializer.ObjectListener
    • isUnsupported

      public boolean isUnsupported(UnsupportedObjectException exception)
      Description copied from interface: UnsupportedListener
      Called when an object is unsupported by the de/serializer.
      Specified by:
      isUnsupported in interface UnsupportedListener
      Parameters:
      exception - The exception describing the error.
      Returns:
      if the process should stop and the exception be thrown.
    • fixtureDestroyed

      public void fixtureDestroyed(Fixture fixture)
    • jointDestroyed

      public void jointDestroyed(Joint joint)
    • beginContact

      public void beginContact(Contact contact)
      Description copied from interface: ContactListener
      Called when two fixtures begin to touch.
      Specified by:
      beginContact in interface ContactListener
    • endContact

      public void endContact(Contact contact)
      Description copied from interface: ContactListener
      Called when two fixtures cease to touch.
      Specified by:
      endContact in interface ContactListener
    • particleDestroyed

      public void particleDestroyed(int particle)
    • particleGroupDestroyed

      public void particleGroupDestroyed(ParticleGroup group)
    • postSolve

      public void postSolve(Contact contact, ContactImpulse impulse)
      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 interface ContactListener
      impulse - This is usually a pooled variable, so it will be modified after this call
    • preSolve

      public void preSolve(Contact contact, Manifold oldManifold)
      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 interface ContactListener