Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 4
  Print  
  2D Physics System  (Read 16813 times)
0 Members and 3 Guests are viewing this topic.
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« on: 2006-07-24 11:53:13 »

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

Offline Evil-Devil

Full Member
**

Posts: 244
Medals: 2


Fir Tree Master


« Reply #1 on: 2006-07-24 12:28:01 »

Really cool. Good work Smiley
Offline Amos Wenger

JGO Kernel
*****

Posts: 1750


Everything's possible, but not everything's fun...


« Reply #2 on: 2006-07-24 12:54:17 »

When will a Xith3D binding be available ?  Smiley

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Games published by our own members! Go get 'em!
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #3 on: 2006-07-24 14:24:54 »

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

Kev

Offline Amos Wenger

JGO Kernel
*****

Posts: 1750


Everything's possible, but not everything's fun...


« Reply #4 on: 2006-07-25 11:18:57 »

Never really understoon binding a rendering layer to a physics layer in a formal manner - isn't that the job of the game engine? Smiley
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.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #5 on: 2006-07-25 11:38:58 »

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

Offline rdcarvallo

Sr. Member
**

Posts: 300


2D Java games forever!


« Reply #6 on: 2006-07-25 14:54:32 »

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.-
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #7 on: 2006-07-25 15:01:57 »

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

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

Offline Amos Wenger

JGO Kernel
*****

Posts: 1750


Everything's possible, but not everything's fun...


« Reply #8 on: 2006-07-25 15:13:18 »

Semi-offtopic :

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

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

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline rdcarvallo

Sr. Member
**

Posts: 300


2D Java games forever!


« Reply #9 on: 2006-07-25 15:19:20 »

1/60 secs...
  That may be, I have it running at variable timestep.
1  
2  
3  
4  
5  
6  
7  
//Pseudo-Java
while(running){
  dt = now -last;
  update(dt);
  render();
  last = now;
}

I will try  with fixed timestep.

   Rafael.-
Games published by our own members! Go get 'em!
Offline Amos Wenger

JGO Kernel
*****

Posts: 1750


Everything's possible, but not everything's fun...


« Reply #10 on: 2006-07-25 15:32:44 »

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

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Orangy Tang

JGO Kernel
*****

Posts: 2959
Medals: 37


Monkey for a head


« Reply #11 on: 2006-07-25 15:36:21 »

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

And network programmer.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Amos Wenger

JGO Kernel
*****

Posts: 1750


Everything's possible, but not everything's fun...


« Reply #12 on: 2006-07-25 15:43:50 »

Sure.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #13 on: 2006-07-25 17:13:37 »

Quote
I will try  with fixed timestep.

   Rafael.-

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

Offline CommanderKeith

JGO Wizard
****

Posts: 1455
Medals: 9



« Reply #14 on: 2006-07-25 19:58:10 »

WOW, that's not physics, its magic!!!!  Flawless from the look of the demos!  Cool

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.

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.

Offline DzzD

JGO Kernel
*****

Posts: 2134
Medals: 16



« Reply #15 on: 2006-07-26 07:01:01 »

I love those demo. seems to works perfectly.

Offline nonnus29

JGO Ninja
***

Posts: 687


Giving Java a second chance after ludumdare fiasco


« Reply #16 on: 2006-07-26 08:36:40 »

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

 Smiley
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #17 on: 2006-07-26 12:35:34 »

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

Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #18 on: 2006-07-27 02:11:25 »

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

Offline endolf
« League of Dukes »

JGO Kernel
*****

Posts: 1592
Medals: 2


Current project release date: sometime in 3003


« Reply #19 on: 2006-07-27 02:56:01 »

Hi

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

Endolf

Offline CommanderKeith

JGO Wizard
****

Posts: 1455
Medals: 9



« Reply #20 on: 2006-07-27 03:12:15 »

Not for me, it works sweet.  I love the stack with the shooting boxes... amazing.

Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #21 on: 2006-07-27 05:18:01 »

Hm. Put the +0.05f thing back in. Right now you get *massive* over/understeer effects if it ran flat (yield pretty much 0) for a while. (So, there was a reason that I put it there... haha... my bad Smiley)

And it also might knock out into the other direction as soon as yield hits Integer.MAX_VALUE. Heh. That might be a problem in 10 years Wink

弾幕 ☆ @mahonnaiseblog
Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #22 on: 2006-07-27 09:55:48 »

There is no dependency on vecmath.jar any more - you've got a caching issue somewhere.

Kev

Offline rdcarvallo

Sr. Member
**

Posts: 300


2D Java games forever!


« Reply #23 on: 2006-07-27 11:30:01 »

Kev,
  Your stacking boxes works great!  I looked into my code and It was
using fixed timesteps, so I have something wrong.
  Just continue coding. I did this only to play a little, and since it didn't  work
well, I didn't continue.

   Rafael.-

Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #24 on: 2006-07-28 03:55:12 »

Ok, the source is currently available here:

http://www.cokeandcode.com/phys2d/source/

And the demo is still at

http://www.cokeandcode.com/phys2d/phys2d.jnlp

It now shows contact points as the bodies collide - I think this will be useful for checking collision shape implementations.

I've just refactored out the collision routines so I can add circles next. Please bare in mind it's very much a work in progress and I'm still trying to get my head round the maths involved. I'm still developing so it might be tricky if anyone wants to start adding stuff right now - if theres any real interest I'll start some java.net or code.google.com (coogle?) projects to hold the source.

The source thats available right now is just a snap shot of what I'm working on - so there are still plenty of holes Smiley

Right now thought I'm just enjoying playing with the demo way too much.

Kev

PS. I've tried to stick 1.4 compatible for personal project reasons.

Offline kevglass
« League of Dukes »

JGO Kernel
*****

Posts: 5214
Medals: 49


Mentally unstable, best avoided.


« Reply #25 on: 2006-07-29 04:36:53 »

Just added circles to the mix - seems the collision refactoring works ok. The demo has been updated with a few scenarions including circles rolling around.

I've been focusing on making it work rather than fast/light. There is work that needs to be done pulling the maths apart and making it optimal for speed and garbage. There's also some stuff that would be nice to do for detecting static bodies and ignoring them.

Kev

Offline shawnkendall

JGO Ninja
***

Posts: 691
Medals: 2


Apathy Error: Don't bother striking any key.


« Reply #26 on: 2006-07-29 12:16:16 »

Go show!

Shawn Kendall
Full Sail Real World Education
Immediate Mode Interactive, LLC
<A HREF="http://cosmic-game-engine.blogspot.com/">Cosmic Game Engine Dev Journal</a>
Offline oNyx

JGO Kernel
*****

Posts: 2943
Medals: 5


pixels! :x


« Reply #27 on: 2006-07-29 15:58:54 »

Waaa neato! Smiley

弾幕 ☆ @mahonnaiseblog
Offline CommanderKeith

JGO Wizard
****

Posts: 1455
Medals: 9



« Reply #28 on: 2006-07-29 22:40:23 »

& thanks for the source !  So when is a billiards game coming out!?

Offline Death33284

Jr. Member
**

Posts: 70



« Reply #29 on: 2006-07-30 02:09:46 »

Wow, this looks great kev   Grin

Can we use this in our own games as long as we give you credit?
Pages: [1] 2 3 4
  Print  
 
 
Jump to:  


Add your game by posting it in the showcase section.

The first screenshot will be displayed as a thumbnail.

Danny02 2012-05-21 17:10:34

Danny02 2012-05-21 17:07:10

Danny02 2012-05-21 16:56:12

davedes 2012-05-21 13:59:23

obsidian_golem 2012-05-20 20:28:41

darkjava55 2012-05-12 16:14:40

Ultroman 2012-05-12 09:36:05

Ultroman 2012-05-11 22:49:53

Ultroman 2012-05-11 22:20:01

Ultroman 2012-05-11 22:17:34
Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.236 seconds with 19 queries.