POV-Ray : Newsgroups : povray.general : Steps & Time Server Time
5 Nov 2024 07:19:31 EST (-0500)
  Steps & Time (Message 1 to 5 of 5)  
From: Simon
Subject: Steps & Time
Date: 7 Aug 2007 04:25:02
Message: <46b82c5e$1@news.povray.org>
Hi all,

wonder if someone can suggest some methods for dealing with this:

Currently: Whenever I want to have multiple steps in a scene, I do something 
like the following:

#declare Steps = 10;
#declare Step = floor(Steps*clock);
#declare Clock = mod(clock*Steps,1);

#if(Step=0)
    //Some rules for step 0 of the animation
#else
    //Some rules for after step 0, usually keeping an object stable
#end

As you can imagine, this becomes cumbersome very quickly if an object is 
doing different things in each step - and it means a lot of nested IFs. In 
the demo above, the steps are all of even Length, but that is easily 
resolved with a bit of logic and an array.

An alternative that sprang to mind was just to copy/paste into multiple 
scenes but that means that if I decide to change something in a previous, I 
have to propogate my changes up and down the timeline - also cumbersome.

Any pointers would be greatly appreciated

(whilst writing this I realised there should be a switch statement of some 
kind and *tada* there is - but still, if anyone has any suggestions, please 
let me know)


Post a reply to this message

From: Alain
Subject: Re: Steps & Time
Date: 7 Aug 2007 05:57:21
Message: <46b84201$1@news.povray.org>
Simon nous apporta ses lumieres en ce 2007/08/07 04:24:
> Hi all,
> 
> wonder if someone can suggest some methods for dealing with this:
> 
> Currently: Whenever I want to have multiple steps in a scene, I do something 
> like the following:
> 
> #declare Steps = 10;
> #declare Step = floor(Steps*clock);
> #declare Clock = mod(clock*Steps,1);
> 
> #if(Step=0)
>     //Some rules for step 0 of the animation
> #else
>     //Some rules for after step 0, usually keeping an object stable
> #end
> 
> As you can imagine, this becomes cumbersome very quickly if an object is 
> doing different things in each step - and it means a lot of nested IFs. In 
> the demo above, the steps are all of even Length, but that is easily 
> resolved with a bit of logic and an array.
> 
> An alternative that sprang to mind was just to copy/paste into multiple 
> scenes but that means that if I decide to change something in a previous, I 
> have to propogate my changes up and down the timeline - also cumbersome.
> 
> Any pointers would be greatly appreciated
> 
> (whilst writing this I realised there should be a switch statement of some 
> kind and *tada* there is - but still, if anyone has any suggestions, please 
> let me know) 
> 
> 
Take a look at the #switch(...) #case(...) #range(...) #break structure.
3.2.2.6.3  The #switch, #case, #range and #break Directives


-- 
Alain
-------------------------------------------------
  My bologna has a first name.

                    Oscar Mayer


Post a reply to this message

From: Chris B
Subject: Re: Steps & Time
Date: 7 Aug 2007 07:55:32
Message: <46b85db4@news.povray.org>
"Simon" <povray@*NOSPAM*SOWare.co.uk> wrote in message 
news:46b82c5e$1@news.povray.org...
> Hi all,
>
> wonder if someone can suggest some methods for dealing with this:
>
> Currently: Whenever I want to have multiple steps in a scene, I do 
> something like the following:
>
> #declare Steps = 10;
> #declare Step = floor(Steps*clock);
> #declare Clock = mod(clock*Steps,1);
>
> #if(Step=0)
>    //Some rules for step 0 of the animation
> #else
>    //Some rules for after step 0, usually keeping an object stable
> #end
>
> As you can imagine, this becomes cumbersome very quickly if an object is 
> doing different things in each step - and it means a lot of nested IFs. In 
> the demo above, the steps are all of even Length, but that is easily 
> resolved with a bit of logic and an array.
>
> An alternative that sprang to mind was just to copy/paste into multiple 
> scenes but that means that if I decide to change something in a previous, 
> I have to propogate my changes up and down the timeline - also cumbersome.
>
> Any pointers would be greatly appreciated
>
> (whilst writing this I realised there should be a switch statement of some 
> kind and *tada* there is - but still, if anyone has any suggestions, 
> please let me know)

Hi Simon,

Lots of alternatives spring to mind.

Basically anything that can return a number (or numbers) can be used to 
control an animation, so you could look at using functions, macros, splines 
etc. You may be able to avoid 'if' statements and 'switch' statements by 
using your 'step' variable as the index to an array. For example, you could 
set up an array from 0 to 10 with values such as 
0,0,0,0.1,0.3,0.5,0.7,0.9,1,1 and then use the value of your 'step' variable 
to retrieve a value from the array. You could then use that value to 
retrieve the coordinates at that distance along a spline or along a sine 
wave or a normal at a point on a surface (trace) or a colour at a point in 
space in a pigment (eval_pigment) etc. etc.

You can then do whatever you want with that number/coordinate/normal/colour. 
With the above example you could use the position along a spline to control 
a camera position, so that it stays still for the first 3 'steps', 
accelerates along the spline and stops for a while at the end, or, if the 
spline stays within a box from <0,0,0> to <1,1,1>, you could use the 
'position' on the spline as the colour of an object.

Hope this inspires some ideas but be careful not to get too wacked out on 
psychedelia.

Regards,
Chris B.


Post a reply to this message

From: Simon
Subject: Re: Steps & Time
Date: 7 Aug 2007 13:46:01
Message: <46b8afd9$1@news.povray.org>
"Chris B" <c_b### [at] btconnectcomnospam> wrote in message 
news:46b85db4@news.povray.org...
>
> "Simon" <povray@*NOSPAM*SOWare.co.uk> wrote in message 
> news:46b82c5e$1@news.povray.org...
>> Hi all,
>>
>> wonder if someone can suggest some methods for dealing with this:
>>
>> Currently: Whenever I want to have multiple steps in a scene, I do 
>> something like the following:
>>
>> #declare Steps = 10;
>> #declare Step = floor(Steps*clock);
>> #declare Clock = mod(clock*Steps,1);
>>
>> #if(Step=0)
>>    //Some rules for step 0 of the animation
>> #else
>>    //Some rules for after step 0, usually keeping an object stable
>> #end
>>
>> As you can imagine, this becomes cumbersome very quickly if an object is 
>> doing different things in each step - and it means a lot of nested IFs. 
>> In the demo above, the steps are all of even Length, but that is easily 
>> resolved with a bit of logic and an array.
>>
>> An alternative that sprang to mind was just to copy/paste into multiple 
>> scenes but that means that if I decide to change something in a previous, 
>> I have to propogate my changes up and down the timeline - also 
>> cumbersome.
>>
>> Any pointers would be greatly appreciated
>>
>> (whilst writing this I realised there should be a switch statement of 
>> some kind and *tada* there is - but still, if anyone has any suggestions, 
>> please let me know)
>
> Hi Simon,
>
> Lots of alternatives spring to mind.
>
> Basically anything that can return a number (or numbers) can be used to 
> control an animation, so you could look at using functions, macros, 
> splines etc. You may be able to avoid 'if' statements and 'switch' 
> statements by using your 'step' variable as the index to an array. For 
> example, you could set up an array from 0 to 10 with values such as 
> 0,0,0,0.1,0.3,0.5,0.7,0.9,1,1 and then use the value of your 'step' 
> variable to retrieve a value from the array. You could then use that value 
> to retrieve the coordinates at that distance along a spline or along a 
> sine wave or a normal at a point on a surface (trace) or a colour at a 
> point in space in a pigment (eval_pigment) etc. etc.
>
> You can then do whatever you want with that 
> number/coordinate/normal/colour. With the above example you could use the 
> position along a spline to control a camera position, so that it stays 
> still for the first 3 'steps', accelerates along the spline and stops for 
> a while at the end, or, if the spline stays within a box from <0,0,0> to 
> <1,1,1>, you could use the 'position' on the spline as the colour of an 
> object.
>
> Hope this inspires some ideas but be careful not to get too wacked out on 
> psychedelia.
>
> Regards,
> Chris B.
>

Thanks very much Chris, the array idea really appeals to me. I'll need to 
sit and ponder how best to utilise it - what springs to mind is having an 
array of stings that are evaluated in place based on the Step. I may end up 
using a micture of this and the if/switch/etc... to come to some sort of 
hybrid. I'll also look into using a function.

Thanks again for the input, it's greatly appreciated.

Simon


Post a reply to this message

From: Simon
Subject: Re: Steps & Time
Date: 7 Aug 2007 15:25:46
Message: <46b8c73a$1@news.povray.org>
"Alain" <ele### [at] netscapenet> wrote in message 
news:46b84201$1@news.povray.org...
> Simon nous apporta ses lumieres en ce 2007/08/07 04:24:
>> Hi all,
>>
>> wonder if someone can suggest some methods for dealing with this:
>>
>> Currently: Whenever I want to have multiple steps in a scene, I do 
>> something like the following:
>>
>> #declare Steps = 10;
>> #declare Step = floor(Steps*clock);
>> #declare Clock = mod(clock*Steps,1);
>>
>> #if(Step=0)
>>     //Some rules for step 0 of the animation
>> #else
>>     //Some rules for after step 0, usually keeping an object stable
>> #end
>>
>> As you can imagine, this becomes cumbersome very quickly if an object is 
>> doing different things in each step - and it means a lot of nested IFs. 
>> In the demo above, the steps are all of even Length, but that is easily 
>> resolved with a bit of logic and an array.
>>
>> An alternative that sprang to mind was just to copy/paste into multiple 
>> scenes but that means that if I decide to change something in a previous, 
>> I have to propogate my changes up and down the timeline - also 
>> cumbersome.
>>
>> Any pointers would be greatly appreciated
>>
>> (whilst writing this I realised there should be a switch statement of 
>> some kind and *tada* there is - but still, if anyone has any suggestions, 
>> please let me know)
> Take a look at the #switch(...) #case(...) #range(...) #break structure.
> 3.2.2.6.3  The #switch, #case, #range and #break Directives
>
>
> -- 
> Alain
> -------------------------------------------------
>  My bologna has a first name.
>
>                    Oscar Mayer

Alain, many thanks! I must admit I never realised how flexible the switch 
statement was! This definitely seems to be the way to go (although I'll also 
be looking into Chris's ideas).

I just want to thank you both for your advice.

Regards,
S


Post a reply to this message

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