Email: nexusmail at this Web site address
Registration is entirely optional; it's no longer required for posting comments. If you wish to create an account, you may do so
through the login page.
The Astronomy Nexusscience, art, and advice |
|
AboutEmail: nexusmail at this Web site address Registration is entirely optional; it's no longer required for posting comments. If you wish to create an account, you may do so POV-Ray 3.0 For Technical IllustrationStellar CartographyObserving GuidesPersonal ExperiencesOther interests |
A simple scene
Submitted by David on Wed, 2006-04-05 03:07.
Table of Contents
All right. You're probably tired of reading and want to create something. Let's start with a couple of demonstrations that illustrate the abilities of POV-Ray, while also providing examples of its language's syntax. Lights, Camera, Objects! The three essentialsFor our first example, let's create a cube hanging in space. The following POV-Ray code will do this -- try opening an editor, then cutting and pasting this in from your browser:
camera {location <5,5,5> look_at <0,0,0> }
light_source { <-10,10,20 > color rgb <1,1,1> }
box { <-1,-1,-1>, <1,1,1>
color rgb <1,0,0> }
Let's render this at 320x240 pixels, and see the result:
Voila! Now, what have we done exactly? Let's go through it step by step. The CameraThe first line in this sample file:
camera {location <5,5,5> look_at <0,0,0> }
defines the camera. A camera declaration in POV-Ray defines where the scene -- the collection of objects being rendered -- is being viewed from, how much of it is being viewed, and so on. You can tell the camera to have many "features", but the two most important are the Since positions and directions are easily represented by vectors, that's what we use. POV-Ray represents a vector with numbers inside angle brackets, like <1,2,3>. In the example above, the camera is 5 units along +x, 5 along +y, and 5 along +z, and it looks towards <0,0,0>, i.e., the origin. You will routinely use vectors like these any time you want to specify a position or a direction. In this example, I've used integers for the three distances, but most of the time, decimal (or "floating-point") quantities are acceptable. There are a couple of times where they aren't -- I'll discuss those as they arise. Warning for engineers, scientists, and other geeks: For historical reasons, the default coordinate system has a potentially irritating quirk: it's left-handed. Moreover, the x-y plane, in the default orientation, lies in the plane of the screen, making it vertical rather than horizontal. Here's the POV-Ray coordinate system:
The Light SourceWe can't see very much without some light to light things up. You use the
light_source { <-10,10,20 > color rgb <1,1,1> }
specifies something called a point light. A point light source is just that -- a single point in space that radiates in all directions. Since it has no dimensions, it won't show up in your scene, even as a dot (so don't bother trying to look for it). POV-Ray can simulate "extended" light sources, but point lights work well for many simple scenes, so we'll stick to them for now. The first vector in the
indicates "pure" red, whereas something like
gives a red-green combination (i.e., yellow), and
indicates equal amounts of all three primary colors, but at low saturations -- i.e., a very dark gray, or, in the case of a light source, a very feeble white light. You'll be using The Box ObjectPOV-Ray is capable of creating huge numbers of exotic shapes and objects, simply by taking a mathematical description of them and drawing the result. The "box" object is a simple example. The third line in the scene file:
box { <-1,-1,-1>, <1,1,1>
color rgb <1,0,0> }
draws a box -- a solid with rectangular sides, all perpendicular to each other. The size and location of the box are specified by two vectors, which represent the positions of two diagonally opposite corners. Here, all the side lengths are the same -- 2 units -- so we get a cube. To make sure the corners chosen are unique, you must pick one to contain the lowest values of x,y, and z, and the other to contain the highest. This can be a bit difficult to visualize. Here's a rendition of this cube with two little white markers indicating the relevant corners:
Finally, this box has a |