Previous:Polygon Main Index Next:Infinite Solid Primitives

#### Triangle and Smooth Triangle

The `triangle` primitive is available in order to make more complex objects than the built-in shapes will permit. Triangles are usually not created by hand but are converted from other files or generated by utilities. A triangle is defined by

TRIANGLE:
`
  triangle {
` <Corner_1>`,` <Corner_2>`,` <Corner_3> [OBJECT_MODIFIER...] `}`

where <Corner_n> is a vector defining the x, y, z coordinates of each corner of the triangle.

Because triangles are perfectly flat surfaces it would require extremely large numbers of very small triangles to approximate a smooth, curved surface. However much of our perception of smooth surfaces is dependent upon the way light and shading is done. By artificially modifying the surface normals we can simulate a smooth surface and hide the sharp-edged seams between individual triangles.

The `smooth_triangle` primitive is used for just such purposes. The smooth triangles use a formula called Phong normal interpolation to calculate the surface normal for any point on the triangle based on normal vectors which you define for the three corners. This makes the triangle appear to be a smooth curved surface. A smooth triangle is defined by

SMOOTH_TRIANGLE:
`
  smooth_triangle {
`
  <Corner_1>`,` <Normal_1>`,`
  <Corner_2>`,` <Normal_2>`,`
  <Corner_3>`,` <Normal_3>
  [OBJECT_MODIFIER...]
`
  }
`

where the corners are defined as in regular triangles and <Normal_n> is a vector describing the direction of the surface normal at each corner.

These normal vectors are prohibitively difficult to compute by hand. Therefore smooth triangles are almost always generated by utility programs. To achieve smooth results, any triangles which share a common vertex should have the same normal vector at that vertex. Generally the smoothed normal should be the average of all the actual normals of the triangles which share that point.

The `mesh` object is a way to combine many `triangle` and `smooth_triangle` objects together in a very efficient way. See "Mesh" for details.

Previous:Polygon Main Index Next:Infinite Solid Primitives