The Export to POV-Ray option will save the automaton as a set of files that can be read and rendered by POV-Ray.
POV-Ray is a freeware ray tracer which is available on all major platforms. In Windows, there is a very nice and easy to use
user interface. Most Linux implementations have a command line version that is included in the distribution.
When you select the POV-Ray Exporter option the following dialog box will appear.
First, select the output filenames by clicking Browse, navigate to the directory in which you wish to save the files and then type in the filename of the pov file. The program will take the name and create three filenames. The main pov file will simply have the .pov extension, the model file which will be the input name with _Model.inc at the end and finally the .ini file. The pov file will contain the scene layout, the inc file will contain the automaton information and the ini file will contain the animation information. Note that the ini file is created only if you select one of the animation options.
When either of the animation options are selected the POV-Ray Exporter will also produce an ini file. To render an animation you will render the ini file and not the pov file. We will discuss rendering and animation options later.
Simply select the color scheme you wish to start with and the one you wish to end with. Note that if you do not have at least two color schemes loaded when you select the POV-Ray Exporter this option will not be available to you.
To render the POV-Ray image you will, of course, need the POV-Ray application. A command-line version of POV-Ray is normally included in most Linux distributions and the most current versions for all major platforms can be found at the POV-Ray web site at http://www.povray.org/. The Windows version is very easy to use and includes a nice user interface with menus and toolbars.
On a Windows system simply load in the pov file (or ini file if doing an animation) and click on the Run button. Once you do POV-Ray will render the image and save the image as a bitmap file in the same folder as your pov file. If you are running an animation then POV-Ray will save a sequence of bitmap files, one for each frame in the animation. Note that POV-Ray will not create a movie file of the animation, you will need to paste the images together with another program.
On a Unix or Linux system using a command-line version you can get a list of flags by simply typing povray into the console or by checking the man pages. For example, if the pov file is Aut.pov you can render a 640X480 image using antialiasing by
povray -W640 -H480 -A0.3 Aut.pov
On a Unix or Linux system POV-Ray will save the image as a png file instead of a bitmap file.
Although you do not need to know anything about POV-Ray programming to use
this feature, we have set up the POV-Ray files so that they are easy to manipulate.
For example, the pov file looks something like the following,
// POV-Ray output from PascGalois JE
// Constants
#declare PI = 3.14159265358979323846;
#declare PI_DIV_180 = 0.017453292519943296;
#declare deg = PI_DIV_180;
background { <0,0,0> }
// User Editable Values
#declare theta = 81.22905;
#declare phi = -0.61676615;
#declare r = 2.073058068752289;
#declare CamPosX = r*cos(phi*deg)*sin(theta*deg);
#declare CamPosY = r*sin(phi*deg);
#declare CamPosZ = r*cos(phi*deg)*cos(theta*deg);
#declare LookAtX = 0.0;
#declare LookAtY = 0.0;
#declare LookAtZ = 0.0;
#declare UpX = 0.0;
#declare UpY = 1.0;
#declare UpZ = 0.0;
#declare L1_theta = 20;
#declare L1_phi = 10;
#declare L1_r = 20;
#declare L2_theta = 70;
#declare L2_phi = 30;
#declare L2_r = 20;
#declare Spot_theta = 30;
#declare Spot_phi = 80;
#declare Spot_r = 40;
#declare SpotPoint_theta = 0;
#declare SpotPoint_phi = 0;
#declare SpotPoint_r = 0;
#declare SpotRadius = 10;
#declare SpotFalloff = 15;
// Scene
camera {
location <CamPosX, CamPosY, CamPosZ>
angle 50
sky <UpX, UpY, UpZ>
look_at <LookAtX, LookAtY, LookAtZ>
}
light_source { <L1_r*cos(L1_phi*deg)*cos(L1_theta*deg),
L1_r*sin(L1_phi*deg),
L1_r*cos(L1_phi*deg)*sin(L1_theta*deg)>
color <1,1,1>
}
light_source { <L2_r*cos(L2_phi*deg)*cos(L2_theta*deg),
L2_r*sin(L2_phi*deg),
L2_r*cos(L2_phi*deg)*sin(L2_theta*deg)>
color <1,1,1>
}
light_source { <Spot_r*cos(Spot_phi*deg)*cos(Spot_theta*deg),
Spot_r*sin(Spot_phi*deg),
Spot_r*cos(Spot_phi*deg)*sin(Spot_theta*deg)>
color <1,1,1>
spotlight
radius SpotRadius
falloff SpotFalloff
point_at <SpotPoint_r*cos(SpotPoint_phi*deg)*cos(SpotPoint_theta*deg),
SpotPoint_r*sin(SpotPoint_phi*deg),
SpotPoint_r*cos(SpotPoint_phi*deg)*sin(SpotPoint_theta*deg)>
}
light_source { <CamPosX, CamPosY, CamPosZ>
color <1,1,1>
}
plane { <0, 1, 0>, -0.375
pigment { color rgb <.2,.2,.4> }
finish { reflection {0.25} phong 0.4 }
}
#include "Aut_Model.inc"
object { aut_output }
If you are using a spherical coordinate camera then the first three lines under
the User Editable Values are the spherical coordinates of the camera.
// User Editable Values
#declare theta = 81.22905;
#declare phi = -0.61676615;
#declare r = 2.073058068752289;
On the other hand if you are using a Yaw-Pitch-Roll camera
the position will be given in rectangular coordinates.
#declare CamPosX = 0.28307894;
#declare CamPosY = -0.0908582;
#declare CamPosZ = -0.07512487;
Keep in mind that POV-Ray uses a left-hand coordinate system with the positive y-axis in the up direction and the positive x-axis moving off to the right.
The three lines declaring variables that start with L1 are spherical coordinates of light number 1 and the three starting with L2 are spherical coordinates of light number 2. If you included the spotlight then the rest of the declaration statements are the spherical coordinates of the position and the point-at point. The final two are the radius and fall-off of the spotlight.
You may edit any of these values to change the camera and light positions and
if you want to narrow the spotlight simply decrease the values of
#declare SpotRadius = 10;
#declare SpotFalloff = 15;
For example, in the images below we used the default values
for the first image and then changed these values to 1 and 2 respectively for the
second image.
POV-Ray uses the same syntax as C for comments, so anything following a // is not rendered and anything between /* and */ is not rendered.
The Scene section of the pov file should, for the most part, not be edited,
since most of it simply changes spherical coordinates to rectangular coordinates.
There are however a couple numbers that you may wish to change. For example,
you can comment out an entire object (like a light_source) by using the comment
tags discussed above. In the camera section the angle 50
sets the angle of view of the camera to 50 degrees, you may wish to increase or
decrease this number. You will also note that the colors for the lights are
color <1,1,1>
, which is bright white. The syntax for the colors
is color <r,g,b>
where r, g and b are the red, green and blue
components of the color. Each of r, g and b should be numbers between 0 and 1.
So if you would prefer a red light you can edit the color to
color <1,0,0>
. You can also change the intensity of a
color by multiplying the vector by a constant. For example,
color 0.7*<1,0,0>
will produce a white light at 70%
intensity. Finally, if you included the base plane the values
reflection {0.25} phong 0.4
control the amount of reflection and shine the surface has. You can set these to any number between 0 and 1.
The ini files are very easy to update. If you do an animation then the ini
file should look something like this.
Input_File_Name="Aut.pov"
Initial_Frame = 1
Final_Frame = 360
This simply creates 360 frames in the animation. To change the number of animation frames just change the value of Final_Frame.
The final file is the model file, which contains the model of the automaton,
the color scheme and some variables that are used in an animation. Of these the
only one you may wish to change is the aut_phong
value. This controls
the amount of shine that is on the object.
// POV-Ray output from PascGalois JE
// Constants and Animation Variables
#local PI = 3.14159265358979323846;
#local r = 0.0125;
#local dr = cos(clock*PI/2)*r;
#local ir = cos(PI/2-clock*PI/2)*r;
#local aut_phong = 0.5;
#local fin = finish { phong aut_phong };
#local inc_aut_phong = clock*aut_phong;
#local ifin = finish { phong inc_aut_phong };
#local dec_aut_phong = (1-clock)*aut_phong;
#local dfin = finish { phong dec_aut_phong };
// Colors
#local c1 = pigment { color rgb <1.0, 0.0, 0.0> };
#local c2 = pigment { color rgb <0.0, 1.0, 0.0> };
#local c3 = pigment { color rgb <0.0, 0.0, 1.0> };
#local c4 = pigment { color rgb <1.0, 1.0, 0.0> };
// Automaton Model
#declare aut_output = union{
sphere {<0.0, 0.3875, 0.0>, r texture{c1 fin}}
sphere {<-0.025, 0.36250000000000004, 0.0>, r texture{c1 fin}}
sphere {<0.0, 0.36250000000000004, -0.025>, r texture{c1 fin}}
...
The saving of the POV-Ray file is done in a separate thread of execution. What this means is that you can keep working while the program saves the file in the background, which is good. On the other hand, if you close the program too quickly after you save the POV-Ray file and the automaton is very large it is possible that you may truncate the model file. Under most circumstances this will not happen but if you are saving a large automaton you may want to use a file browser to make sure the model file is not increasing in size before you close the program.