Part 3
Geometry in POV Ray
-First off, let me explain how to make shapes interact, POV Ray calls these 'CSG Operations'. Your basic operations (there are two more, but in the years I've been doing this I've never used anything but these 4) are:
union
difference
merge
intersection
-You'll notice you've already used 'union' and 'difference', their format (but not their effect) is the same with the all CSG operations...
-First, you type out which operation you want to use (numbers refer to the examples in the image below):
-'union' makes POV Ray consider all geometry/objects/variables within that union as a single piece of geometry, so if you have a box with a cylinder going though it you will see both shapes (1).
-'difference' takes the first piece of geometry and subtracts all the following pieces from it, so if you have a box with a cylinder going though it you will see a box with a cylindrical hole in it, and you won't see the cylinder at all (2). Alternatively if you include the cylinder before the box you will only see the ends of the cylinder where it did not intersect with the box. If you had a box followed by a cylinder going through the top of the box and another going through the box's side you would see a box with cylindrical holes in its top and side (3).
-'intersection' takes every piece of geometry and only shows the space where every piece of geometry intersects. So, again, if you have a box with a cylinder going through it, you will see a cylinder, but only where it is passing through the box (4). If you had a box followed by a cylinder going through the top of the box and another going through the box's side you would see only the shape of the two cylinders meeting, but only if that shape is also within the area of the box (5).
-'merge' is nearly identical to union, the difference between the two is only noticeable with transparent shapes. So if you have a transparent (partially that is, complete transparency is possible but not very helpful in this instance) box with a transparent cylinder going though it you will not see the cylinder where it is passing through the box, but rather you will just see a box with cylinders sticking out the sides (6). But with a union, you would see the entire cylinder, even where it is passing through the box (7,8).
-Once you type in the desired operation, you must follow it with a '{' followed by the code for the geometry to be effected by the operation, and finally end the operation with a '}' For example, the code for the geometry in example #1 is (I'll explain the 'pigment' part later):
union {
box {<10,10,10>,<-10,-10,-10>}
cylinder {<20,0,0>,<-20,0,0>,5}
pigment {color rgbt <.5,.5,.5,0>}
}
-This would do the same thing, except it takes up less visual space in the code editor:
union {box {<10,10,10>,<-10,-10,-10>}
cylinder {<20,0,0>,<-20,0,0>,5} pigment {color rgbt <.5,.5,.5,0>}}
-We can finally get to the shapes themselves. The basic geometric shapes you'll be using are:
box
sphere
cylinder
cone
torus
plane
-And while more complex, these shapes are necessary to at least mention for now:
blob
sphere_sweep
bicubic_patch
-Of course you can't just type 'box' and expect a box to appear when you render again, POV Ray needs to be told some key information in order to form a shape. The information needed is different for each shape, we'll touch on each one briefly.
-First, the common feature with all shapes is, similar to CSG operations, the initial code begins with the name of the shape, followed by a '{', then the information, and finally ended with a '}'.
-While not common to all shapes, you will find with most a small block of code like this:
<0,0,0>
-With code for shapes, this is the X,Y,Z coordinates (
IN THAT ORDER) of a point in that shape. The measurement units are of no real-world value, but 1 unit in one POV Ray file is 1 unit in every POV Ray file (you could probably change that, but I don't know how, or why you would want to
)
Box
-the basic code for a box is:
box {<0,0,0>,<0,0,0>}
-Note the comma between the each <0,0,0> , it is necessary.
-If you were to render that, you would see nothing, because every part of the box exists at the location X=0,Y=0,Z=0. To make the box visible, at last one of these points has to be somewhere different than the other point, ie:
box {<10,10,10>,<0,0,0>}
or
box {<0,0,0>,<10,10,10>}
-These 2 boxes would look the exact same. Each has one corner at X=0,Y=0,Z=0 and another corner at X=10,Y=10,Z=10. POV Ray generates the other corners with this information.
-Make sure all 3 values are different between the two points, because:
box {<0,0,0>,<10,10,0>}
-This shape does not look the same as the previous two. The 2nd point has the same Z value as the 1st point, so this would create a mathematically flat plane stretching out 10 units on the X axis and 10 units up the Y axis. If you were to look at this shape directly down the Z axis it would be invisible, like the world's thinnest sheet of paper.
-You may in fact want a shape like that, there is a shape similar (the plane) but it goes on infinitely on all but one axis.
Sphere
-We could actually have skipped all the declarations of objects like 'Part A' and 'Tutorial' (or whatever you called your unit), you can just place the code down for geometry outside of those variable declarations and it will appear in the scene when you render, but since every unit is a collection of many (sometimes A LOT) of shapes that need to maintain their positions relative to each other while moving or rotating, uniting them in some way is necessary.
Stay tuned for more updates!