POV-Ray : Newsgroups : povray.newusers : Moving Camera Server Time
24 Nov 2024 20:56:58 EST (-0500)
  Moving Camera (Message 1 to 5 of 5)  
From: OpalPlanet
Subject: Moving Camera
Date: 15 Jun 2007 17:55:01
Message: <web.467309fa983673bc39928d3a0@news.povray.org>
I'm new to POV, and I'm trying to make a camera follow a certain path. For a
total time of 5, I want the camera to spend 0<t<1 at a certain point, then
move along a specific circular path over time 1<t<2, and then remain at the
end
point of this path for t>2. This is the code i wrote for it, but it doesn't
seem to work. I'm sure I'm missing someting stupidly obvious, but could
someone give me a hand. Either de-bug or a pointer in the right direction
would be helpful.

Thx,
OpalPlanet


//declare variables for camera motion
#declare loopcount = 0;
#declare X = 0;
#declare Y = 0;
#declare Z = -3.5;
#declare Ystep = -.01375;
#declare Zstep = -.0125;

#if (clock <= 1)
camera {
 location <0,0,-3.5 >
 look_at <0,0,0>}

#else #if (clock <= 2)
 //move camera coords
  #while loopcount <= 200
   Y = Y + Ystep;
   Z = Z + Zstep;
  #end // end while
 camera {
  location <0, Y, Z >
  look_at <0,0,0>
  }

#else
 camera{
  location<0,-2.75,-1>
  look_at<0,0,0>
  }
 //end cameras


Post a reply to this message

From: Charles C
Subject: Re: Moving Camera
Date: 15 Jun 2007 19:25:02
Message: <web.46731eabe5525c43e94cc5130@news.povray.org>
"OpalPlanet" <ecs### [at] msncom> wrote:
> I'm new to POV, and I'm trying to make a camera follow a certain path. For a
> total time of 5, I want the camera to spend 0<t<1 at a certain point, then
> move along a specific circular path over time 1<t<2, and then remain at the
> end
> point of this path for t>2. This is the code i wrote for it, but it doesn't
> seem to work. I'm sure I'm missing someting stupidly obvious, but could
> someone give me a hand. Either de-bug or a pointer in the right direction
> would be helpful.
>
> Thx,
> OpalPlanet
>
>
> //declare variables for camera motion
> #declare loopcount = 0;
> #declare X = 0;
> #declare Y = 0;
> #declare Z = -3.5;
> #declare Ystep = -.01375;
> #declare Zstep = -.0125;
>
> #if (clock <= 1)
> camera {
>  location <0,0,-3.5 >
>  look_at <0,0,0>}
>
> #else #if (clock <= 2)
>  //move camera coords
>   #while loopcount <= 200
>    Y = Y + Ystep;
>    Z = Z + Zstep;
>   #end // end while
>  camera {
>   location <0, Y, Z >
>   look_at <0,0,0>
>   }
>
> #else
>  camera{
>   location<0,-2.75,-1>
>   look_at<0,0,0>
>   }
>  //end cameras


It looks like you're missing some parenthesis next to your #while statement,
and some #end statements. You also forgot to increment your counter.  It
doesn't work to use multiple #else's but there is a handier thing you can
use instead:

#switch()
  #case() #break
  #case() #break
  #case() #break
#end

Untested but it'd look something like this:


//declare variables for camera motion
#declare X = 0;
#declare Y = 0;
#declare Z = -3.5;
#declare Xstep = 0;
#declare Ystep = -2.75;
#declare Zstep = -1;


#declare MyClock = 5*clock; //A clock that goes from 0 to 1 is good for
compatibility.

#switch (MyClock)
    #case(MyClock <=1)
       #declare Cam_Location = <0,0,-3.5>;
       #declare Cam_Look_At  = <0,0,0>;
    #break
    #case(MyClock <= 2) //testing for <= 1 is covered by previous #case
       #declare Cam_Location =
<X+Xstep*(MyClock-1),Y+YStep*(MyClock-1),Z+Zstep*(MyClock-1)>;
       #declare Cam_Look_At  = <0,0,0>;
    #break
    #case(MyClock > 2)
       #declare Cam_Location = <0,-2.75,-1>;
       #declare Cam_Look_At  = <0,0,0>;
    #break
#end //end #switch (MyClock)

camera{
    location Cam_Location
    look_at  Cam_Look_At
}


Post a reply to this message

From: Tim Attwood
Subject: Re: Moving Camera
Date: 15 Jun 2007 19:37:47
Message: <467322cb$1@news.povray.org>
> I'm new to POV, and I'm trying to make a camera follow a certain path. For 
> a
> total time of 5, I want the camera to spend 0<t<1 at a certain point, then
> move along a specific circular path over time 1<t<2, and then remain at 
> the
> end
> point of this path for t>2. This is the code i wrote for it, but it 
> doesn't
> seem to work. I'm sure I'm missing someting stupidly obvious, but could
> someone give me a hand. Either de-bug or a pointer in the right direction
> would be helpful.
...
> //declare variables for camera motion
> #declare loopcount = 0;
> #declare X = 0;
> #declare Y = 0;
> #declare Z = -3.5;
> #declare Ystep = -.01375;
> #declare Zstep = -.0125;
>
> #if (clock <= 1)

the clock variable defaults to 0..1,
this can be changed in the ini files
or with command line commands,
if you've done that great, otherwise use 1/5 instead...

> camera {
> location <0,0,-3.5 >
> look_at <0,0,0>}
>
> #else #if (clock <= 2)

After holding still you want the
camera to move for 1/5 of the animation.
So just set up another variable for clock
durring that time...

#else
   #local My_clock = clock-1/5;
or
  #local My_clock = clock - 1;


> //move camera coords
>  #while loopcount <= 200
>   Y = Y + Ystep;
>   Z = Z + Zstep;
>  #end // end while

This while loop executes the whole loop, but why?
just leave that out, the animation loop will re-parse
the whole scene for every frame with a different
clock value.

> camera {
>  location <0, Y, Z >
>  look_at <0,0,0>
>  }

Y an Z have the same value every time...
try something like...
#local CLOC = vrotate(<0,0.75,0>;90*My_clock*y)+<0,-2.75,0>;
camera {
   location CLOC
   look_at <0,0,0>
}

You might also look into using a spline, that might make lining
up the start and stop of your movements line up easier
if you decide to change it later.

> #else
> camera{
>  location<0,-2.75,-1>
>  look_at<0,0,0>
>  }
> //end cameras


Post a reply to this message

From: Charles C
Subject: Re: Moving Camera
Date: 15 Jun 2007 19:40:01
Message: <web.46732283e5525c43e94cc5130@news.povray.org>
My example would have needed a #switch(1) at the start instead of
#switch(MyClock), but better yet, leave the #switch(MyClock) and replace
the #case() statements with, for example, statements like #range(0,1).


Post a reply to this message

From: OpalPlanet
Subject: Re: Moving Camera
Date: 18 Jun 2007 13:45:01
Message: <web.4676c490e5525c4339928d3a0@news.povray.org>
"Charles C" <nomail@nomail> wrote:
> My example would have needed a #switch(1) at the start instead of
> #switch(MyClock), but better yet, leave the #switch(MyClock) and replace
> the #case() statements with, for example, statements like #range(0,1).

It worked even without the changes!
Thanks,
OpalPlanet


Post a reply to this message

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