Section 4.4.2
Blob Object

[ *** STILL BEING WRITTEN *** Dieter Bayer ]

Section 4.4.3
Height Field Object

A height field is an object that has a surface that is determined by the color value or palette index number of an image designed for that purpose. With height fields, realistic mountains and other types of terrain can easily be made. First, you need an image from which to create the height field. It just so happens that POV-Ray is ideal for creating such an image.

Make a new file called image.pov and edit it to contain the following:

#include "colors.inc" global_settings { assumed_gamma 2.2 hf_gray_16 }

The hf_gray_16 keyword causes the output to be in a special 16 bit grayscale that is perfect for generating height fields. The normal 8 bit output will lead to less smooth surfaces.

Now create a camera positioned so that it points directly down the z-axis at the origin.

camera { location <0, 0, -10> look_at 0 }

Then create a plane positioned like a wall at z=0. This plane will completely fill the screen. It will be colored with white and gray wrinkles.

plane { z, 10 pigment { wrinkles color_map { [0 0.3*White] [1 White] } } }

Finally, create a light source.

light_source { <0, 20, -100> color White }

Render this scene at 640x480 +A0.1 +FT . You will get an image that will produce an excellent height_field.

Now we will use this image to create a height field. Create a new file called hfdemo.pov and edit it as follows:

#include "colors.inc"

Add a camera that is two units above the origin and ten units back ...

camera{ location <0, 2, -10> look_at 0 angle 15 }

... and a light source.

light_source{ <1000,1000,-1000> White }

Now add the height field. In the following syntax, a Targa image file is specified, the height field is smoothed , it is given a simple white pigment, it is translated to center it around the origin, and it is scaled so that it resembles mountains and fills the screen.

height_field { tga "image.tga" smooth pigment { White } translate <-.5, -.5, -.5> scale <17, 1.75, 17> }

Save the file and render it at 320x240 -A . Later, when you are satisfied that the height field is the way you want it render it at a higher resolution with antialiasing.


A height field created completely with POV-Ray.

Wow! The Himalayas have come to your computer screen!


Section 4.4.4
Julia Fractal Object

[ *** STILL BEING WRITTEN *** ]

Section 4.4.5
Lathe Object

[ *** STILL BEING WRITTEN *** Dieter Bayer ]

Section 4.4.6
Mesh Object

Mesh objects are very useful because they allow you to create objects containing hundreds or thousands of triangles. Compared to a simple union of triangles the mesh object stores the triangles more efficiently. Copies of mesh objects need only a little additional memory because the triangles are stored only once.

Almost every object can be approximated using triangles but you may need a lot of triangles to create more complex shapes. Thus we will only create a very simple mesh example. This example will show a very useful feature of the triangles meshs though: a different texture can be assigned to each triangle in the mesh.

Now let us start. We'll create a simple box with differently colored sides. Create an empty file called meshdemo.pov and add the following lines.

camera { location <20, 20, -50> look_at <0, 5, 0> } light_source { <50, 50, -50> color rgb<1, 1, 1> } #declare Red = texture { pigment { color rgb<0.8, 0.2, 0.2> } finish { ambient 0.2 diffuse 0.5 } } #declare Green = texture { pigment { color rgb<0.2, 0.8, 0.2> } finish { ambient 0.2 diffuse 0.5 } } #declare Blue = texture { pigment { color rgb<0.2, 0.2, 0.8> } finish { ambient 0.2 diffuse 0.5 } }

We must declare all textures we want to use inside the mesh before the mesh is created. Textures cannot be specified inside the mesh due to the worser memory performance that would result.

Now add the mesh object. Three sides of the box will use individual textures while the other will use the "global" mesh texture.

mesh { /* top side */ triangle { <-10, 10, -10>, <10, 10, -10>, <10, 10, 10> texture { Red } } triangle { <-10, 10, -10>, <-10, 10, 10>, <10, 10, 10> texture { Red } } /* bottom side */ triangle { <-10, -10, -10>, <10, -10, -10>, <10, -10, 10> } triangle { <-10, -10, -10>, <-10, -10, 10>, <10, -10, 10> } /* left side */ triangle { <-10, -10, -10>, <-10, -10, 10>, <-10, 10, 10> } triangle { <-10, -10, -10>, <-10, 10, -10>, <-10, 10, 10> } /* right side */ triangle { <10, -10, -10>, <10, -10, 10>, <10, 10, 10> texture { Green } } triangle { <10, -10, -10>, <10, 10, -10>, <10, 10, 10> texture { Green } } /* front side */ triangle { <-10, -10, -10>, <10, -10, -10>, <-10, 10, -10> texture { Blue } } triangle { <-10, 10, -10>, <10, 10, -10>, <10, -10, -10> texture { Blue } } /* back side */ triangle { <-10, -10, 10>, <10, -10, 10>, <-10, 10, 10> } triangle { <-10, 10, 10>, <10, 10, 10>, <10, -10, 10> } texture { pigment { color rgb<0.9, 0.9, 0.9> } finish { ambient 0.2 diffuse 0.7 } } }

Trace the scene at 320x240. You'll see that the top, right, and front side of the box have different textures. Thought this is not a very impressive example it shows what you can do with mesh objects. More complex examples, also using smooth triangles, can be found under the scene directory as chesmsh.pov and robotmsh.pov .


Section 4.4.7
Polygon Object

The polygon object can be used to create any planar, n-sided shapes like squares, rectangles, pentagons, hexagons, octagons, etc.

A polygon is defined by a number of points that describe its shape. Since polygons have to be closed the first point has to be repeated at the end of the point sequence.

In the following example we will create the word POV using just one polygon statement.

We start with thinking about the points we need to describe the desired shape. We want the letters to lie in the x-y-plane with the letter O being at the center. The letters extend from y=0 to y=1. Thus we get the following points for each letter (the z coordinate is automatically set to zero).

Letter P (outer polygon): 
    <-0.8, 0.0>, <-0.8, 1.0>, 
    <-0.3, 1.0>, <-0.3, 0.5>, 
    <-0.7, 0.5>, <-0.7, 0.0>
 
Letter P (inner polygon): 
    <-0.7, 0.6>, <-0.7, 0.9>, 
    <-0.4, 0.9>, <-0.4, 0.6>
   
Letter O (outer polygon):
    <-0.25, 0.0>, <-0.25, 1.0>,
    < 0.25, 1.0>, < 0.25, 0.0>
   
Letter O (inner polygon):
    <-0.15, 0.1>, <-0.15, 0.9>,
    < 0.15, 0.9>, < 0.15, 0.1>
   
Letter V:
    <0.45, 0.0>, <0.30, 1.0>, 
    <0.40, 1.0>, <0.55, 0.1>, 
    <0.70, 1.0>, <0.80, 1.0>,
    <0.65, 0.0>

Both letters P and O have a hole while the letter V consists of only one polygon. We'll start with the letter V because it is easier to define than the other two letters.

Create a new file called polygdem.pov and add the following text.

camera { orthographic location <0, 0, -10> right 1.3 * 4/3 * x up 1.3 * y look_at <0, 0.5, 0> } light_source { <25, 25, -100> color rgb 1 } polygon { 8, <0.45, 0.0>, <0.30, 1.0>, // Letter "V" <0.40, 1.0>, <0.55, 0.1>, <0.70, 1.0>, <0.80, 1.0>, <0.65, 0.0>, <0.45, 0.0> pigment { color rgb <1, 0, 0> } }

As noted above the polygon has to be closed by appending the first point to the point sequence. A closed polygon is always defined by a sequence of points that ends when a point is the same as the first point.

After we have created the letter V we'll continue with the letter P . Since it has a hole we have to find a way of cutting this hole into the basic shape. This is quite easy. We just define the outer shape of the letter P , which is a closed polygon, and add the sequence of points that describes the hole, which is also a closed polygon. That's all we have to do. There'll be a hole where both polygons overlap.

In general you'll get holes whenever an even number of sub-polygons inside a single polygon statement overlap. A sub-polygon is defined by a closed sequence of points.

The letter P consists of two sub-polyons, one for the outer shape and one for the hole. Since the hole polygon overlaps the outer shape polygon we'll get a hole.

After you've understood how multiple sub-polygons in a single polygon statement work, it's quite easy to add the missing O letter.

Finally, we get the complete word POV .

polygon { 30, <-0.8, 0.0>, <-0.8, 1.0>, // Letter "P" <-0.3, 1.0>, <-0.3, 0.5>, // outer shape <-0.7, 0.5>, <-0.7, 0.0>, <-0.8, 0.0>, <-0.7, 0.6>, <-0.7, 0.9>, // whole <-0.4, 0.9>, <-0.4, 0.6>, <-0.7, 0.6> <-0.25, 0.0>, <-0.25, 1.0>, // Letter "O" < 0.25, 1.0>, < 0.25, 0.0>, // outer shape <-0.25, 0.0>, <-0.15, 0.1>, <-0.15, 0.9>, // whole < 0.15, 0.9>, < 0.15, 0.1>, <-0.15, 0.1>, <0.45, 0.0>, <0.30, 1.0>, // Letter "V" <0.40, 1.0>, <0.55, 0.1>, <0.70, 1.0>, <0.80, 1.0>, <0.65, 0.0>, <0.45, 0.0> pigment { color rgb <1, 0, 0> } }


The word "POV" made with one polygon statement.


Next Section
Table Of Contents