POV-Ray : Newsgroups : povray.general : #declares within #macro are cleared across (#switch, #case, #break) Server Time
5 Nov 2024 07:19:31 EST (-0500)
  #declares within #macro are cleared across (#switch, #case, #break) (Message 1 to 4 of 4)  
From: volt
Subject: #declares within #macro are cleared across (#switch, #case, #break)
Date: 10 Aug 2007 03:25:00
Message: <web.46bc11e0d5109145c1db64640@news.povray.org>
Here is what I'm doing: Making it so the .inc calculates the distance that
the
camera moves from lastframe to thisframe, and then only moving it half of
that distance. The result, if successful, would be a smoother camera for
rendering .povs.

In the example given in the inc, the camera moves slightly for the first 3
frames and then stays still for 2 frames.  If my goal is achieved, the
camera will move at a constant speed for the first 3 frames and then slow
down for the next 2 frames.

After I figure this out, if possible, the part where it only moves the
camera
half the distance will be changed to one-quarter, one-eighth, or any other
value, to determine how fast the camera accelerates.

The first frame that the macro is invoked, for the first frame, the macro is
set
to use the camera's initial position only.

The problem is that when the #break is reached on line 48, pov-ray clears
the
oxpos, oypos, and ozpos values declared in the macro that was invoked on
line 47. This means that the second time that the macro is invoked, when
the macro reaches line 25, it gives the parse error that 'oxpos' is an
"undeclared identifier."

Is there any known workaround for this? I've scavenged the 'net as well as
the help file.

Before running the .inc, set initial_frame=1 and final_frame=5

---
..inc begins here
---

// this is the camera's acceleration
#declare camaccel=0.5;

// this is setting the camera( ) macro
#macro Camera( xpos, ypos, zpos, lookatx, lookaty, lookatz)

// this sets the camera up to be moved from the first frame
#if (frame_number=initial_frame)
#declare oxpos=xpos;
#declare oypos=ypos;
#declare ozpos=zpos;
#end

// this sets up the camera in a position as follows:
// it takes the old position and the new position, and then places the
camera a set distance toward
// the new position, with the set distance being a percentage "camaccel" of
the total distance
//
// Example: if frame 1 has camera at <1,0,1> and frame 2 has camera at
<2,0,1> the following script
//          will place the camera at <1.5,0,1>.
camera {

//this is the error line:
location <oxpos+camaccel*(xpos-oxpos),-(oypos+camaccel*(ypos-oypos)),
ozpos+camaccel*(zpos-ozpos)>

sky <0, 0, 1>
look_at <lookatx, -lookaty, lookatz>}

// this sets the position we just found above as the old position, for the
next frame
#declare oxpos=oxpos+camaccel*(xpos-oxpos);
#declare oypos=oypos+camaccel*(ypos-oypos);
#declare ozpos=ozpos+camaccel*(zpos-ozpos);




// light source
light_source { <xpos, -ypos, 5> color rgb <1,1,1>}
#end

// nothing below this line can be edited.
// this is the same information generated in mass-scale from the program

#switch (frame_number)
#case (1)
Camera(5.108626, 2.569125, 2.406943,  0.999140, -0.099606, 0.206943)
#break

#case (2)
Camera(5.108626, 3.569125, 2.406943,  0.999140, -0.099606, 0.206943)
#break

#case (3)
Camera(5.108626, 4.569125, 2.406943,  0.999140, -0.099606, 0.206943)
#break

#case (4)
Camera(5.108626, 4.569125, 2.406943,  0.999140, -0.099606, 0.206943)
#break

#case (5)
Camera(5.108626, 4.569125, 2.406943,  0.999140, -0.099606, 0.206943)
#break
#end

//stuff to look at
plane{z, 0
pigment{color rgb <1,1,.9>}}
box{<-1,-1,0>,<1,1,2>
pigment{color rgb <.9,1,1>  }}


Post a reply to this message

From: Mike Williams
Subject: Re: #declares within #macro are cleared across (#switch, #case, #break)
Date: 10 Aug 2007 03:54:09
Message: <jWPLqeA9lBvGFwvS@econym.demon.co.uk>
POV variables don't persist between frames.

When you start parsing frame 2, all the variables are undefined. They
don't have the values that that they ended up with at the end of frame
1. You either have to re-calculate the values from scratch in each
frame, or write the calculated values to a file and read them back in
subsequent frames.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Tim Nikias
Subject: Re: #declares within #macro are cleared across (#switch, #case, #break)
Date: 10 Aug 2007 04:44:49
Message: <46bc2581$1@news.povray.org>
Mike Williams wrote:
> POV variables don't persist between frames.
> 
> When you start parsing frame 2, all the variables are undefined. They
> don't have the values that that they ended up with at the end of frame
> 1. You either have to re-calculate the values from scratch in each
> frame, or write the calculated values to a file and read them back in
> subsequent frames.

Shameless plug (and an attempt to help): If you just save ALL variables 
in an array, it might be very easy to use my I/O-Macros to read/write 
arrays to disk...

http://www.nolights.de/rnd/development.html#iomacros

Regards,
Tim

-- 
aka "Tim Nikias"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: volt
Subject: Re: #declares within #macro are cleared across (#switch, #case, #break)
Date: 10 Aug 2007 12:25:00
Message: <web.46bc90fe2a53bed8c1db64640@news.povray.org>
Thanks, Tim, I haven't tried it yet, but I'm sure that this is what I'm
looking for.

For the curious, I'm using POV-ray to render a game called "Toribash"
(www.toribash.com) because there's a built-in function of the game to
create an "animation.pov" that saves the location of the camera, joints,
and body pieces in a way where macros are written to create spheres/boxes
for the body and blobs for the blood, all textured/finished to choice and
in a modeled environment.  Check the following link for videos of what I've
done with Toribash and Pov-Ray:

http://www.toribash.com/forum/showthread.php?t=11578

Thanks again

> Shameless plug (and an attempt to help): If you just save ALL variables
> in an array, it might be very easy to use my I/O-Macros to read/write
> arrays to disk...
>
> http://www.nolights.de/rnd/development.html#iomacros
>
> Regards,
> Tim
>
> --
> aka "Tim Nikias"
> Homepage: <http://www.nolights.de>


Post a reply to this message

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