Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 4
  ignore  |  Print  
  2D Physics System  (Read 24144 times)
0 Members and 1 Guest are viewing this topic.
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Posted 2006-07-24 17: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

Senior Member


Medals: 2


Fir Tree Master


« Reply #1 - Posted 2006-07-24 18:28:01 »

Really cool. Good work Smiley
Offline Amos Wenger

Senior Member




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


« Reply #2 - Posted 2006-07-24 18: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2006-07-24 20: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

Senior Member




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


« Reply #4 - Posted 2006-07-25 17: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2006-07-25 17: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

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #6 - Posted 2006-07-25 20: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2006-07-25 21: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

Senior Member




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


« Reply #8 - Posted 2006-07-25 21: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

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #9 - Posted 2006-07-25 21: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




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


« Reply #10 - Posted 2006-07-25 21: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


Medals: 51
Projects: 11


Monkey for a head


« Reply #11 - Posted 2006-07-25 21: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

Senior Member




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


« Reply #12 - Posted 2006-07-25 21: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #13 - Posted 2006-07-25 23: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
« Reply #14 - Posted 2006-07-26 01: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
« Reply #15 - Posted 2006-07-26 13:01:01 »

I love those demo. seems to works perfectly.

Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #16 - Posted 2006-07-26 14:36:40 »

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

 Smiley
Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #17 - Posted 2006-07-26 18: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #18 - Posted 2006-07-27 08: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

JGO Knight


Medals: 7
Projects: 1


Current project release date: sometime in 3003


« Reply #19 - Posted 2006-07-27 08:56:01 »

Hi

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

Endolf

Offline CommanderKeith
« Reply #20 - Posted 2006-07-27 09:12:15 »

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

Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #21 - Posted 2006-07-27 11: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #22 - Posted 2006-07-27 15:55:48 »

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

Kev

Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #23 - Posted 2006-07-27 17: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #24 - Posted 2006-07-28 09: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

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #25 - Posted 2006-07-29 10: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

Senior Member





« Reply #26 - Posted 2006-07-29 18:16:16 »

Go show!

Shawn Kendall
Cosmic Interactive, LLC
http://www.facebook.com/BermudaDash
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #27 - Posted 2006-07-29 21:58:54 »

Waaa neato! Smiley

弾幕 ☆ @mahonnaiseblog
Offline CommanderKeith
« Reply #28 - Posted 2006-07-30 04:40:23 »

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

Offline Death33284

Junior Member





« Reply #29 - Posted 2006-07-30 08: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
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (19 views)
2014-04-15 18:08:23

BurntPizza (15 views)
2014-04-15 03:46:01

UprightPath (28 views)
2014-04-14 17:39:50

UprightPath (13 views)
2014-04-14 17:35:47

Porlus (29 views)
2014-04-14 15:48:38

tom_mai78101 (54 views)
2014-04-10 04:04:31

BurntPizza (111 views)
2014-04-08 23:06:04

tom_mai78101 (212 views)
2014-04-05 13:34:39

trollwarrior1 (181 views)
2014-04-04 12:06:45

CJLetsGame (187 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!