2D Physics System

I’ve ported and tidied some code from GDC 2006 for a 2D physics engine (all kudos to Erin Catto) - I decided I’ll probably want a reliable 2D physics engine for future gaming projects. At the moment it only handles boxes but I’m hopefully going to extend it to include circles next and refactor the collision stuff along the way.

Webstart Demo Box Here

some screenshots:

http://www.cokeandcode.com/phys2d/screenshots/d1.png
http://www.cokeandcode.com/phys2d/screenshots/d2.png
http://www.cokeandcode.com/phys2d/screenshots/d3.png

Kev

Really cool. Good work :slight_smile:

When will a Xith3D binding be available ? :slight_smile:

Never really understoon binding a rendering layer to a physics layer in a formal manner - isn’t that the job of the game engine? :slight_smile:

Kev

Yes, you’re absolutely right. Anyway that’s why I stopped using ODEJava’s Xith3D bindings and did my own linking : much clearer.

I was just kidding and wanting to know if you’re planning to develop some more with Xith3D.

Right now it seems my development system hardware is so rubbish it prohibits me from using Java3D, Xith or JME (all of which I’ve wanted to use just recently - hence the posts on the forums there). However, not being able to get basic terrain rendering at > 20 fps (due to my crap hardware, rather then the libraries in question) makes it less than endearing.

I think I’m going to be sticking to writing small extremely optimised games for now.

Kev

It works very well…
I also ported the code, but the demos of the stacks and the pyramid always exploded.
Did you use a bigger drag/friction to make the simulation more stable??

Rafael.-

Ah, if I knew someone else had already ported it - I would have just used that one :slight_smile:

Re: Drag/Friction - no, it’s just as it was before - though the demos arn’t identical and I haven’t tried a stack yet.

One thing I do notice is it seems the simulation isn’t very reliable running at a step of anything other than 1/60.0f - I’ll probably make this the default or something in this version.

Kev

Semi-offtopic :

I catched this sentence : “Ah, if I knew someone else had already ported it - I would have just used that one :)”

That happens really often and… well making a java.net project doesn’t give so much visibility.

If some are interested, I am ready to make a site containing a repository of useful libs, for 3D (JOGL LWJGL Xith3D Java3D jME),
for physics (JOODE, your physic implementation, someone else which I can’t remember the name unfortunately), for some other things…

The basic idea here is to share your libs to avoid some work for others… Hmm maybe I’m not clear here anyway ask questions I’ll answer

1/60 secs…
That may be, I have it running at variable timestep.


//Pseudo-Java
while(running){
  dt = now -last;
  update(dt);
  render();
  last = now;
}

I will try with fixed timestep.

Rafael.-

Variable time-step is the nightmare of every physic programmer.

[quote="<MagicSpark.org [ BlueSky ]>,post:11,topic:28007"]
Variable time-step is the nightmare of every physic programmer.
[/quote]
And network programmer.

And network programmer.
[/quote]
Sure.

Are you planning on releasing source and expanding the Box2D demo into a more general physics system? If so, should I stop and wait for your implementation?

Kev

WOW, that’s not physics, its magic!!! Flawless from the look of the demos! 8)

I haven’t read the slides & code yet, but I was wondering, can it do 2D polygons? I’ve been hot on the trail for a way of doing physics for my 2D tank game. I’d love to be able to use these methods you’ve both employed.

Thanks,
Keith

EDIT: I read the code, but without knowing C I’m not comfortable with it. From the slides it looks like doing the impulse method for polygons wouldn’t be that hard so long as overlapping sections can be computed, which can be done. If either of you would be so kind to share your java-ported versions I’d be happy to try to tweak it to work with 2D polygons.

I love those demo. seems to works perfectly.

Yep, that’s really amazing. What’s the status on the source code? Will we get to see it?

:slight_smile:

I was hoping to tidy the source code up a bit (add some documentation) before releasing. I was also going to try to refactor the collision code a bit to allow for circles before making it public.

If you’re happy to take a look at the current state I could make it available sooner (maybe some repository somewhere).

However, I’d rather not step on anyone’s toes - if rdcarvallo is already working on some open implementation I don’t want to break that.

Kev

I’ve added a stacking demo - seems stable even with slightly variable time steps (though I’ve now fixed it here to be 1/60.0f always).

Kev

Hi

vecmath jar is missing from the webstart dir so it all brokey now :confused:

Endolf