
Bouncy Ball

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
F(y) = -ky
where k is spring stiffness
F is the force restoring to original size, proportional to y, there y is(assumably) compression force.
AKA variant of Hooke`s law
Hooke`s
F=kd
where
k is constant
d is distance from orig length
Bugle4d
Cédric
1) I calculate the force exerted on the surface (because the ball might not hit it dead-on, of course). The force would be... |velocity| cos (angle between -(surface normal) and ball direction).
So, if V is the velocity vector of the ball, and N is the surface normal, the force is V.N * |N|. And of course N is normalized, so it''s just V.N. Wow, cool.

2) Uh. F is the force I got in step one, and k is my ''magic number'' for the squishiness of the ball. OK, so that gives me the height the ball should squish to?
Am I right so far? If so, how do I make the ball squish over a number of frames? Presumably, the faster it''s moving, the quicker it squishes; and the faster it''s moving, the more it squishes; so would it always take a fixed amount of time to squish?
Thanks so far...

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
I''m not a physics major, but I think the ball will also lose some of its kinetic energy in the stretching/squashing, and so won''t bounce as high (think of a deflated basketball). If this is not the effect you want, maybe physical modelling is not the way to go in your case.

TerranFury: that may be so, but this is ''cartoony'' physical modelling - the whole ''body moves away very fast but eyes stay for a second'' sort of realm.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Cédric

Treat the ball as either a) a set of surface patches connected by springs; or, b) a set of solid (but not rigid) sub-volumes that transmit forces throughout the ball.
If you''d like further explanation of these methods, just holler.
Cheers,
Timkin
quote:
Original post by Timkin
There is an alternative approach to this problem and I seem to recall posting something along these lines for a thread a few months ago... pity the search function is down.
Treat the ball as either a) a set of surface patches connected by springs; or, b) a set of solid (but not rigid) sub-volumes that transmit forces throughout the ball.
If you''d like further explanation of these methods, just holler.
Thank you (and everyone else), but I think I''ve got something that looks right, at least.
The sub-volumes thing, that''s the idea of splitting the ball up longitudinally, isn''t it? The problem is that when I''m working with a straightforward quad (texture-mapped 2d sprite), that''s not so easy to do; unless, of course, I work with a number of quads, in which case my framerate drops.
TerranFury, cedricl: I''ve got the ball stretching vertically with speed, and it looks ok. At the top of the trajectory, it looks normal, but when moving at a high speed either up or down, it''s stretched.
In case anyone is interested as to how I did it: you don''t really want to know, as most of it came out to be just tweaking numbers. I figured that I only need the ball to actively deform when it has a bottom-edge collision with something (the rest of the time it just passively deforms, based on the vertical velocity as already mentioned). So treating bottom-edge as a special case helped things massively. Other than that, it was just a hodgepodge application of all the things people have been telling me in here (especially the hooke''s law stuff).
Thanks, people.

Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse