For this tutorial, we will make two uses of the text object. First, let's just make some block letters sitting on a checkered plane. Any TTF font should do, but for this tutorial, we will use the ones bundled with POV-Ray 3.0.
Create a file called textdemo.pov and edit it as follows:
Now let's add the text object. We will use the font timrom.ttf and we will create the string POV-RAY 3.0 . For now, we will just make the letters red. The syntax is very simple. The first string in quotes is the font name, the second one is the string to be rendered. The two floats are the thickness and offset values. The thickness float determines how thick the block letters will be. Values of .5 to 2 are usually best for this. The offset value will add to the kerning distance of the letters. We will leave this a 0 for now.
Rendering this at 200x150 -A , we notice that the letters are off to the right of the screen. This is because they are placed so that the lower left front corner of the first letter is at the origin. To center the string we need to translate it -x some distance. But how far? In the docs we see that the letters are all 0.5 to 0.75 units high. If we assume that each one takes about 0.5 units of space on the x-axis, this means that the string is about 6 units long (12 characters and spaces). Let's translate the string 3 units along the negative x-axis.
That's better. Now let's play around with some of the parameters of the text object. First, let's raise the thickness float to something outlandish... say 25!
Actually, that's kind of cool. Now let's return the thickness value to 1 and try a different offset value. Change the offset float from 0 to 0.1 and render it again.
Wait a minute?! The letters go wandering off up at an angle! That is not what the docs describe! It almost looks as if the offset value applies in both the x- and y-axis instead of just the x axis like we intended. Could it be that a vector is called for here instead of a float? Let's try it. Replace 0.1 with 0.1*x and render it again.
That works! The letters are still in a straight line along the x axis, just a little further apart. Let's verify this and try to offset just in the y axis. Replace 0.1*x with 0.1*y . Again, this works as expected with the letters going up to the right at an angle with no additional distance added along the x axis. Now let's try the z axis. Replace 0.1*y with 0.1*z . Rendering this yields a disappointment. No offset occurs! The offset value can only be applied in the x and y directions.
Let's finish our scene by giving a fancier texture to the block letters, using that cool large thickness value, and adding a slight y offset. For fun, we will throw in a sky sphere, dandy up our plane a bit, and use a little more interesting camera viewpoint (render the following scene at 640x480 +A0.2 ):
Now. let's try using text in a CSG object. We will attempt to create an inlay in a stone block using a text object. Create a new file called textcsg.pov and edit it as follows:
Now let's create the block. We want it to be about eight units across because our text string ( POV-RAY 3.0 ) is about six units long. We also want it about four units high and about one unit deep. But we need to avoid a potential coincident surface with the text object so we will make the first z coordinate 0.1 instead of 0. Finally, we will give this block a nice stone texture.
Next, we want to make the text object. We can use the same object we used in the first turorial except we will use slightly different thickness and offset values.
Remember that the text object is placed by default so that its front surface lies directly on the x-y-plane. If the front of the box begins at z=0.1 and thickness is set at 0.15, the depth of the "inlay" will be 0.05 units. Go ahead and place a difference block around the two objects.
Render this at 200x150 -A . We can see the inlay clearly and that it is indeed a bright gold color. Render this at 640x480 +A0.2 to see the results more clearly, but be forewarned... this trace will take a little time.
Create a file called tordemo.pov . Edit it as follows:
Go ahead and trace this. Well, it's a donut allright. Let's try changing the major and minor radius values and see what happens. Change them as follows:
That looks more like a hula-hoop! Let's try this:
Whoa! A donut with a serious weight problem!
With such a simple syntax, there isn't much else you can do to a torus besides change its texture... or is there? Let's see...
Torus' are very useful objects in CSG. Let's try a little experiment. Make a difference of a torus and a box:
Interesting... a half-torus. So? So, now add another one flipped the other way. Only, let's declare the original half-torus and the necessary transformations so we can use them again:
Now create a union of two Half_Torus objects:
This makes an S -shaped object, but we can't see the whole thing from our present camera. Let's add a few more links, three in each direction, move the object along the +z direction and rotate it about the +y axis so we can see more of it. We also notice that there appears to be a small gap where the Half_Torus' meet. This is due to the fact that we are viewing this scene from directly on the x-z plane. We will change the camera y coordinate from 0 to 0.1 to eliminate this.
Rendering this we see a cool, undulating, snake-like something-or-other. Neato. But we want to model something useful, something that we might see in real life. How about a chain?
Thinking about it for a moment, we realize that a single link of a chain can be easily modeled using two half toruses and two cylinders. Go ahead and create a new file. You can use the same camera, background, light source, and declared objects and transformations as you used in tordemo.pov :
Now, make a complete torus of two half toruses:
This may seem like a wasteful way to make a complete torus, but we are really going to move each half apart to make room for the cylinders. First, add the declared cylinder before the union:
Then add two Chain_Segments to the union and translate them so that they line up with the minor radius of the torus on each side:
Now translate the two half toruses +y and -y so that the clipped ends meet the ends of the cylinders. This distance is equal to half of the previously declared Torus_Translate :
Render this and voila! A single link of a chain. But we aren't done yet! Whoever heard of a green chain? We would rather use a nice metallic color instead. First, remove any pigment blocks in the declared toruses and cylinders. Then add the following before the union:
Then add the texture to the union and declare the union as a single link:
Now make a union of two links. The second one will have to be translated +y so that its inner wall just meets the inner wall of the other link, just like the links of a chain. This distance turns out to be double the previously declared Torus_Translate minus 2 (twice the minor radius). This can be described by the expression:
Declare this expression as follows:
In the object block, we will use this declared value so that we can multiply it to create other links. Now, rotate the second link 90*y so that it is perpendicular to the first, just like links of a chain. Finally, scale the union by 1/4 so that we can see the whole thing:
Render this and you will see a very realistic pair of links. If we want to make an entire chain, we must declare the above union and then create another union of this declared object. Be sure to remove the scaling from the declared object:
Now declare your chain:
And, finally create your chain with a couple of transformations to make it easier to see. These include scaling it down by a factor of 1/10, and rotating it so that you can clearly see each link:
Render this and you should see a very realistic gold chain stretched diagonally across the screen.