POV-Ray : Newsgroups : povray.animations : Shed version 2 Server Time
16 May 2024 04:33:50 EDT (-0400)
  Shed version 2 (Message 31 to 33 of 33)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Klewlis
Subject: Re: Shed version 2
Date: 21 Feb 2017 19:10:01
Message: <web.58acd5bfe97123ee5f9209890@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Klewlis" <nomail@nomail> wrote:
>
> > OK, I suspect the problem is in the fact that I am running the animation from an
> > ..ini file.  This would be the same problem I had with the #while command.
>
> I would not have guessed that would be a / the problem
>

Actually, the problem is not in the Switch/Range.  The problem is in the other
coding I used.

#switch (frame_number)
    #range (1, 35)
        #declare b=b+1;
        object { SunLight
            rotate x*(b/2)
        }
    #break
    #range (36, 60)
        object { SunLight
            rotate x*(b/2)
        }
    #break
    #range (61, 282)
        #declare b=b+1;
        object { SunLight
            rotate x*(b/2)
        }
    #break
#end

Just before this code, I do: #declare b=0, so each time POV parses the file, b
is initialized to 0.  During the first 35 frames b=1 because of this.

This actually makes me wonder why this works:
    #declare a=2;

    #for (i, 1.5, 241.5, 16)
        #declare a=a+1;
        #if (frame_number>a)
            object {Stud
                rotate z*90
                #if (i<240)
                    translate <i, 0, 140.375>
                #else
                    translate <i-1.5, 0, 140.375>
                #end
            }
        #end
    #end

(I am not complaining, I am glad it works.)  It seems that each time the file is
parsed, "i" would be initialized to 1.5, but instead it is incremented by 16.

Thank you;
Ken


Post a reply to this message

From: Bald Eagle
Subject: Re: Shed version 2
Date: 22 Feb 2017 07:45:00
Message: <web.58ad8768e97123eec437ac910@news.povray.org>
"Klewlis" <nomail@nomail> wrote:

> Just before this code, I do: #declare b=0, so each time POV parses the file, b
> is initialized to 0.  During the first 35 frames b=1 because of this.

Yes, I had a little voice telling me I ought to suggest looking at that part,
but it got overridden.   :(

> This actually makes me wonder why this works:
>     #declare a=2;
>
>     #for (i, 1.5, 241.5, 16)
>         #declare a=a+1;
>         #if (frame_number>a)
>             object {Stud
>                 rotate z*90
>                 #if (i<240)
>                     translate <i, 0, 140.375>
>                 #else
>                     translate <i-1.5, 0, 140.375>
>                 #end
>             }
>         #end
>     #end
>


Frame number increases with each frame, and so even if 'a' stays static, frame
number remains greater than a.

(Remember that it's always good practice to use capitalized varible names to
avoid conflicts with 'internal' POV-Ray names.)


Post a reply to this message

From: clipka
Subject: Re: Shed version 2
Date: 22 Feb 2017 11:39:14
Message: <58adbeb2$1@news.povray.org>
Am 22.02.2017 um 01:05 schrieb Klewlis:

> This actually makes me wonder why this works:
>     #declare a=2;
> 
>     #for (i, 1.5, 241.5, 16)
>         #declare a=a+1;
>         #if (frame_number>a)
>             object {Stud
>                 rotate z*90
>                 #if (i<240)
>                     translate <i, 0, 140.375>
>                 #else
>                     translate <i-1.5, 0, 140.375>
>                 #end
>             }
>         #end
>     #end
> 
> (I am not complaining, I am glad it works.)  It seems that each time the file is
> parsed, "i" would be initialized to 1.5, but instead it is incremented by 16.

As a matter of fact, /both/ happens in each frame; the latter even
multiple times.

So in frame #1 you get:

    frame_number = 1
    a = 2
    i = 1.5
        a = 3
        test if frame_number(=1) > a(=3) -> no
    i = 17.5
        a = 4
        test if frame_number(=1) > a(=4) -> no
    i = 33.5
        a = 5
        test if frame_number(=1) > a(=5) -> no
    i = 49.5
        a = 6
        test if frame_number(=1) > a(=6) -> no
    ...etc...

Then, in frame #2, you get:

    frame_number = 2
    a = 2
    i = 1.5
        a = 3
        test if frame_number(=2) > a(=3) -> no
    i = 17.5
        a = 4
        test if frame_number(=2) > a(=4) -> no
    i = 33.5
        a = 5
        test if frame_number(=2) > a(=5) -> no
    i = 49.5
        a = 6
        test if frame_number(=2) > a(=6) -> no
    ...etc...

Later, in frame #3, you get:

    frame_number = 3
    a = 2
    i = 1.5
        a = 3
        test if frame_number(=3) > a(=3) -> no
    i = 17.5
        a = 4
        test if frame_number(=3) > a(=4) -> no
    i = 33.5
        a = 5
        test if frame_number(=3) > a(=5) -> no
    i = 49.5
        a = 6
        test if frame_number(=3) > a(=6) -> no
    ...etc...

At last, in frame #4, you get:

    frame_number = 4
    a = 2
    i = 1.5
        a = 3
        test if frame_number(=4) > a(=3) -> yes
            insert a Stud at i=1.5
    i = 17.5
        a = 4
        test if frame_number(=4) > a(=4) -> no
    i = 33.5
        a = 5
        test if frame_number(=4) > a(=5) -> no
    i = 49.5
        a = 6
        test if frame_number(=4) > a(=6) -> no
    ...etc...

In frame #5, you get:

    frame_number = 5
    a = 2
    i = 1.5
        a = 3
        test if frame_number(=5) > a(=3) -> yes
            insert a Stud at i=1.5
    i = 17.5
        a = 4
        test if frame_number(=5) > a(=4) -> yes
            insert a Stud at i=17.5
    i = 33.5
        a = 5
        test if frame_number(=5) > a(=5) -> no
    i = 49.5
        a = 6
        test if frame_number(=5) > a(=6) -> no
    ...etc...

... and so forth.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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