Skip to main content
GameDev.net gamedev.net
🔒 Locked

falling body example

Started by totenhose Jan 26, 2004 at 4:01 PM 15 replies 2.4k views
Original Post
totenhose
totenhose
Can smb please give a link to some easy example with source where rigid body is falling onto ground. I prefer simple cube with linear and angular movement in 2d or 3d and inelastic collision - like dice simulation. I have searched a lot and those i have found, are too complicated. Articles doesn't help me either, mainly collision parts are too hazy. [edited by - totenhose on January 26, 2004 5:18:58 PM]
Odoacer
Odoacer
You can check out my own rigid-body collision program here. The collision detection however sucks because I'm using bounding boxes for spherical collisions. But the pure elasticity demos (e=.95) show objects falling pretty well.

edit: I also wrote some dumbed-down docs (I made the prog as a physics project). It does a pretty good job of explaining all the physics-related functions though. I can upload 'em if you want (word 2k format).

[edited by - Odoacer on January 26, 2004 5:06:50 PM]
totenhose
totenhose
to odoacer:
can this program simulate a falling and rotating cube too ?
Odoacer
Odoacer
Nope. I haven''t really coded any distinctions between objects of different types (although the objects themselves do store what kind they are). Pretty much the only thing this program can do accurately is simulate gravity (they will even fall the equivalent of 10 m/s) and elasticity. I didn''t have time to incorporate any rotation or anything before I turned it in. Would have been nice though, maybe I''ll work on it.

I''ve done a pretty good job of comparmentalizing the source though so you should be able to look through the physics class and have a fairly good idea of what''s going on and adapt it to your uses.
totenhose
totenhose
to olii:
seems too be perfect, only one file and so discrete. i'm trying to get it work under dev-cpp now...
included exe does not work, even with those dll-s. It sais: "The procedure entry point __glutCreateWindowWithExit could not be located in the dynamic link library glut32.dll"

[edited by - totenhose on January 26, 2004 6:12:08 PM]
dmounty
dmounty
This is a very good article on verlet integration for rigid body physics (including articulated bodies).
oliii
oliii
awww crap. it''s probably when I tried to use a custom glut library.

I''ve got to rebuild my exe, Should have done that a long time ago. but I can''t access my FTP, .... one of those days.

btw, you should not need memwatch. I''m re-building the exe, and cleaning up the messy Vector/quat/matrix libraries.
Everything is better with Metal.
oliii
oliii
yeah, dmounty. I''ve got a demo/tutorial of the stuff coming up at flipcode COTD, if only it didn''t takes age that long to submit COTDs.
Everything is better with Metal.
oliii
oliii
quote:
Original post by jack_1313
I''d love to see that tutorial oliii... when do think it will be released?


it''s available here

although, it''s not ''exactly'' a tutorial, but I took the time to write a document, which explains the main parts of the demo, especially the collision detection parts. The demo is more like Bouncer''s physics game, with soft boies, chains, and rigid bodies. I decided to give it a go and code a similar system. I was surprised how easy it was. Took me the best part of two days. The physics part is better explained by Jakobsen, so I didn''t went lyrical on that part.

I cleaned up the rigid body demo, and it should find its way to my site this morning. I might want to release it as another tutorial Although I''ll have more trouble explaining it properly.

PS : Don''t buy Norton Internet Security 2004. It''s a piece of crap. Even after uninstalls, It is still blocking my popups, hence I can''t FTP to lycos using their webftp service.
Everything is better with Metal.
totenhose
totenhose
To Olii: Now your exe works, and i got it work on dev-cpp too. Nice. Thanks a lot man. You''re in the credits, if i get this game done
oliii
oliii
np. That''s just the tip of the iceberg though. anyway, best of luck
Everything is better with Metal.
totenhose
totenhose
Olii, i have a question:

You have this line:

//----------------------------------------------------------
// Calculate world cordinate inertia matrix
//----------------------------------------------------------
InvInertia = Orientation * BoxInertia.Inverse() * Orientation.Inverse();

But doesn''t this equal to:

InvInertia = BoxInertia.Inverse();

I don''t know matrices very well but it seems to me that
Orientation * Orientation.Inverse() gives nothing (1)
And if i make this replacement, then simulation stays the same.

Tell me if i''m wrong or right.
m_e_my_self
m_e_my_self
quote:
Original post by totenhose
Olii, i have a question:

You have this line:

//----------------------------------------------------------
// Calculate world cordinate inertia matrix
//----------------------------------------------------------
InvInertia = Orientation * BoxInertia.Inverse() * Orientation.Inverse();

But doesn''t this equal to:

InvInertia = BoxInertia.Inverse();

I don''t know matrices very well but it seems to me that
Orientation * Orientation.Inverse() gives nothing (1)
And if i make this replacement, then simulation stays the same.

Tell me if i''m wrong or right.


No, matrixes are not necessarily commutative (think that''s the word), meaning A * B does not necessarily equal B * A. That means that also A * B * A^-1 does not have to equal B (and usually doesn''t)
oliii
oliii
note, that I'' think you can replace the inverse() by transpose(), since the inertia matrices are diagonal, and the orientation matrices are otrhogonal.
Everything is better with Metal.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.