POV-Ray : Newsgroups : povray.animations : scripting troubles Server Time
28 Jul 2024 14:28:09 EDT (-0400)
  scripting troubles (Message 1 to 2 of 2)  
From: rsibbald
Subject: scripting troubles
Date: 20 Jun 2000 13:47:32
Message: <394FAF92.AEF20A32@julian.uwo.ca>
Sorry, but the problem is not easily described without the .pov
file which is attached.

I would like to have multiple (eventually >30) cells following the
spline pathway.  I need them to move independently of each other
(ie. not rotate together).  I would also like to randomly have them
within 2-5 units of the spline path instead of having all of them on the

exact same path.  I'm close, yet still having trouble.  Spacing between
the cells is also a major concern.  They are all bunching up a little
too
much.
       Any help would be much appreciated.  I am new to povray yet
am amazed at how much help I have found thus far.  So thanks, in
advance.

Rob


Post a reply to this message


Attachments:
Download 'multicell.pov.txt' (3 KB)

From: Chris Colefax
Subject: Re: scripting troubles
Date: 22 Jun 2000 22:55:52
Message: <3952d1b8@news.povray.org>
rsibbald <rsi### [at] julianuwoca> wrote:
> Sorry, but the problem is not easily described without the .pov
> file which is attached.
>
> I would like to have multiple (eventually >30) cells following the
> spline pathway.  I need them to move independently of each other
> (ie. not rotate together).  I would also like to randomly have them
> within 2-5 units of the spline path instead of having all of them on the
>
> exact same path.  I'm close, yet still having trouble.  Spacing between
> the cells is also a major concern.  They are all bunching up a little
> too
> much.
>        Any help would be much appreciated.  I am new to povray yet
> am amazed at how much help I have found thus far.  So thanks, in
> advance.

To start, let's look at the code you used, and what exactly it does.
Outside the loop you have:

#declare ang = seed(1);
#declare time = seed(2);
#declare travel = seed (3);

Because these three seed declarations use static values, the stream of
numbers returned by each will also be static throughout the animation.
Looking at the declarations inside the loop:

#declare xx = rand (ang)*360;
#declare yy = rand (ang)*720;
#declare zz = rand (ang)*540;
#declare tt = rand (time)*10;
#declare gh = rand (travel)*8-4;

we can see that each of these values will therefore be static for each
individual cell.  This, then, explains how the cells will actually move:

 object {rbc rotate From (0,<xx,yy,zz>) To (1,<yy,zz,xx>)
             translate From (0,<gh,gh,0>) To (1,<gh,gh,0>)
             animate_by_spline (path, spline_clock (clock*tt))}

Firstly, the rotations will spin each cell in a different way (as you want).
However, the translations for each cell will be static throughout the
animation (because the gh value for each cell remains the same).  What's
more, all the cells will be positioned (before the spline animation)
somewhere on the line between <-4, -4, 0> and <4, 4, 0>.

Finally, the spline clock for each cell will start at 0 (all bunched
together) and end somewhere between 0 and 10.  Because the spline's clock
loops between 0 and 1, this means some cells might only have moved partially
along the spline by the end of the animation, and others might have moved 10
times around the spline.  Presumably, this is *not* what you want!

Of course, there are many different ways to go about animating a group of
objects like this.  How complicated the coding gets depends on whether
you're worried about accurately simulating the cell's movements, collision
detection, etc.  I think your code is quite suitable, though, and with a
little modification it should do what you want:

union {
#declare ang = seed(1);
#declare travel = seed (3);

#declare rbc_count = 30; #while (rbc_count > 0)
   #declare Pos = (<rand(travel), rand(travel), rand(travel)> - 0.5)*<20,
20, 30>;
   #declare Rot1 = <rand(ang), rand(ang), rand(ang)>*-720;
   #declare Rot2 = <rand(ang), rand(ang), rand(ang)>*720;
   object {rbc translate Pos rotate From (0, Rot1) To (1, Rot2)}
#declare rbc_count = rbc_count - 1; #end

animate_by_spline (path, default_options)}

The first change I've made is to union all the cells together, and move them
en masse along the spline.  This ensures that all the cells move at the same
speed, but the way they are positioned inside the union prevents them from
being a static block.  Specifically, I first spread out each cell within a
20x20x30 block around the origin.  This gives the cells enough room to avoid
bunching up - if you want them more compact, you probably need to scale the
cells smaller.

The rotations for each cell range from somewhere between <-720, -720, -720>
and <720, 720, 720>, from the start of the animation to the finish.  Because
the rotation (which always takes place around the origin) is applied *after*
the translation, each cell will actually be pivoting around some point
outside of itself, rather than around its own centre (imagine your elbow as
the pivot point, with the cell in your hand).  This means that each cell
will move in a random arc around the other cells, so that even though they
all move along the same spline at the same speed, they will each appear to
be accelerating and decelerating differently.

Further rotations and translations can be applied to each cell, depending on
the exact effect you want.  The important thing to remember is that you'll
only get movement when the transformation is dependant (at some point) on
the clock.


Post a reply to this message

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