POV-Ray : Newsgroups : povray.newusers : Rotation then Translation inside an animation Server Time
28 Apr 2024 17:26:54 EDT (-0400)
  Rotation then Translation inside an animation (Message 1 to 6 of 6)  
From: Romain
Subject: Rotation then Translation inside an animation
Date: 1 Apr 2014 05:20:01
Message: <web.533a82fdeb8b8f69281b7210@news.povray.org>
Hello everyone,

I started to use POV-Ray to create some mesh animation. I'd like to make an
animation like this:
 - During the first 15 frames, make a rotation on Y-axis.
 - During the last 15 frames, make a translation on X-axis.

I did something like this:

mesh {
 .... //My triangles

#if (frame_number < 15)
   rotate < 0, clock*360, 0 >
#else
   translate < clock*5, 0, 0 >
#end
}

The problem with this, is that I don't save the state of the rotation so my
translation is done on the wrong state.

I tried to declare some variables (in .ini or .pov) but, like I though, their
values are resetting for each frames.

Can we save the previous transformation applied on one object?

Thank you.

Romain


Post a reply to this message

From: scott
Subject: Re: Rotation then Translation inside an animation
Date: 1 Apr 2014 06:26:45
Message: <533a9465$1@news.povray.org>
On 01/04/2014 10:15, Romain wrote:
> Hello everyone,
>
> I started to use POV-Ray to create some mesh animation. I'd like to make an
> animation like this:
>   - During the first 15 frames, make a rotation on Y-axis.
>   - During the last 15 frames, make a translation on X-axis.
>
> I did something like this:
>
> mesh {
>   .... //My triangles
>
> #if (frame_number < 15)
>     rotate < 0, clock*360, 0 >
> #else
>     translate < clock*5, 0, 0 >
> #end
> }
>
> The problem with this, is that I don't save the state of the rotation so my
> translation is done on the wrong state.
>
> I tried to declare some variables (in .ini or .pov) but, like I though, their
> values are resetting for each frames.
>
> Can we save the previous transformation applied on one object?

If I understand correctly what you want to do, then you can just add an 
additional rotate line into the #else block to do the same rotation as 
in frame 14:

  #if (frame_number < 15)
      rotate < 0, clock*360, 0 >
  #else
      rotate <0,clockAtFrame14*360,0>
      translate < clock*5, 0, 0 >
  #end

BTW, is it wise to mix frame_number and clock? I would stick to using 
just one or the other, as at some point you might want to change the 
frames per second the animation is rendered at. Do you really want the 
rotation to last 15 frames regardless of the frame rate, or a fixed 
amount of time?


Post a reply to this message

From: Romain
Subject: Re: Rotation then Translation inside an animation
Date: 1 Apr 2014 09:45:00
Message: <web.533ac1f4e4fdc502281b7210@news.povray.org>
scott <sco### [at] scottcom> wrote:
> On 01/04/2014 10:15, Romain wrote:
> > Hello everyone,
> >
> > I started to use POV-Ray to create some mesh animation. I'd like to make an
> > animation like this:
> >   - During the first 15 frames, make a rotation on Y-axis.
> >   - During the last 15 frames, make a translation on X-axis.
> >
> > I did something like this:
> >
> > mesh {
> >   .... //My triangles
> >
> > #if (frame_number < 15)
> >     rotate < 0, clock*360, 0 >
> > #else
> >     translate < clock*5, 0, 0 >
> > #end
> > }
> >
> > The problem with this, is that I don't save the state of the rotation so my
> > translation is done on the wrong state.
> >
> > I tried to declare some variables (in .ini or .pov) but, like I though, their
> > values are resetting for each frames.
> >
> > Can we save the previous transformation applied on one object?
>
> If I understand correctly what you want to do, then you can just add an
> additional rotate line into the #else block to do the same rotation as
> in frame 14:
>
>   #if (frame_number < 15)
>       rotate < 0, clock*360, 0 >
>   #else
>       rotate <0,clockAtFrame14*360,0>
>       translate < clock*5, 0, 0 >
>   #end
>
> BTW, is it wise to mix frame_number and clock? I would stick to using
> just one or the other, as at some point you might want to change the
> frames per second the animation is rendered at. Do you really want the
> rotation to last 15 frames regardless of the frame rate, or a fixed
> amount of time?

Thanks you for your very quick answer.

I'd like to have a rotation in a fixed amount of time. But I'm not sure how to
do this without the fps.
Is it possible?

For now, I did something like that:
in .pov:
#declare MyClock=Start + (End-Start)*clock;

#if (MyClock < 2.5)
 rotate< 0, clock*360, 0 >
#else
 #declare previousClock = 2.5 * fps / final_frame;
 rotate < 0, previousClock*360, 0 >
 translate < clock*5, 0, 0 >
#end

in .ini:
Initial_Frame=1
Final_Frame=150
Initial_Clock=0
Final_Clock=1

Declare=fps=30
Declare=Start=0;
Declare=End=5;


This script works but I don't know if it's the best solution.


Post a reply to this message

From: scott
Subject: Re: Rotation then Translation inside an animation
Date: 1 Apr 2014 10:28:14
Message: <533accfe@news.povray.org>
> I'd like to have a rotation in a fixed amount of time. But I'm not sure how to
> do this without the fps.
> Is it possible?

I always use "clock" to be the number of seconds in the animation, so in 
your example I would put:

Initial_Clock=0
Final_Clock=5
Initial_Frame=1
Final_Frame=150

If you then decide you want to render at 60fps you only need to change 
Final_Frame. I try to avoid using anything based on the frame_number or 
fps unless really needed.

In your scene you can then write:

  #if (clock < 2.5)
    rotate< 0, clock*360, 0 >
  #else
    #declare previousClock = 2.5;
    rotate < 0, previousClock*360, 0 >
    translate < (clock-2.5)*5, 0, 0 >
  #end

I also changed the translate distance to (clock-2.5)*5, otherwise you'll 
get a jump at 2.5 seconds.


Post a reply to this message

From: Romain
Subject: Re: Rotation then Translation inside an animation
Date: 1 Apr 2014 11:10:00
Message: <web.533ad609e4fdc502281b7210@news.povray.org>
scott <sco### [at] scottcom> wrote:
> I always use "clock" to be the number of seconds in the animation, so in
> your example I would put:
>
> Initial_Clock=0
> Final_Clock=5
> Initial_Frame=1
> Final_Frame=150
>
> If you then decide you want to render at 60fps you only need to change
> Final_Frame. I try to avoid using anything based on the frame_number or
> fps unless really needed.
>
> In your scene you can then write:
>
>   #if (clock < 2.5)
>     rotate< 0, clock*360, 0 >
>   #else
>     #declare previousClock = 2.5;
>     rotate < 0, previousClock*360, 0 >
>     translate < (clock-2.5)*5, 0, 0 >
>   #end
>
> I also changed the translate distance to (clock-2.5)*5, otherwise you'll
> get a jump at 2.5 seconds.

Thank you.
I'm going to use you're method which is easier than mine :)

I start (finally) to understand how POV-Ray animation works.

Thanks so much again!


Post a reply to this message

From: Warp
Subject: Re: Rotation then Translation inside an animation
Date: 1 Apr 2014 11:58:33
Message: <533ae228@news.povray.org>
Romain <nomail@nomail> wrote:
> I'm going to use you're method which is easier than mine :)

If you need to "collect" lots of transformations like that, rather than
having to repeat all previous transformations in increasingly-nested
#else blocks, you can literally collect them into one single transform
variable, which you can then apply to your object.

Also, you may want to use the min() function instead of #if blocks,
as it makes it much simpler.

For example like this:

#declare Tr = transform { rotate <0, min(clock, 2.5)*360, 0> };
#declare Tr = transform { Tr translate <min(clock-2.5, 2.5)*5, 0, 0> };
#declare Tr = transform { rotate <0, min(clock-5.0, 2.5)*360, 0> };

...

  object
  {
    YourObject
    transform { Tr }
  }

-- 
                                                          - Warp


Post a reply to this message

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