POV-Ray : Newsgroups : povray.binaries.animations : Re: Just a little rythmic doodle ( 916 kbbu ) : Re: Just a little rythmic doodle ( 916 kbbu ) Server Time
19 Jul 2024 09:29:09 EDT (-0400)
  Re: Just a little rythmic doodle ( 916 kbbu )  
From: Rune
Date: 23 Feb 2003 18:12:42
Message: <3e59556a$1@news.povray.org>
Skip Talbot wrote:
> Very cool.  How is it done?

Thanks! :)

Well, for each "hair" there is an array of points. Each hair will
attempt to become straight. This is done by making each point go towards
the line defined by the two previous points in the array. Furthermore,
each point is forced to be a specific distance from the previous point
in the array. That's all really. I didn't even bother to implement
things like inertia, and certainly not collision detection.

This is the core of the code:

#declare H = 0;
#while (H<Hairs)
   #declare S = 2;
   #while (S<Segments)
      #declare Goal = (2*A[H][S-1]-A[H][S-2]);
      #declare A[H][S] = A[H][S]*(1-Stiffness)+Goal*Stiffness;
      #declare A[H][S] =
A[H][S-1]+vnormalize(A[H][S]-A[H][S-1])*SegmentLength;
      #declare S = S+1;
   #end
   #declare H = H+1;
#end

Each hair is then moved around by controlling the locations of the first
and second point in the array.

Oh, and then I made some rhythmic-like functions to control the movement
and the colors etc. :)  (Not really functions, just #declared variables
dependent on the frame_number variable.)

Rune
--
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com (updated Oct 19)
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.