3 easy steps to an animation in POV-Ray

© and written by GRUMET Lukas | http://www.thespacebetweenus.com

Alright, please let me clear a few things at first. I won't explain the very basics in this tutorial, so if you haven't ever worked with pov-ray before, i strongly recommend that you have a look on a tutorial like PHONG's or Slime's.

Okay, let us start.

1st step:


Make a random object like a box or a torus, whatever you want. I have created a simple box.

source code:

camera { location <3, 3,3> look_at <0,0,0> }
light_source{ <4,10,0> rgb<1,1,1>}


box {

<-1,-1,-1>, <1,1,1>

translate <0,0,0> texture { pigment { rgb <1, 1, 1> } } }


2nd step:


This looks boring, right? time to animate it.

For an animation, you always need a clock variable. It is "the key to it all", say the authors of the online documentation on povray.org.
The clock variable can be inserted for example in the "translate" or on in the "rotate" tag.

At first, we will try to rotate the box, so therefore we will add the clock variable to the "rotate" tag, which would look like this:

source code:

camera { location <3, 3,3> look_at <0,0,0> }


light_source{ <4,10,0> rgb<1,1,1>}


box {

<-1,-1,-1>, <1,1,1>

translate <0,0,0> texture { pigment { rgb <1, 1, 1> }} rotate <-clock*360, 0, 0>}


As you can see, i added the "rotate" tag to the box, and in it's coordinates, I inserted the clock variable. This means the box rotates -360°(replace the - through a +, then it will rotate in the opposite direction) around the X-axis and 0° around the y- and z-axis (if you want it to rotate around an other axis, just insert the variable in the axis-value you want it to rotate).
Ok. Don't push the "Run-Button" yet, because you won't get anything special. Save your file as "stepstoanimation.pov".

3rd step:


Now we need an .ini file, where we can define how much frames we want to raytrace and how often the box should be rotated.

Create a new file and save it as: "animation.ini" and please save it into the same folder where you have put in your .pov file
Well done, so far;We are nearly finished.

At first we have to tell the ini file, which file it should raytrace when it is finished. This is done by the following code:

source code:

Input_File_Name=stepstoanimation.pov

Our input-file-name is our "stepstoanimation.pov" of course.
Right, now we just have to tell the ini file where the clock should start and how much frames it renders:

source code:

Initial_Frame = 1
Final_Frame = 30
Initial_Clock = 0.0
Final_Clock = 1.0

Initial_Frame tells the ini file where(on which frame) it should start to ray trace.
Final_Frame says where to end the animation. So, this is the number of frames you can adjust.
Initial_Clock defines where the clock starts.
Final_Clock defines where to end the clock. For example: If you set it's value t0 2.0, the box will rotate 2 times.

Once again, the full source code of the ini file:

source code:

Input_File_Name=stepstoanimation.pov

Initial_Frame = 1
Final_Frame = 30
Initial_Clock = 0.0
Final_Clock = 1.0

Now press the "RUN" button!
Have a look at your folder where you have saved your .pov file. Now, there should be all the frames-Now, add them together with a program like Image Ready, or something else.

Congratulations! Now you should have understand the basics of an animation. Read on, if you want to know how the motion works. Play around with the values above, i hope you will get what you want.

How to move an object:

Ok, we keep our source code as it is, BUT we remove the rotate tag and expand the "translation" tag a bit.

source code:

camera { location <3, 3,3> look_at <0,0,0> }


light_source{ <4,10,0> rgb<1,1,1>}


box {

<-1,-1,-1>, <1,1,1>

translate <pi, 1, 0>
translate <2*pi*clock, 0, 0>
texture { pigment { rgb <1, 1, 1> }}
}

As you can see we have got 2 "translate" tags in the code. The first one tells POV-Ray where to start, the second one, where to end. You need "pi" and "pi*clock".
Save this file as "stepstoanimation-translate.pov", then switch back to our .ini file and change the input settins to our new "stepstoanimation-translate.pov" file.
Then you should get something like this:


You can also mix the "rotate" and "translate" tag; below is an example:

camera { location <3, 3,3> look_at <0,0,0> }


light_source{ <4,10,0> rgb<1,1,1>}


box {

<-1,-1,-1>, <1,1,1>

translate <-4*pi, 0, 0>
translate <8*pi*clock, 0, 0> rotate <-clock*360, 0, 0>
texture { pigment { rgb <1, 1, 1> }}



That's all folks. These are the most common animation tags in POV-Ray. I hope this tutorial could help you, and if you have got any more questions, feel free to mail me.
You can grab the zip file containing the POV files and the INI file here

your pal
-mas

Valid XHTML 1.0! Valid CSS!