Tech Notes For The "Wave" Animation
An explanation of the logic used to create waving tentacles and tails.Moving worlds
As I ported my earlier VRML1 code, I wanted to use VRML 2.0 animations right-away. So I added the 'tilde' command (~) to allow animations to be inserted in the Lsystem production string. Soon after I was able to get any part of a model to spin, breath, bounce or do any kind of interpolator based transform. But when I came to code the wave handler, thinking of smoothly flowing tentacles or antennae, interpolators wouldn't do the job anymore - I needed a little vrmlScript.
Do the trig for me
I misassessed the problem believing that a simple cosine function and clever routing would do the magic, but, in respect for sensible minds I will not describe here the erratic behaviour of my very first digital tentacles.
The truth is elswere
Not so long ago, I was entertaining Dan, one of our architect/designer neighbors at Atelier Coup, with a spherical trigonometry problem (how do you build a star with n branches in space), when he suggested me to consider an object/behaviour oriented approach. It didn't solve my problem at that time but the idea came back to help me now.
How does a tentacle behave ? We are talking here of a chain of segments, each of which makes an angle with its predecessor so that the whole thing moves in a natural way. How does one segment knows which angle it should have to make those beautiful arabesques ? How does a segment tell the next segment that some motion is occuring ?
My life on the tentacle
After waving around some network cables with Anthony from Thoughtworks, the answer became clear : one segment doesnt care, he doesnt even know he is taking part in an aesthetic exercise. He's just having an other day, followings its own simple life.
To start I assumed two simple behaviours: 1) segments don't like to be bent. They react (with a delay) to align themselves with their predecessor. 2) And when you move one, the next one moves the other way to compensate keeping the rest of the chain unchanged and aligned.
So we have a chain of segements S0, S1, S2... driven by the following rules :
- When one segment is moved of an angle a, the next segment moves in the other direction of 2a, and the next one moves again of a. The sum of the angular changes is null (a-2a+a=0).
- This reaction occurs with a delay (one iteration in the wave process). When a segment is appended with its predecessor, it is moved back by half of it's angle; involving changes in the two next segments as per the previous rule.
Only the first segment moves. The others adjust themselves to the change in a chain reaction. No more complex maths. Additions and divisions. The resulting vrmlscript can be seen in action with the sperm or the octopus. It actually support up to 20 segments (or LSystem iterations) and makes fascinating life like animations.
In that problem, complex behaviour is the sum of simple ones applied over time. The rules can be easily changed to create other types of tentacules, and the addition of some chaos would certainly add even more realism.
Patrick Murris : patmurris@montreal.com
Montreal, May 26, 1997