Archived

This topic is now archived and is closed to further replies.

Bouncer

2D rigid body physics

Recommended Posts

Bouncer    145
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]

Share this post


Link to post
Share on other sites
emptyhead    178
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?

Share this post


Link to post
Share on other sites
Bouncer    145
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.

Share this post


Link to post
Share on other sites
emptyhead    178
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]

Share this post


Link to post
Share on other sites
Bouncer    145
>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)

Share this post


Link to post
Share on other sites
emptyhead    178
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?


Share this post


Link to post
Share on other sites
iNsAn1tY    476
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]

Share this post


Link to post
Share on other sites
iNsAn1tY    476
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]

Share this post


Link to post
Share on other sites
zerot    122
impressive display of fast physics

had some fun with it
http://webserv.nhl.nl/~homan000/400blauweballen2.jpg



[edited by - Zerot on May 29, 2003 4:46:38 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by Bouncer
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.





That was a great article...I''m using it in a 3D animation system for Cloth, Hair..and the "Ragdoll" effect..

I''ll have to check this out when I get home from work..

Share this post


Link to post
Share on other sites
blueEbola    464
Wow! That was very impressive.. and strangely fun too
It maintained a steady 45fps on my system, and the physics look reallly nice

Do you plan on releasing the source?

Share this post


Link to post
Share on other sites
BigFootz    122
Bouncer,

I''ve read the articles but I''ve been busy working on other elements of my project/s(sound/music/special effects) and have the basic theory of particle physics (the particles and springs control the mesh etc. springs can be made by.. .)
down and written but not coded

Thee are many ways to go about it and I''m confused how to get it from my head to basic code

I''m using Blitz3D
I''m not sure what steps to take and what order

I just want a simple ragdoll/bouncing etc. engine
I wouldn''t mind sharing my work on it with you if you can help me understand the process of coding it in Blitz3D

I don''t mind doing little tweaks for differant masses cause I already have mapped out how to give a mesh actual material properties (weights are differant for wood and iron etc.) and even internal density changes so I could actually combine differant meshes to make say a hammer with a rubber handle etc. and make it look like it too because the hammer head wood be heavier! All theoretically

It''s just the actual programming of the simple startup code I don''t understand

I want to do it myself but I don''t know where to start
I have all the calcs for torque,mass,forces etc. written down

I guess cause I don''t understand all of C++ and Types yet
So I have to see some Basicy examples

I know I would make use of the bounding spheres/boxes and collision checking and some other stuff but how and where and when?

The articles are all words but nothing a basic coder can figure out the decisive command implementation, order and arrangement woth

I''m sorry for my lengthy letterisms
As you can see I don''t mind typing at all if it get''s me somewhere

Thanks for any help

P.S. It''s quite funny that I can do sound effects,music a 3d engine in 2d,my own audio synth programming and am working on ray casting but I can''t get basic physics coded with Blitz3D

Share this post


Link to post
Share on other sites
oliii    2196
quote:
Original post by BigFootz
I want to do it myself but I don''t know where to start
I have all the calcs for torque,mass,forces etc. written down

I guess cause I don''t understand all of C++ and Types yet
So I have to see some Basicy examples



you should really check out the Jacobsen article. Take it step by step, and you''ll achieve a similar result. C, C++, basic, whatever... It''s not really specific to a language.

It starts of with simple particles, then moves on to links and meshes. Implementing that kind of stuff is really fun, and leaves room for lots of experiments. You can do brakages, springs, woblly masses... It sounds like lots of fun

Share this post


Link to post
Share on other sites
Ilici    862
quote:
Original post by Bouncer
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.



I implemented that recently and it gives great results. I have a 10 particle cloth simulation working and some nice rotating cubes (with uneven distribution of mass) and collision detection + response, but not used yet. Now only if i was not so lazy i could put the collision detection to work.

if anyone is interested in the code tell me and i''ll post it.

Share this post


Link to post
Share on other sites
Bouncer    145
I didn''t know this thread still existed... somebody brought it back to life. As you may notice it''s 6 months old

Okey ... those few demos are no longer online... but new demo is.
The engine has evolved a lot since then... This is a bit old also... but it includes soft bodies... better friction.. it''s faster and more stabile and features 4 different scenes.

www.kotiposti.net/naama/IR3_TEST.zip

Share this post


Link to post
Share on other sites
Wildfire    154
Those soft bodies (flesh-bags) are a bit eerie But I like the effect you get when playing with the right and middle mouse button to attract and repel stuff, nice

Only problem is that the soft bodies ''break'' easily. Maybe a few more springs (that''s what you''re using?) inside them would prevent this.

Share this post


Link to post
Share on other sites
Ilici    862
quote:
Original post by Bouncer
I didn''t know this thread still existed... somebody brought it back to life. As you may notice it''s 6 months old

Okey ... those few demos are no longer online... but new demo is.
The engine has evolved a lot since then... This is a bit old also... but it includes soft bodies... better friction.. it''s faster and more stabile and features 4 different scenes.

www.kotiposti.net/naama/IR3_TEST.zip



Damn that''s SWEET!

Did you put particles in all the vertices of the objects or did you model the particles yourself?

Can we see a cloth simulation? pleaase

Share this post


Link to post
Share on other sites