CLOCK MODIFIER INCLUDE FILE for Persistence of Vision 3.x

Created by Chris Colefax, 24 June 1997
Updated 7 August 1998: updated for POV-Ray 3.1


INSTALLATION

QUICK START

CLOCK TYPES

CLOCK MODIFICATION OPTIONS

USING THE CLOCK MODIFICATION PREVIEW

USING THE mclock VARIABLE

COPYRIGHT AND LEGAL INFORMATION

CONTACTING THE AUTHOR


INSTALLATION
The Clock Modifier consists of two files, ClockMod.inc and ClockP.inc which should be copied to one of the directories (folders) in your POV-Ray library path. Normally this is the INCLUDE sub-directory of the directory where you installed POV-Ray, so if you installed POV-Ray in C:\POVRAY you should copy the files to C:\POVRAY\INCLUDE. On a Windows 95 system, this is probably something like:

C:\Program Files\POV-Ray for Windows\Include

On UNIX and similar systems, where filenames are case-sensitive, you may have to rename the include files so the capitals and lowercase are as shown above. This will enable you to render the sample files without modification.


QUICK START
POV-Ray animation is usually achieved using the clock variable. While this concept is quite simple, it can also be very frustrating. Even trying to animate the most basic of scenes often requires you to know and use a lot of complicated mathematical functions. With the Clock Modifier include file you can choose from a whole variety of different clock types, such as Acceleration, Deceleration, Recoil, and Bounce, and use them to animate objects, light_sources, etc. in all sorts of different ways. Using a modified clock value is as simple as declaring the name of the desired modification, and then including ClockMod.inc, eg:

#declare clock_type = "Wave"
#include "ClockMod.inc"

In addition there are a variety of other options than can be used to modify and combine different clock types. To use any of these just add the following line to your scene file, before including ClockMod.inc:

#declare [variable-name] = [value]

substituting the desired variable name and value where appropriate. The Clock Modifier include file will then create a new variable, mclock, that can be used to scale, rotate, and translate objects, as well as alter their pigments and other attributes, eg:

object {MyObject
#declare clock_type = "Bounce"
translate y * mclock * 10}

Note that ClockMod.inc should never be included at the start of a scene (like colors.inc or textures.inc). It should only be included after declaring the desired clock type and options. To use the Clock Modifier more than once in a scene, you should declare the first set of options and include ClockMod.inc. Then declare the next set of options and include ClockMod.inc again.


CLOCK TYPES
The Clock Modifier include file allows you to use nine different clock types, as listed below. To use a particular clock type, you must first declare the clock_type variable as the name of the desired type. Note that you only have to use the first letter of a particular type, eg:

#declare clock_type = "O"

rather than #declare clock_type = "Oscillation". You can preview all of the available clock types by rendering the Preview.pov scene.

ACCELERATE


This clock type starts out slow and then gradually speeds up. This is very useful for animating moving objects. You can adjust the rate of acceleration using the clock_strength option. See the Anim1.pov scene for an example of this clock type.

DECELERATE


This clock type starts out fast and then slows down. You can adjust the rate of deceleration using the clock_strength variable. See the Anim1.pov scene for an example of this clock type.

S-CURVE


This clock type is like a combination of acceleration and deceleration; it starts out slow, speeds up, and then slows down again. It has many uses, such as smoothly changing the colour of an object (see the Anim3.pov scene for an example).

TRIANGLE


This clock type rises and then falls again, with sharp changes of direction. It can be used to make objects pulsate (see the Anim2.pov scene for an example).

JUMP


This clock type is similar to the Triangle clock type, but it slows down as it rises, and then speeds up again as it falls (the change of direction at the top is smooth). The clock_strength option can be used to adjust the rate of acceleration/deceleration. See the Anim3.pov scene for an example of this clock type.

BOUNCE


As the name suggests, this clock type can be used to make objects bounce. It starts out high, than falls and bounces back. The clock_strength option can be used to adjust the rate of acceleration/deceleration. See the Anim2.pov scene for an example of this clock type.

OSCILLATE


This clock type starts at 0, then rises to 1. It then falls to -1, and rises again to 0. It can be used to oscillate all sorts of objects (see the Anim2.pov scene for an example).

WAVE


This clock type is similar to the Oscillate clock type, but it starts at 0, rises to 1, and then falls back to 0. See then Anim1.pov scene for an example of this clock type.

RECOIL


This clock type can be used to animate all sorts of recoiling objects, such as firing guns, etc. The clock_strength option can be used to alter the rate of recoil. See the Anim3.pov scene for an example of this clock type.


CLOCK MODIFICATION OPTIONS
The nine basic clock modification types can be altered using the following variables.

clock_start & clock_finish


Normally the POV-Ray internal clock starts at 0 (at the beginning of the animation) and ends at 1. If you are using different clock values, you can set these using the clock_start and clock_finish variables, eg:

#declare clock_start = 0
#declare clock_finish = 100

You can also use these variables to make a particular modification occupy only part of a scene, eg:

#declare clock_type = "Accelerate"
#declare clock_start = .7

will only start accelerating 70% of the way through the animation.

clock_repeat


You can use this option to make a particular modification repeat itself during the course of an animation, eg:

#declare clock_type = "Recoil"
#declare clock_repeat = 10

could be used to make a cannon fire 10 times.

clock_strength


This option can be used to alter the rate of acceleration/deceleration of the following clock types: Accelerate, Decelerate, Jump, Bounce and Recoil. The default value is 1; numbers larger than this will increase the rate, while numbers smaller than 1 will decrease the rate, eg:

#declare clock_type = "Jump"
#declare clock_strength = 2

will make the jumping motion more apparent.

clock_combine


This option can be used to combine one clock type with another. This is most useful when using a repeated Wave or similar, eg:

#declare clock_type = "Wave"
#declare clock_repeat = 10

will give 10 waves, each taking the same length of time. If you wanted the waves to get quicker as time passed, you could combine the above with an Accelerate, eg:

#declare clock_combine = "Accelerate"

The Combine.pov scene shows how this option works. Note that if you using the Clock Modification include file more than once in a scene, and you have used clock_combine once but don't want to use it again, you should declare it as "", eg:

#declare clock_type = "Wave" #declare clock_combine = "Accelerate"
#include "ClockMod.inc"

#declare clock_combine = ""


USING THE CLOCK MODIFICATION PREVIEW
When using a variety of the above options (especially the clock_combine option) it can be very useful to see a graph of the mclock variable. You use achieve this using the ClockP.inc file; first declare the desired clock options, and then include the ClockP.inc file (do not include the ClockMod.inc file), eg:

#declare clock_type = "Recoil" #declare clock_repeat = 3
#declare clock_combine = "Decelerate" #declare clock_strength = 2
#include "ClockP.inc"

No other cameras, lights, or objects are necessary, though the following options can be used to control the clock preview.

graph_continuous


Normally the graph is plotted using spheres. If you would prefer an unbroken line graph, use this option, eg:

#declare graph_continuous = true

graph_thickness


Use this option to change the thickness of the line graph, eg:

#declare graph_thickness = .01

The default for graph_thickness is .02

graph_smoothness


Use this option to alter the number of points plotted on the graph, eg:

#declare graph_smoothness = 250

The default is 100. Increasing this option will make the graph more accurate, and is useful when you have a very complex graph (eg. many repeated oscillations).


USING THE mclock VARIABLE
This section contains a basic explanation of how to use the mclock variable to modify different objects in a variety of ways.

Note that if you are using POV-Ray 3.1 or later, you will probably want to use the Automatic Clock Modifier Macro File, which eliminates the need to perform the tasks described below.

TRANSLATING OBJECTS


Animations generally involve movement of some kind. The simplest way to move an object (or light_source, camera, etc.) is to use the translate command, eg:

object {MyObject translate <10, 10, -10>}

This will move the specified object 10 units along the x-axis, 10 units up the y-axis, and -10 units along the z-axis. If you wanted to animate the object so that it started at its current position, and then accelerated to its new position, you would use:

object {MyObject
#declare clock_type = "Accelerate"
#include "ClockMod.inc"
translate <10, 10, -10> * mclock}

Note that you can add translations together, so you can first create your object at the origin, then animate it, and finally move it into the correct position, eg:

sphere {<0, 0, 0>, 1
pigment {color Red}
#declare clock_type = "Bounce"
#include "ClockMod.inc"
translate y * mclock * 5
translate <10, 1, 20>}

This will create a red sphere that bounces 5 units high (up the y-axis), and bounces on the spot located at <10, 1, 20>.

OTHER TRANSFORMATIONS


You can use mclock with rotate and scale in the same way as with translate, eg:

object {MyObject
#declare clock_type = "Jump"
#include "ClockMod.inc"
scale mclock * 2

#declare clock_type = "Oscillate"
#include "ClockMod.inc"
rotate y * 50 * mclock}

This will make the object pulsate between its normal size and double its size, and also rotate back and forth 50 degrees around the y-axis.

PIGMENTS AND OTHER ATTRIBUTES


In addition to the transformation above, you can use the mclock variable with any POV-Ray attribute that requires a number. An example of this is pigments, eg. to make a flashing blue light:

light_source {<10, 30, -20>
#declare clock_type = "Wave"
#declare clock_repeat = 20
#include "ClockMod.inc"
color Blue * mclock}

The mclock variable can also be used in the pigment, normal and finish statements of objects, as well as when animating camera angles, etc. Often you will want to go from one value to another, eg. changing an object from Red to Green. To do this, use the following commands:

#declare clock_type = "S-Curve"
#include "ClockMod.inc"
pigment {Red + mclock * (Green - Red)}

As you can see, you start with the first value, and then add mclock multiplied by the different between the two values (which is always the second value take away the first value). If you wanted to make an object become less reflective during an animation, you could use:

#declare clock_type = "Decelerate"
#include "ClockMod.inc"
finish {reflection .8 + mclock * (.2 - .8)}

This will change the reflection from 0.8 at the start of the animation, down to 0.2 at the end.


COPYRIGHT AND LEGAL INFORMATION
The Clock Modifier Include File, including ClockMod.inc, ClockP.inc, all documentation, and associated sample *.POV files are Copyright 1997, 1998 by Chris Colefax. Full permission is granted to the user to modify any or all of the files for his/her own use. If modified versions are to be distributed the user should make clear the modifications that have been made by him/herself.

The Clock Modifier Include File may be bundled with or without other software on CD-ROM collections, Bulletin Board systems and other file archives, providing that all associated files, including documentation and samples, are included. I would also request that persons intending to distribute the Clock Modifier Include File in this manner or otherwise would first contact me to ensure that they are in possession of the latest available version.

Further, no restrictions of any sort are placed on the usage of the include files themselves (ClockMod.inc and ClockP.inc), and scene files or images created using the include files remain entirely the property of the user or users who have created them. I claim no liability or responsibility for damages or loss resulting from usage of the include files, or any part of the include file package.


CONTACTING THE AUTHOR
If you wish to contact me with bug reports, bug fixes, criticisms, comments, suggested improvements, questions, etc. you can reach me by email at:

ccolefax@geocities.com

or by regular mail at:


POV-RayTM and Persistence of VisionTM are registered trademarks of the POV-Ray TeamTM