Archive: Rigid body physics...


21st December 2006 00:38 UTC

Rigid body physics...
I made this preset recently to test the practicality of making a physicsy preset... it seems to work fine except for a couple of strange bugs.

1.) After the cube settles a mysterious "wobbling" starts to happen. Despite how it may appear this doesn't come from the collision (like the usual wobbling in most game physics) but from my integrator. I've tried adding dampening to no avail. If I remove the constraints the problem doesn't disappear either. I have a hunch that it is to do with rounding errors somehow but can't work it out.

2.) It doesnt draw anything when TomyLobo tries to watch it.

I get the feeling that I will be able to resolve the wobble by either fixing my integrator, or abandoning it and replacing it... but 2 is just weird since there is no dependency on external files or the like..

If you want to change the starting velocity and spin of the cube I added some variables to apply different velocities to two opposite vertices on the first frame. In the first superscope you can modify these lines to change them:

svx = 2; svy = 0; svz = ivz; // velocity for the first vertex so that it can spin
tvx = -2; tvy = 1; tvz = ivz; // velocity for the second vertex so that it can tumble

It is possible to roll the cube along the ground by making sure that the velocities don't balance in x and z.

If anyone is interested this physics model can be quite easily extended to any triangular model with a little preprocessing to determine some constraints. Its just a shame that there is an instability for the moment...

If anyone can shed any light on the bugs it would be most appreciated. :)

Please excuse the ugliness of the cube, it doesn't even backface cull!


21st December 2006 10:27 UTC

I stayed up quite late working on this last night... I managed to remove the instability from the integrator, it is now stable if I remove the constraints, I also added some different friction for the ground and some simple deformability/elasticity for the cube. It is still unstable but might be okay with a little work, or when applied to a situation where nothing comes to rest (imagine the cube rolling down a 45-degree incline).

Anyway, I was going to post it up this morning but I forgot to update the file on my ftp with the latest version. I also forgot that I can't access ftp at work.

I would post the link but I don't particularly want people browsing the unsecure root of my ftp...

Anyway, I am disappointed that there has been no feedback yet... being the first new technical thing in AVS for quite a while and all.

Now... to make a hypercube with physics... and project it onto a 3-sphere...


21st December 2006 17:18 UTC

here it is. i changed the starting conditions so it looks cooler too... :)


22nd December 2006 00:24 UTC

Originally posted by jheriko
Now... to make a hypercube with physics... and project it onto a 3-sphere...
<droool>

I'll check out the preset latter tonight.

22nd December 2006 00:55 UTC

Now it is so very nearly stable, you have to wait a good few seconds for it to flip out. This is good enough for a preset in several ways now. As long as the cube keeps moving there is no instability. I might make a version tomorrow with a cube rolling down a slope.. but now its getting quite late here.

Enjoy.


23rd December 2006 03:36 UTC

wOw, pretty cool!


23rd December 2006 20:11 UTC

Here you go
I looked into the code and found what was causing the warping.

I've tested the preset like 100 times and waited without closing avs window and the cube remains stable for about 1-5 mins. i'll let you take it from there.
also as you know i'm not very Inclined in math so please show some mercy if the correction is not what you wanted.
Chow.


23rd December 2006 21:28 UTC

you broke the framerate independence.. and added some random shit. (t=sin(oldt))

effectively you broke my timer which means that it uses a constant time step, which makes my integration much more stable.

thanks but no thanks.


24th December 2006 03:21 UTC

2.) It doesnt draw anything when TomyLobo tries to watch it.
Wow jheriko, you were trying to impress us with the 'physics' part of the preset, but this selective ignore of forum members has the be the real star of your preset, not to mention where you hid that code!

Seriously though, would it help to perhaps change the 'physical' perspective from one of mechanics to maybe one of electronics? An integrator is after an analogue computer, and in its most basic form, a capacitor. Would this make the maths easier and/or more compreshensible/discernable? Most likely a dead end, but throwing it in for grins.

26th December 2006 19:01 UTC

srsly... i really outdid myself by making not work for only one person :p

the integrator is a bit flaky, but its fast. i might gut it and replace it with rk4, but it is stable enough for a preset for now. at worst i can at least turn it off should an object come to rest, and turn it on again when it has to move again... before it was so unstable that the cube never became slow enough to allow me to effectively cut off the small values.


27th December 2006 02:42 UTC

Cube_1 doesnt work for me as you already know :)


28th December 2006 12:49 UTC

I forgot actually. So its two people then.

Its still quite amazing. I've never had this kind of 'selective functionality' from avs presets before.. it boggles the mind how it can happen. The only reasonable explanation i can think of is that you have a different triangle/avstrans APE to mine.

This preset uses no components or code tricks that haven't already been used. All the physics stuff is just AVStrans code working in the megabuf.