POV-Ray : Newsgroups : povray.advanced-users : Spline question - using 3.1 and CC's macro Server Time
1 Nov 2024 19:15:11 EDT (-0400)
  Spline question - using 3.1 and CC's macro (Message 1 to 2 of 2)  
From: R L C
Subject: Spline question - using 3.1 and CC's macro
Date: 14 Nov 2001 16:38:15
Message: <3ao5vt4d9kcsdk2ug0lsrgvdbq2sffl8vm@4ax.com>
Hi all,

I am trying to animate a mixed particle flow down a channel, with
different particles separating at one point and moving down different
channels.

I am sure this can be done another way, but for now I am trying it
with splines, specifically Chris Colefax' excellent splines macro. I
have designed several (9) splines describing paths down the channels.

Since I want to show particles continually flowing down the channels,
I want multiple particles on one spline, following one another. 

Can I do this using the spline macro? Can I assign some sort of spline
clock to a particular particle? 

I thought about using #while statements to start sets of particles,
but even that is a little hokey.

Any thought? Suggestions? ready-made code (grin)?

Thanks for the help.

Lloyd


Post a reply to this message

From: Chris Colefax
Subject: Re: Spline question - using 3.1 and CC's macro
Date: 18 Nov 2001 05:32:48
Message: <3bf78e50@news.povray.org>
R L C <the### [at] hotmailcom> wrote:
> I am trying to animate a mixed particle flow down a channel, with
> different particles separating at one point and moving down different
> channels.
>
> I am sure this can be done another way, but for now I am trying it
> with splines, specifically Chris Colefax' excellent splines macro. I
> have designed several (9) splines describing paths down the channels.
>
> Since I want to show particles continually flowing down the channels,
> I want multiple particles on one spline, following one another.
>
> Can I do this using the spline macro? Can I assign some sort of spline
> clock to a particular particle?
>
> I thought about using #while statements to start sets of particles,
> but even that is a little hokey.
>
> Any thought? Suggestions? ready-made code (grin)?

There are a couple of options: you can indeed assign a clock value to a
particle using the animate_by_spline macro with the spline_clock option:

    object {Particle animate_by_spline(Spline1, spline_clock(clock))}

To create more particles, though, you would need to write out each with a
displaced clock value (e.g. spline_clock(clock + 0.01), spline_clock(clock +
0.02), for as many particles and splines as you need!).  As you can see,
then, while loops might not be so hokey at all.  Probably the quickest
parsing option would be to use the spline_value function in the loop, again
using displaced clock values:

#declare R1 = seed(0);
blob {threshold 0.9
    #declare C = 0; #while (C < 100)
        #declare SplineClock = C/100 + clock;
        sphere {spline_value(Spline1, SplineClock), .02 + rand(R1)*.1, 1
            pigment {rgb <1, 0, 0>}}
        sphere {spline_value(Spline2, SplineClock), .02 + rand(R1)*.1, 1
             pigment {rgb <1, 1, 0>}}
        [extra splines]
         }
    #declare C = C + 1; #end
    }

This places particles with random sizes along the length of each spline
(from 0 to 1 along the spline's clock distance).  Each subsequent frame,
however, uses a displaced spline clock value (the + clock above) - so at
clock = 0 you evaluate the spline from 0 to 1, at clock = 0.1 you evaluate
the spline from 0.1 to 1.1, and at clock = 1 you go from spline clock = 1 to
2.  Each spline is limited to a clock range of 0 to 1, but the macros
automatically wraps around spline clock values outside this range, so you
can use code like above to create a seamless flow of particles.


Post a reply to this message

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