2D rigid body physics

Started by
33 comments, last by Bouncer 20 years, 4 months ago
Here is my 2D rb physics engine I've been working on... Now I'm just kind of testing it to see is it fast enough for game use... [EDIT] Somebody brought this thread back to life the old links were dead... so here's an updated demo www.kotiposti.net/naama/IR3_TEST.zip Milk is for babies [edited by - bouncer on May 29, 2003 4:14:29 AM] [edited by - Bouncer on December 5, 2003 10:38:16 PM]
Milk is for babies
Advertisement
My God! Very nice work!
I ran the stress test, and i must admit that i am very impressed! The simulation is very stable, and doesn''t slow down much when the number of objects increase.

Btw, can you give any hints about what methods you are using?
Is your method possible to expand to 3d?

:wq!
WOW! This rules so much!
One of those things I can play around with for hours

Well, it''s freakin fast, and the physics rule. Dunno what else to say.
Makes me want to play the game you make with it

My Wonderful Web Site (C++ SDL OpenGL Game Programming)

I am a signature virus. Please add me to your signature so that I may multiply.
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
Simulation is based on Thomas Jakobbsen''s article "Advanced character physics". Objects are made from constrained particles and a mesh is attached to them. Verlet integration is used. Collision detection for now is sphere to sphere and sphere to line.

This is basicly the same kind of system as used in Hitman. So this kind of system is usable in 3D also.
Milk is for babies
Did you have to do a lot of "kludges" or hacks to get it this stable, i've read the postmortem of hitman, and they talked about how they had to make lots of tweaks and hacks to get it looking realistic.
Have you tried to stop the spherical objects to stop oscillating with friction or something?
What type of game are you planning to use it for?

Im guessing that you're not using bruteforce O(n^2) collision detection.. so what kind of algorithm do you use?

(sorry for all the questions... ;-) )

[edited by - emptyhead on May 29, 2003 7:11:28 AM]
:wq!
Amazing!! Great work!

++Sailor Elevator++

[edited by - Sailor Elevator on May 29, 2003 7:12:57 AM]
"Everytime you plan to go out and drink - DON''T!"
>Did you have to do a lot of "kludges" or hacks to get it this ;>stable, i''ve read the postmortem of hitman, and they talked >about how they had to make lots of tweaks and hacks to get it >looking realistic.

- not much hacks... but there are some problems with verlet as you propably know. Friction is one of them... which I got working pretty nice with some hacking. Elasticity is more difficult issue.. I mean controlling bouncing. If you want very realistic physics then this system is not very good. But for my purpose I just need fast and good looking system. The stability with verlet is very good... with enough iterations you never get any twitching or shaking with objects... they behave very nicely.


>Have you tried to stop the spherical objects to stop oscillating >with friction or something?

The oscillation is there for purpose... it just makes them look nicer... because the balls don''t actually roll because they are single particles.


>What type of game are you planning to use it for?

I''m using it for a very cool 2D multiplayer "deathmatch" game (side view)... not a lot can be said because I''m still working on the engine.


Im guessing that you''re not using bruteforce O(n^2) collision detection.. so what kind of algorithm do you use?

Sorted bounding boxes and sweep''n prune(modified even faster)

Milk is for babies
You''re using a fixed timestep, and interpolating between positions for every rendered frame, right? Does that mean that you''ll have to actually store three positions:
P(t), P(t+1), P(t+2)
and use P(t) and P(t+1) to interpolate and render, and P(t+2) for the result of the "next" physics update... Or is there some clever way to avoid it, without calculating everything at once?


:wq!
Truly, truly amazing. I got about half a screen of objects, turned off gravity, blasted them about with the big wheel, then turned gravity back on. The effect of the big wheel coming back down and smashing into the smaller objects was awesome.

I have to say that I think the system would be OK for real-time apps. I ran it on a college machine (I'm supposed to be revising ), and, although it's a low-spec machine, it still ran at 40 fps with half a screen of objects. I expected it to slow down big time when I did the above-described simulation, but to my suprise, the framerate only dropped by 1 fps. Excellent work, and I'm going to look out for that article you mentioned...


Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]

[edited by - iNsAn1tY on May 29, 2003 10:20:06 AM]
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Y'know, thinking about it, your 2D physics system there would actually make a rather impressive screensaver. Perhaps if you half-filled the screen with objects, programmed the big wheel to move around randomly (maybe bounce off the sides of the screen, or something), and turned gravity on and off at random intervals? Something to put on instead of SETI for a while


Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]

[edited by - iNsAn1tY on May 29, 2003 11:37:16 AM]
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

This topic is closed to new replies.

Advertisement