|
|
On 07/17/2018 05:36 PM, Mike Horvath wrote:
> I want to be able to tie a variable to the clock value, but only for
> certain portions.
>
> For example, the variable should be equal to 0 before the clock is 0.3,
> and equal to one after the clock is equal to 0.6. In between 0.3 and 0.6
> the clock should interpolate from 0 to 1.
>
> How would I do this using a macro? Thanks.
>
>
> Mike
This might be the single most common thing I do in my anim.
I never hardcode 0.3 in the code. Because you will likely want to tweak
it [1] and here you only have to change it in one place.
#declare Start=0.3;
#declare End = 0.6;
#switch (myclock)
#range (0,Start)
#declare Out=0;
#break
#range(Start, End)
#declare Out=AniSegment(Start,End);
#break
#range(End,1)
#declare Out=1;
#break
#end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Animate this segment of the clock from 0 to 1
#macro AniSegment(_start, _end)
((myclock-_start)/(_end-_start))
#end
Additionally, I like to add acceleration/deceleration to the move. So:
#range(Start, End)
#local F=AniSegment(Start,End);
#declare Out=Curve0(F);
#break
where
#declare pi2=(pi*2);
///////////////////////////////////////////////////////////////////////////////////////////////////
// Curves: see http://www.buckosoft.com/~dick/pov/curves/
#macro Curve0(_i)
(0.5-(cos(_i/2*pi2)/2))
#end
[1] This smells like you really want
#declare Start=1/3;
#declare End=2/3;
--
dik
Rendered 328976 of 330000 (99%)
Post a reply to this message
|
|