POV-Ray : Newsgroups : povray.advanced-users : Very odd effect in an animation... Server Time
31 Oct 2024 16:17:15 EDT (-0400)
  Very odd effect in an animation... (Message 1 to 8 of 8)  
From: Carl
Subject: Very odd effect in an animation...
Date: 30 Jan 2005 18:40:01
Message: <web.41fd6f6253e7090a29d4ff530@news.povray.org>
Check out this animation: (174,908 bytes)
http://www.wwwmwww.com/TRON/test1.gif

Now check out this one: (172,434 bytes)
http://www.wwwmwww.com/TRON/test2.gif

The second one is how the animation SHOULD look.  The 5th frame in the
first one has the BLUE bike in the wrong location.  It's placed it at x=0
for some reason that's beyond me.  The only difference between the code
that produced the first animation and the second is the array I've declared
that defines the path of the RED bike.  In the first animation I used:

  #declare path1 = array[4]
  {<10-0.5,0,21>, <10-0.5,0,25>, <11-0.5,0,25>, <11-0.5,0,30>};

In the second animation I used:

  #declare path1 = array[4]
  {<9.5,0,21>, <9.5,0,25>, <10.5,0,25>, <10.5,0,30>};

The path the BLUE bike follows in both animations is defines by this array:

  #declare path3 = array[2]
  {<11.5,0,18>, <11.5,0,28>};

Is there something wrong with the way I declared path1 in the first
animation?  If so it seemed to work as expected in 10 of 11 frames.  Any
ideas?  I'll post all the code if need be.

Thanks,
Carl


Post a reply to this message

From: Carl
Subject: Re: Very odd effect in an animation...
Date: 30 Jan 2005 18:55:00
Message: <web.41fd734bdbc88d1529d4ff530@news.povray.org>
I forgot to add I'm using POV-Ray Version 3.6.1.icl8.win32 on a 1.5 GHz
Pentium 4 running Windows ME if that makes a difference.

Thanks,
Carl


Post a reply to this message

From: Slime
Subject: Re: Very odd effect in an animation...
Date: 30 Jan 2005 19:13:49
Message: <41fd783d$1@news.povray.org>
> The only difference between the code
> that produced the first animation and the second is the array I've
declared
> that defines the path of the RED bike.

By any chance, are you passing variables "by reference" into macros? (So
that the macros change their values?)

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Carl
Subject: Re: Very odd effect in an animation...
Date: 30 Jan 2005 20:55:00
Message: <web.41fd8e9edbc88d1529d4ff530@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote:
> By any chance, are you passing variables "by reference" into macros? (So
> that the macros change their values?)

Yes, I'm passing variables to macross to be set by those macros.  I declare
them outside the macro to be zero before the macro is called.  At the
beginning of my code I have:

#declare Bike1x = 0;
#declare Bike1z = 0;
#declare Bike1Forward = <1,0,0>;
#declare Bike1Color = Red;

#declare Bike2x = 0;
#declare Bike2z = 0;
#declare Bike2Forward = <1,0,0>;
#declare Bike2Color = Orange;

#declare Bike3x = 0;
#declare Bike3z = 0;
#declare Bike3Forward = <1,0,0>;
#declare Bike3Color = Blue;

#declare Bike4x = 0;
#declare Bike4z = 0;
#declare Bike4Forward = <1,0,0>;
#declare Bike4Color = Orange;

  I then have my macros followed by:

JetWall (path1,bike_height,wall_width,Bike1Color,Bike1x,Bike1z,Bike1Forward)
JetWall (path2,bike_height,wall_width,Bike2Color,Bike2x,Bike2z,Bike2Forward)
JetWall (path3,bike_height,wall_width,Bike3Color,Bike3x,Bike3z,Bike3Forward)
JetWall (path4,bike_height,wall_width,Bike4Color,Bike4x,Bike4z,Bike4Forward)
#declare Spokes = (frame_number/2=int(frame_number/2));
LightCycle(Bike1x,Bike1z,Bike1Forward,Bike1Color,Spokes,135,155)
LightCycle(Bike2x,Bike2z,Bike2Forward,Bike2Color,Spokes,155,185)
LightCycle(Bike3x,Bike3z,Bike3Forward,Bike3Color,Spokes,165,125)
LightCycle(Bike4x,Bike4z,Bike4Forward,Bike4Color,Spokes,35,195)

JetWall is a macro that draws the wall following the bike and calculates the
location (Bike#x and Bike#z) and forward direction (Bike#Foward)  Those
values are then passed to the macro LightCycle that draws the Bike itself.
I'm not 100% sure what you mean by "by reference".

Thanks,
Carl


Post a reply to this message

From: Slime
Subject: Re: Very odd effect in an animation...
Date: 30 Jan 2005 21:52:11
Message: <41fd9d5b$1@news.povray.org>
> > By any chance, are you passing variables "by reference" into macros? (So
> > that the macros change their values?)
>
> Yes, I'm passing variables to macross to be set by those macros.

A bug was recently discovered where doing that fails very infrequently.
Details can be found in the thread "Differences in rendering 3.50 vs. 3.6.1"
in povray.general on 11/24/2004. Basically, your changes to the variables
within the macro aren't changing their values outside of the macro. This bug
will be fixed in 3.6.2 according to Thorsten.

You can work around this by using global variables, setting their values
inside the macros, and then reading those values after calling the macros.
Or I think you can use 3.6.0 if that's easier and you're not relying on the
3.6.1 bugfixes.

> I'm not 100% sure what you mean by "by reference".

When a variable is passed "by reference," it means that the variable you see
inside the macro is the same as the one outside the macro; so changing it
inside the macro affects the value of the original variable passed in. When
a variable is passed "by value," its value is copied into a new variable
inside the macro, and changing that variable has no effect on the original
variable that was passed.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Carl
Subject: Re: Very odd effect in an animation...
Date: 30 Jan 2005 23:35:00
Message: <web.41fdb4d1dbc88d1529d4ff530@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote:
> A bug was recently discovered where doing that fails very infrequently.
> Details can be found in the thread "Differences in rendering 3.50 vs. 3.6.1"
> in povray.general on 11/24/2004.

Thanks.  I read the thread and that sounds exactly like the problem I'm
having.  It's good to know the bug wasn't in my code which to be honest
surprises me.

> This bug will be fixed in 3.6.2 according to Thorsten.

Any idea when 3.6.2 is coming out?  I'm guessing that's not public knowledge
yet, but figured it couldn't hurt to ask.

Carl


Post a reply to this message

From: Rune
Subject: Re: Very odd effect in an animation...
Date: 31 Jan 2005 15:48:53
Message: <41fe99b5$1@news.povray.org>
Slime wrote:
>> I'm not 100% sure what you mean by "by reference".
>
> When a variable is passed "by reference," it means that the variable
> you see inside the macro is the same as the one outside the macro; so
> changing it inside the macro affects the value of the original
> variable passed in. When a variable is passed "by value," its value
> is copied into a new variable inside the macro, and changing that
> variable has no effect on the original variable that was passed.

This difference I know, but I've never been quite sure, in POV-script, HOW 
you pass a variable by reference and how do you pass it by value?

Also, where in the documentation is the information about passing by 
reference versus passing by value?

Rune
-- 
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

From: Slime
Subject: Re: Very odd effect in an animation...
Date: 31 Jan 2005 16:22:54
Message: <41fea1ae@news.povray.org>
> This difference I know, but I've never been quite sure, in POV-script, HOW
> you pass a variable by reference and how do you pass it by value?

In POV-Ray, all variables are passed by reference and all non-variables are
passed by value.

mymacro(
    3, // by value
    myvar, // by reference
    myvar + 0 // by value
)

> Also, where in the documentation is the information about passing by
> reference versus passing by value?

Not sure. Probably around wherever macros are explained. Everything I said
in these two posts I either heard on this newsgroup or learned from other
languages.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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