POV-Ray : Newsgroups : povray.general : #declares within #macro are cleared across (#switch, #case, #break) : #declares within #macro are cleared across (#switch, #case, #break) Server Time
31 Jul 2024 08:19:16 EDT (-0400)
  #declares within #macro are cleared across (#switch, #case, #break)  
From: volt
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

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