Primitive objects are the building box with which other objects are
created. Each primitive type has associated with it specialized
methods for
creation,
intersection with a ray,
bounding box calculation,
surface normal calculation,
ray enter/exit classification,
and for the computation 2D texture coordinates termed u-v
coordinates.
This latter method is often referred to as the inverse mapping
method.
While most of these methods should be of little concern to you, the
inverse mapping methods
will affect the way in which certain textures are applied to primitives.
Inverse mapping is a matter of computing normalized u and v coordinates
for a given point on the surface of the primitive. For planar objects,
the u and v coordinates of a point are computed
by linear interpolation based upon the u and v coordinates assigned
to vertices or other known points on the primitive. For non-planar
objects, uv computation can be considerably more involved.
This section briefly describes each primitive and
the syntax that should be used to create an instance of the primitive.
It also describes the inverse mapping method, if any, for each type.
- blob thresh st r
[st r
...]
Defines a blob with consisting of a threshold equal to thresh,
and a
group of one or more metaballs. Each metaball is defined by
its position
, radius r, and strength st.
The metaballs affect each other according to a superimposed
density distribution:
F(
x,
y,
z) =
bie-di -
T = 0
There is no inverse mapping method for blobs.
- box
Creates an axis-aligned box
which has
and
as
opposite corners.
Transformations may be applied to the box if a non-axis-aligned instance
is required. There is no inverse mapping method for boxes.
- sphere radius
Creates a sphere with the given radius and centered at the
given position.
Note that ellipsoids may be created by applying the proper scaling
to a sphere. Inverse mapping on the sphere is accomplished
by computing the longitude and latitude of the point on the sphere,
with the u value corresponding to longitude and v to latitude.
On an untransformed sphere, the z axis defines the poles, and the
x axis intersects the sphere at u = 0, v = 0.5. There are
degeneracies at the poles: the south pole contains all points of
latitude 0., the north all points of latitude 1.
- torus rmajor rminor
Creates a torus centered at
by rotating
a circle with the given minor radius around the center
point at a distance equal to the major radius.
In tori inverse mapping,
the u value is computed using the angle of rotation about the
up vector, and the v value is computing the angle of rotation
around the tube, with v = 0 occuring on the innermost point of the tube.
- triangle
Creates a triangle with the given vertices.
- triangle
Creates a Phong-shaded triangle with the given vertices and
vertex normals.
For both Phong- and flat-shaded triangles, the u axis is the
vector from
to
, and the v axis the vector
from
to
. There is a degeneracy at
, which contains all points with v = 1.0. This default
mapping may be modified using the triangleuv primitive described
below.
- triangleuv
Creates a Phong-shaded triangle with the given vertices,
vertex normals. When performing texturing, the
uv given for each vertex are used instead of the
default values.
When computing uv coordinates within the interior of the
triangle, linear interpolation of the coordinates associated with
each triangle vertex is used.
- poly
[
...]
Creates a polygon with the given vertices. The vertices
should be given in counter-clockwise order as one is
looking at the ``front'' side of the polygon. The number of
vertices in a polygon is limited only by available memory.
Inverse mapping for arbitrary polygons is problematical.
Rayshade
punts and equates u with the x coordinate of the point of intersection,
and v with the y coordinate.
- heightfield file
Creates a height field defined by the altitude data stored
in the named file. The height field is based upon
perturbations of the unit square in the z = 0 plane, and is
rendered as a surface tessellated by right isosceles triangles.
See Appendix C for a discussion of the format of a height field file.
Height field inverse mapping is straight-forward: u is the
x coordinate of the point of intersection, v the y coordinate.
- plane
Creates a plane that passes through the given point and
has the specified normal.
Inverse mapping on the plane is identical to polygonal inverse mapping.
- cylinder radius
Creates a cylinder that extends from
to
and has the indicated radius. Cylinders are rendered
without endcaps.
The cylinder's axis defines the v axis. The u axis wraps around the
cylinder, with u = 0 dependent upon the orientation of the cylinder.
- cone
radbottom
radtop
Creats a (truncated) cone that extends from
to
. The cone will have a radius of
radbottom at
and a radius of radtop at
.
Cones are rendered without endcaps.
Cone inverse mapping is analogous to cylinder mapping.
- disc radius
Creates a disc centered at the given position and with the
indicated surface normal.
Discs are useful for placing
endcaps on cylinders and cones.
Inverse mapping for the disc is based on the computation of the
normalized polar coordinates of the point of intersection. The
normalized radius
of the point of intersection is assigned to u, while the normalized angle
from a reference vector is assigned to v.