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
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
Box2D SimpleTestbed. UPDATE: Version 1.0
Box2D SimpleTestbed. UPDATE: Version 1.0
- Attachments
-
- SimpleTestbed_1.0_mod.love
- updated by dreadkillz
He refactored the code and made some features better. - (119.36 KiB) Downloaded 391 times
-
- SimpleTestbed_1.0.love
- version 1.0
- (101.45 KiB) Downloaded 604 times
Last edited by vernon on Sat Jul 28, 2012 10:17 pm, edited 9 times in total.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Box2D SimpleTestbed
That would be awasome. Actually I never used love.physiscs module, but such a tool will be appreciated.
Much thanks!
Much thanks!
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: Box2D SimpleTestbed. UPDATE: Version 0.21
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
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
Re: Box2D SimpleTestbed. UPDATE: Version 1.0
Version 1.0 is done.
I worked so much on this this week that I kinda hate it now lol.
Have fun using it
I worked so much on this this week that I kinda hate it now lol.
Have fun using it
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: Box2D SimpleTestbed. UPDATE: Version 1.0
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 312 times
Re: Box2D SimpleTestbed. UPDATE: Version 1.0
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. 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.
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)
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
Hay dreadkillz!
The right click - drag works as expected.
The arrow keys seem to be reversed.
Is that intentional?
Just seems couter-intuitive.
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
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.
the right mouse click drags the world, while the arrow keys move the camera around. can be fixed by negating two numbers.
Who is online
Users browsing this forum: No registered users and 1 guest