 |
Physics Laws in Swing Applications
Posted by gfx on September 27, 2005 at 04:09 PM | Comments (8)
I just finished (well almost) a Swing demo using real world physics to animate a drag and drop gesture. You can try the demo or read more about its implementation. If you're very curious you can also read the source code. Finally, here are two screenshots from the demo:
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
When you drop the icon and try to click mouse button, while icon still bounces you get nasty trembling effect.
I've tried to enter that on jroller, but has no success.
Posted by: whizzy on September 28, 2005 at 05:14 AM
-
Hi Romain,
I don't think you use real world phisics per se, since the mass of an object doesn't affect the fall speed...
Cheers.
Posted by: mgrev on September 28, 2005 at 08:32 AM
-
Yes I do. Only, as I said, I do not use gravity but a damping oscillator. Just imagine the object is tied to a spring. A quite simple equation gives you not only the falling effect but also the bouncing one. You don't need to be very precise to get an interesting effect.
whizzy: I can't reproduce the bug you're describing but this is just a demo, I don't pretend it to be bug free :))
Posted by: gfx on September 28, 2005 at 09:22 AM
-
Sorry, my bad, I didn't read the article. I just assumed that gravity was used.
Posted by: mgrev on September 28, 2005 at 12:12 PM
-
To mgrev:
The fall speed is not depended from the mass of object. v = sqrt(2gh)
where g is gravitation acceleration (about 9.8 ) and h is height of falling
Posted by: vladyush on September 29, 2005 at 12:59 PM
-
To vladyush: I know and that' was my initial concern...
Posted by: mgrev on September 29, 2005 at 01:24 PM
-
v = sqrt(2gh) obviously only applies if gravity is being used, which he says it does not.
however, for a mass/spring system, the mass of the object does affect it the fall speed.. the period goes as sqrt(m/k) where k is the spring constant... the downside of this model is that the ball will spend the same amount of time in the air after each bounce! Not very physically realistic. But it still looks cool.
Posted by: kanato on October 31, 2005 at 11:30 PM
-
open source?
Posted by: swv on July 03, 2007 at 01:34 PM
|