ThreeDWorldDoc.tioga
Crow, November 7, 1986 5:25:31 pm PST
ThreeDWorldDoc
CEDAR 6.1 — FOR INTERNAL XEROX USE ONLY
ThreeDWorld
3-D Shapes Rendered on Cedar Displays
Frank Crow
© Copyright 1985 Xerox Corporation. All rights reserved.
Abstract: This package provides shaded renditions of numerically-described three dimensional shapes on Cedar displays (LF, Dorado Color display) or Interpress devices. Quick display for line drawings and faceted objects allows near-real-time display of simple shapes. For more complex scenes or more expensive shading techniques, a short sequence of images may be computed and then played back at real-time rates. More elaborate shading techniques include: smoothly varying shading for curved surfaces, highlights, simulated transparency, mapped and space-filling textures, and antialiasing. Currently, this package supports only shapes approximated by polygons and Bezier patches.
Created by: Frank Crow
Maintained by: Frank Crow <Crow.pa>
Keywords: 3-D, antialiasing, shading, highlights, image synthesis, texture, transparency
XEROX  Xerox Corporation
   Palo Alto Research Center
   3333 Coyote Hill Road
   Palo Alto, California 94304

For Internal Xerox Use Only
0. Command files
ThreeDWorld.load - starts everything including the demo package.
LoadThreeDWorld.cm - runs enough code for applications to run on top of.
1. Demo Package
General Features
A demonstration package is included in the release. It is started up by the command ThreeDWorld.load. The demo starts up the color display and displays a viewer with an array of buttons for exercising various features of the system. Three built-in scenes are provided which can be viewed from various positions and shaded in different manners. A sequence of images is provided for real-time playback.
Built-in Scenes
Three scenes are provided: The first consists of an icosahedron, a cube with a cut corner, and a soccer ball-like shape above a checkerboard, the second shows an egg shape, a banana shape and a piece of stemware, the third shows the famous Newell teapot as a demonstration of Bezier patches. The button labeled "NewScene" switches between them.
The first scene demonstrates the capability for quickly rendering simple scenes. The icosahedron and soccer ball have individually colored polygons when displayed with facets. They use global colors, however when smooth shaded. The cube with a cut corner has individually colored vertices when smotth shaded.
The second scene demonstrates the approximation of curved surfaces using polygons. The images cannot be generated as quickly, but provide more interesting shapes. The piece of stemware is transparent, as can be seen when an antialiased rendition is requested ("NoJaggy" mode).
The third scene demonstrates rendition of directly defined curved surfaces. Line drawings show just the patch boundaries. Shaded images are rendered by successive subdivision of the patches. Subdivision is terminated when the resulting patches are supposedly indistinguishable from approximating polygons. The approximating polygons are then rendered.
Button Semantics
The menu buttons have the following meanings:
- Help - provides a miniscule amount of helpful information (suggestions for additional messages are welcome)
- NewScene - Selects one of the predefined scenes in cyclic order.
- Lines - displays the current scene as a line drawing.
- Facets - displays the current scene with each polygon shaded in a constant color.
- Smooth - displays the current scene with curved surfaces simulated.
- Shiny - displays the current scene with highlights simulated.
- Orbit - generates a sequence of double-buffered images on an elliptical path about the scene starting at the eyepoint used for the most recently generated image. It continues making images forever, not advisable for rendering modes which take more than a few seconds per frame.
- STOP! - stops the current button action, useful for mistakes and to salve impatience.
- Movie - reads a sequence of AIS files from [Cyan] and displays them at a rate controlled by the x-coordinate of left mouse clicks, using large amounts of VM in the process.
- Gallery - reads a set of AIS files defined by [Cyan]<AIS>Crow>PrettyPictures.txt and displays them in response to mouse clicks, using even larger amounts of VM in the process.
- Jaggy - turns off anti-aliasing, for jaggy images.
- NoJaggy - turns on anti-aliasing, no jaggies, best used with a 24-bit display. Use with the 8-bit display will require use of greyscale imagery.
- Reset - recovers from various problems, resets viewport to full screen, clears objects from scene, lighting unchanged.
All of the mouse buttons have the same effect for the menu buttons. Outside the menu buttons mouse clicks cause a new image to be computed. A left click changes the x-y position of the eyepoint and a right click changes its height. A middle click will move the light source around in the same manner as a left click moves the eyepoint. The available range of values gives a space of about -20 to +20 units in all three dimensions.
If a Movie action is running the x position is used to control the frame rate from approximately -30 fps at the left of the screen to approximately +30fps at the right.
If the Gallery is being viewed, a left click moves ahead to the next picture, a right click moves back to the previous one. No response indicates no more pictures available in the requested direction. Pictures are cached, so that they can be run through quickly, once they are all read in.
2. Major Interfaces and Example Programs
Examples
- ThreeDTest.cm - Contains procedure call scripts which may be stuffed to the interpreter for richer exercise of the available functions. The command file and the code for the demonstration program provide examples to follow in assembling further applications of the package.
- ThreeDDemoImpl - Provides the functions described above under section 1. Routines may be investigated by browsing the code.
- ShadingProcs - Gives examples of texturing techniques which may be applied to a scan-converted surface. Its probably best to discuss this with an implementer before trying to use it.
Interfaces
- ThreeDMisc - A grab bag of useful procedures. Procedures are provided for manipulating the color map, writing text to the display, generating patterns to use as texture, controlling the lighting, assigning colors to objects, generating frames and controlling simple animations.
- ThreeDBasics - Defines the basic structures used to define shapes and three dimensional contexts within which shapes live.
- ThreeDScenes - Provides basic routines for setting up three dimensional contexts, defining and altering environments, and manipulating shapes and vertices.
- ThreeDSurfaces - Procedures for reading, clipping, sorting, shading, and displaying shapes.
- ThreeDIO - Procedures for reading and writing shapes using a standard scheme for describing surfaces.
- Tilers - Control of scan conversion routines and code for the more elaborate tiler which handles anti-aliasing, texture, and transparent surfaces.
- AISAnimation - Contains procedures for reading and writing AIS files from three dimensional contexts and for controlling playback of images cached from AIS files. Additional routines aid in naming sequences of files for use in animation
- Animation3D - Simple routines for generating a sequence of positions from descriptors for lines and tilted orbits. Expansions of point sequences to cubic curves is expected soon.
- TextureMaps - Procedures for mapping texture coordinates to regular arrays of polygons. Procedures for preparing and applying AIS files as texture.
- SolidTextures - Procedures for capturing solid texturing techniques in a less volatile form.
- ShapeTwiddle - Procedures for cleaning up and editing shape files. New shapes may be written out after modifications are made.
- StandardPatches - Procedures for operating on Bezier patches. Bezier shapes may be expanded to polygons or sudivided into larger numbers of patches. Display routines show Bezier patches by rendering curved patch boundaries for line drawings and by subdividing to effectively straight boundaries for shaded renderings. Similar procedures for other patch formulations are planned.
3. Shape and Image Description Formats
Patches (Surface types $ConvexPolygon, $Lines, $Bezier)
A surface compose of patches may be either closed (cannot be seen from the inside) or open. Where there is a notion of "outside" (as in a "closed" surface) the vertices of a patch are assumed to be taken in clockwise order as seen from the outside.
Shapes are described using a file format as follows:
- Keywords are used to indicate formatting. Currently used keywords are "SurfaceType", "Vertices", "Polygons", "Patches". Keywords are followed by a "~".
- The keyword "SurfaceType" is followed by a rope containing surface descriptors. Current descriptors include: "ConvexPolygon", Bezier", "InsideVisible", etc.
- The keyword "Vertices" is followed by a series of descriptors of the lines containing vertex data. Descriptors are colon-separated pairs including a field name and a type. Understood field names include "index", "xyz", "normal", "color", "texture", "trans". Understood types include: "integer", "real", "triple". Vertex coordinates are assumed in a right handed space (x, y, z ~ longitude, latitude, altitude in the Eastern hemisphere).
- The keywords "Polygons" or "Patches" are followed by a series of descriptors of the lines containing surface data. Descriptors are colon-separated pairs including a field name and a type. Understood field names include "index", "normal", "color", "trans". Understood types include: "integer", "real", "triple" and, "nats". "Nats" indicates a field containing a sequence of NAT, used to describe a surface element by enumerating its vertices. Other fields names (but not other types) may be added. Nonstandard names will cause the corresponding data to be stored on the shape's property list, where it may later be used.
Comments may be included as whole lines or at the end of lines (and possibly elsewhere).
The following describes a box with the top removed:
OpenBox.shape
SurfaceType ~ ConvexPolygon, InsideVisible
Vertices ~ xyz: triple      -- 8 vertices, 5 polygons

1.0  -1.0 -1.0
-1.0 -1.0 -1.0
-1.0  1.0 -1.0
1.0   1.0 -1.0
 1.0  -1.0  1.0
-1.0 -1.0  1.0
-1.0  1.0  1.0
1.0   1.0  1.0

Polygons ~ vertices: nats

 3 2 1 0     -- bottom
 1 5 4 0     -- front (as seen from negative y-axis)
 1 2 6 5     -- left side
 3 0 4 7     -- right side
 3 7 6 2     -- back