Box2D SimpleTestbed. UPDATE: Version 1.0

Showcase your libraries, tools and other projects that help your fellow love users.

Did you find the SimpleTestbed useful?

Yes
7
78%
No
2
22%
Maybe
0
No votes
 
Total votes: 9

User avatar
vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

Box2D SimpleTestbed. UPDATE: Version 1.0

Post 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
Attachments
SimpleTestbed_1.0_mod.love
updated by dreadkillz
He refactored the code and made some features better.
(119.36 KiB) Downloaded 399 times
SimpleTestbed_1.0.love
version 1.0
(101.45 KiB) Downloaded 610 times
Last edited by vernon on Sat Jul 28, 2012 10:17 pm, edited 9 times in total.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Box2D SimpleTestbed

Post by Roland_Yonaba »

That would be awasome. Actually I never used love.physiscs module, but such a tool will be appreciated.
Much thanks!
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

Re: Box2D SimpleTestbed

Post by dreadkillz »

This is great, thank you.
User avatar
vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

Re: Box2D SimpleTestbed. UPDATE: Version 0.2

Post by vernon »

New 0.2 version is out. :3
User avatar
vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

Re: Box2D SimpleTestbed. UPDATE: Version 0.21

Post 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
User avatar
vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Post 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
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Post 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!
Attachments
SimpleTestbed_1.0_mod.love
(119.36 KiB) Downloaded 320 times
User avatar
vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Post 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.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Post 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.
User avatar
vernon
Prole
Posts: 18
Joined: Fri Oct 07, 2011 3:54 pm

Re: Box2D SimpleTestbed. UPDATE: Version 1.0

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest