POV-Ray : Newsgroups : povray.animations : How to run initialization code only once for all frames Server Time
20 Apr 2024 03:14:12 EDT (-0400)
  How to run initialization code only once for all frames (Message 1 to 2 of 2)  
From: Tomohiro
Subject: How to run initialization code only once for all frames
Date: 19 Jan 2011 06:30:00
Message: <web.4d36ca9e87d6bd0088b2ef990@news.povray.org>
Hello,

I would like to generate an animation. The scene file contains
a lot of preparatory calculations (initializations). The following
is a reduced example.


// Initialization
#local R=seed(10);
#local J=0;
#while(J<10000)
  #local POS[J]=<rand(R)*100, rand(R)*100, rand(R)*100>
  #local J=J+1;
#end

// Drawing
#local J=0;
#while(J<10000)
  sphere{ POS[J] + <clock*100,0,0> ,1}
  #local J=J+1;
#end

For a 1000-frame animation, the whole scene file will need to
be run 1000 times, including the initialization part.
However, I think it is not needed and just a waste of time.
How can I omit the 999-time calculations and let my PC do the
calculation only once?


Post a reply to this message

From: clipka
Subject: Re: How to run initialization code only once for all frames
Date: 19 Jan 2011 06:34:47
Message: <4d36cc57$1@news.povray.org>
Am 19.01.2011 12:28, schrieb Tomohiro:
> Hello,
>
> I would like to generate an animation. The scene file contains
> a lot of preparatory calculations (initializations). The following
> is a reduced example.
>
>
> // Initialization
> #local R=seed(10);
> #local J=0;
> #while(J<10000)
>    #local POS[J]=<rand(R)*100, rand(R)*100, rand(R)*100>
>    #local J=J+1;
> #end
>
> // Drawing
> #local J=0;
> #while(J<10000)
>    sphere{ POS[J] +<clock*100,0,0>  ,1}
>    #local J=J+1;
> #end
>
> For a 1000-frame animation, the whole scene file will need to
> be run 1000 times, including the initialization part.
> However, I think it is not needed and just a waste of time.
> How can I omit the 999-time calculations and let my PC do the
> calculation only once?

You can use "#fopen" / "#write" / "#fclose" to auto-generate an .inc 
file (and do this only on the very first frame), and then #include it 
for all frames.


Post a reply to this message

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