bats

really hung over this morning after our company xmas party last night…. although strangely its making me productive and somehow able to write this post, most likely the residual of frenzy impulses from a very busy week involving the usual flash sites and a very cool interactive installation of flocking bats.

the installation was for our xmas party themed gotham so i thought id put my flocking code to some good use and apply it to some winged rodents… no, to be fair i really like bats… have masses of them flocking over my house each evening to their nightly feeding spots and always enjoy the spectacle.


bats_01 from lukasz on Vimeo.

back to code speak, getting the bats to orientate towards the direction of flight was a tricky exercise in opengl.
in theory all i wanted to do was to rotate the bat around the Y axis (left or right) and around the Z axis (up or down)… easy enough, but that’s not the way it works in opengl. if you rotate the coordinate space around one axis, then all the other axis are also rotated.
with help from flashmonkey the solution was found in using a rotation matrix and a few other vector calculations.
there are probably many ways of arriving at the same result but this is what worked for us.

here is the source
also will need toxi’s geomutils library if you haven’t got it already.


About this entry