We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › BoxWrap2d physics library - seeking feedback
Pages: 1 2 3 
BoxWrap2d physics library - seeking feedback (Read 20616 times)
BoxWrap2d physics library - seeking feedback
Jun 14th, 2008, 2:55am
 
Hi all,

I finally took a couple of days and put together a light Processing-specific wrapper around the JBox2d physics library.  It's called BoxWrap2d, and you can check it out at http://www.jbox2d.org/processing.  It should make doing rigid body physics in Processing about as simple as possible.

At the moment, though, this is basically one very rough and jagged edge, certainly not a release quality library yet!  There's a lot of functionality available (in fact, all the functionality of JBox2d if you have the guts to dig in and learn that), but there are some things missing, some things broken (probably, at least, though I don't know what yet!), and some things that could be a lot easier to do.  Plus, right now there's only Javadoc documentation.

But it's got boxes, circles, convex polygons, and a bunch of joints, which should be a start.  If you're interested, give it a d/l and try it out.  Let me know if you have any suggestions.

Oh, and this will probably only work with newer versions of Processing, because JBox2d uses Java 1.5.  Also, please ignore the extraneous import statements that show up when you import the library, I'm aware of the problem and will try to clean those up at some point soon.
Re: BoxWrap2d physics library - seeking feedback
Reply #1 - Jun 16th, 2008, 7:20am
 
Very nice, thank you Smiley I'm glad we're moving beyond particle physics and springs!!
Re: BoxWrap2d physics library - seeking feedback
Reply #2 - Jun 17th, 2008, 2:57am
 
No problem at all, I just hope it is useful to someone! :>

Honestly, the Java port of Box2d was mainly done to scratch my own itch, as I've been stuck in particles + springs territory for a while myself, never quite having the energy to make a full rigid body engine.  Turns out that I both learned more and ended up with a better engine by porting Box2d than I would have by fighting through it all myself!

Don't knock particles and springs, though - if those are all you need, they will usually be a lot faster than a full rigid body engine.
Re: BoxWrap2d physics library - seeking feedback
Reply #3 - Jun 17th, 2008, 6:46pm
 
Eric Jordan wrote on Jun 17th, 2008, 2:57am:
Don't knock particles and springs, though - if those are all you need, they will usually be a lot faster than a full rigid body engine.

And smaller, too! Wink
I like the demo parsing HTML pages and showing the structure with circles and springs: simple, effective and appealing.
Re: BoxWrap2d physics library - seeking feedback
Reply #4 - Sep 26th, 2008, 11:13am
 
im trying to apply some forces to rigid bodies, but i cant seem to get it to work. reading the box2d manual doesnt seem to be the best thing to do.. processing says most of the Body functions are not available?
where can i get a list of functions for this processing version ?

i want to create a basic attraction/repulsive program.
Re: BoxWrap2d physics library - seeking feedback
Reply #5 - Sep 27th, 2008, 1:20am
 
Eric,

This is so wonderful! Thank you. I don't have time to test right now (too many other Processing tasks) but I hope you get some good feedback. Something like this has been missing for a long time. I look forward to using it.

Casey

Re: BoxWrap2d physics library - seeking feedback
Reply #6 - Sep 27th, 2008, 1:40am
 
@crmx: You should be able to call physics.applyForce(body, forceX, forceY) - however, it appears that the version of the library that's online is older than the one I've got on my machine, which I didn't realize until just now!  In particular, it lacks the applyForce function in the wrapper.

As a temporary workaround until I upload a new version (I want to make sure the local one I've got actually works right...), you can do the following:
Code:
Vec2 force = new Vec2(forceX, forceY);
Vec2 applicationPoint = body.getWorldCenter();//gets body center of mass
body.applyForce(physics.screenToWorldVector(force), physics.screenToWorld(applicationPoint));

Which is not too difficult, the only tricky bit is that the physics coordinates differ from the screen coordinates so you need to manually transform them first...this is one of the annoying things that this wrapper intends to hide from you most of the time.

In any case, I'll upload a new version soon.
Re: BoxWrap2d physics library - seeking feedback
Reply #7 - Sep 28th, 2008, 12:28pm
 
oh ok. that should work for what im experimenting

good work on jbox btw. this should become a new toy for alot of process'ers =)
Re: BoxWrap2d physics library - seeking feedback
Reply #8 - Oct 24th, 2008, 10:28pm
 
hey!

the library looks really good and it's fun to code with!

is there a way to change the size of an object? (or even better... changing the complete shape).


best, hansi.
Re: BoxWrap2d physics library - seeking feedback
Reply #9 - Dec 25th, 2008, 5:36pm
 
I tryed your boxwrap2d and got an stange error:
i run the example, but only the boxes are displayed. No circles (yes i pressed the mousebutton and the boxes akt like the circles are there)....

I changed to OPENGL, but it does not help..

Where is my mistake?

btw: I use Processing 1.0.1

Source:

http://jbox2d.nfshost.com/processing/examples/SwingingDemo.pde
Re: BoxWrap2d physics library - seeking feedback
Reply #10 - Dec 26th, 2008, 10:46am
 
Ah, funnily I was starting to take a look again at that library, wondering if there is an update on boxwrap2d to follow the latest version of JBox2D.

You are right, I see neither circles nor joints, if I change the formers to rects I can visualize them.
I see the same issue with Processing 0154, not with 0135. Looks like some change in the underlying libraries has broken the wrapper.
Re: BoxWrap2d physics library - seeking feedback
Reply #11 - Dec 26th, 2008, 10:52pm
 
Yup, it appears something has changed inside the P5 core that doesn't interact well with the old .jar I uploaded.  Oddly enough, all I've had to do to reenable drawing is build the library against the new core.jar, and it seems to work.  Strange, since that shouldn't happen with Java, but oh well!  Can't exactly debug it since once I update to the new P5 jar the same exact code works.

In any case, I uploaded a new .zip, which should work, available from the page at http://www.jbox2d.org/processing/

Library cleanup coming soon, btw, with some more docs and tutorials as well as functionality improvements (and maybe a JBox2d update as well)...

@hansi: no, currently Box2d itself does not support changing shapes while simulating, so unfortunately that's probably not going to be possible with this library.
Re: BoxWrap2d physics library - seeking feedback
Reply #12 - Dec 27th, 2008, 10:07am
 
Many thanks for this update (and the coming one!).
I downloaded the new version, and I got an error: org.jbox2d.util package is missing.
Looks like a little packaging error.

I could checkout the project from SVN, and build it. I had to replace the ~1MB core.jar at the root by the 224KB one found in processing-1.0.1/lib. The exported jar is a bit big (379KB) compared to your, but the SwingingDemo works fine once I removed the sizeSet = true; line from the end.

Note: I added .svn/ to the exclude path of data, and **/.svn/* to the exclude path of src.
The export to jar feature of Eclipse is annoying because I have to re-specify what to export each time.
Re: BoxWrap2d physics library - seeking feedback
Reply #13 - Dec 27th, 2008, 10:14pm
 
Ok, thanks PhiLho, I'll see if I can fix up the uploaded version.  As you mentioned, the Eclipse export to jar functionality leaves a lot to be desired if you don't want to export absolutely everything with the jar, so I probably just made a mistake when I was deselecting (the org.jbox2d.util package in particular has a bunch of stuff in it that is not being used, so I may have been overly agressive with the trimming...).

I'll try to put a new version up at some point today.
Re: BoxWrap2d physics library - seeking feedback
Reply #14 - Dec 30th, 2008, 8:57pm
 
Okay, a new .zip is up, let's see if this one does it!  (Works on my computer, then again, so did the last one!)
Pages: 1 2 3