Page 1 of 2

Box2D SimpleTestbed. UPDATE: Version 1.0

Posted: Mon Jun 18, 2012 10:43 pm
by vernon
This is the project I've started working on.
Box2D on C++ has a great Testbed application, where you can quite easily add new physics environments to test out.
You don't need to use placeholder graphics or anything, because the Testbed renders the bodies, shapes, joints etc.
You can download it here: http://box2d.googlecode.com/files/Testbed_v2.1.3.zip [windows executable]

The main goal is to be able to test Lua/LÖVE based Box2D code, not just C++.

The original has a lot of features, and I probably won't port all of those.
My first aim is to get the rendering right with LÖVE's graphics tools and to be able to switch between simulations.

I hope this will be useful for everyone who's struggling with testing box2D's features.

Edit:
first prototype is ready. No camera yet. Thanks for Boolsheet on the IRC channel for the debugging :3

Edit:
version 0.2
added:
working GUI (except for the time step button and update frequency slider)
camera controls: arrow keys, keypad + - buttons for zooming. Mouse: wheels zoom, right button drags the screen. You can redefine any of the keyboard controls in your own test!
more advanced drawing: now correctly draws all the shapes. Bounding box drawing was added. Joint drawing was added. Coordinate system toggleable

edit:
version 0.21 bugfixes. Fixed Jansen walker, and I fixed the other tests too. Fixed drawing of angled shapes.

edit:
version 1.0 Added features: better drawing algorithm, mousejoint to manipulate objects, Time Stepping capabilities.

Controls:
arrow keys: they move the camera around
right click drag: moves the environment around
numpad +, numpad -, mousewheels: zooming
left click on shape, drag: it creates a mousejoint between a dynamic body and the cursor's position. It applies a force to the body.

How to add your own tests:
inherit a class from my Test class and save it in a lua file. The name of the class and the filename must match. Put your lua file in the tests directory. Tadaaa!
For more details check out the source of the default tests. Especially: tests/spherestack.lua
Image

Re: Box2D SimpleTestbed

Posted: Tue Jun 19, 2012 1:51 pm
by Roland_Yonaba
That would be awasome. Actually I never used love.physiscs module, but such a tool will be appreciated.
Much thanks!

Re: Box2D SimpleTestbed

Posted: Wed Jun 20, 2012 7:14 pm
by dreadkillz
This is great, thank you.

Re: Box2D SimpleTestbed. UPDATE: Version 0.2

Posted: Fri Jun 22, 2012 3:00 pm
by vernon
New 0.2 version is out. :3

Re: Box2D SimpleTestbed. UPDATE: Version 0.21

Posted: Sat Jun 23, 2012 5:40 pm
by vernon
Version 0.21

Now everything works correctly.

Features to add:
-time step change
-updating the game world step by step
-mouse joint force effects on the world objects
-more detailed drawing of the different kind of joints
-drawing of contact points
-drawing of friction forces

There is still a lot of features missing, but the testbed can be used for actual testing. Have fun using it :3

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Posted: Sun Jun 24, 2012 7:08 pm
by vernon
Version 1.0 is done.

I worked so much on this this week that I kinda hate it now lol.
Have fun using it

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Posted: Wed Jul 25, 2012 7:13 pm
by dreadkillz
Hey I really like your testbed so I refactored the code a bit, and made it a little cleaner (in my opinion). Also a camera system with proper zooming works now instead of scaling everything manually and better coordinates drawing. Pretty useful when I just want dump a quick box2d test. Thanks a lot!

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Posted: Sat Jul 28, 2012 1:49 am
by vernon
the new coordinates look cool. :)

well I kinda started with attaching the camera but I couldn't figure out how to keep it from messing up the lines. then i started doing the manual scaling madness.

Code: Select all

love.graphics.setLineWidth(1/camera.sx) 
well this line of yours is pretty smart lol. It didn't came to mind that i could set it under 1 pixel. hehe. then the zoom brings it back to 1.

can you explain what hardoncollider does in the project? just providing the shape class for the improved camera?

edit:
oh so you are the maker of hump? :) i read the docs on your github. Now i understand it.

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Posted: Sat Jul 28, 2012 2:45 am
by Ref
Hay dreadkillz!
The right click - drag works as expected.
The arrow keys seem to be reversed.
Is that intentional?
Just seems couter-intuitive.

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Posted: Sat Jul 28, 2012 2:55 am
by vernon
that just wasn't thought through properly by me.

the right mouse click drags the world, while the arrow keys move the camera around. can be fixed by negating two numbers.