G3dRender.mesa
Copyright Ó 1985, 1989, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 15, 1992 10:42 pm PDT
Crow, October 30, 1990 6:22 pm PST
Glassner, November 7, 1989 12:00:16 pm PST
DIRECTORY Atom, CedarProcess, G2dBasic, G3dBasic, G3dLight, G3dMatrix, G3dShape, Imager, ImagerPixel, ImagerSample, ImagerColor, IO, Rope, ViewerClasses;
G3dRender: CEDAR DEFINITIONS
~ BEGIN
Errors
Error:       SIGNAL [code: ATOM, reason: ROPE]; -- we're able to resume this error
Imported Types
Box:     TYPE ~ G2dBasic.Box;
Pair:     TYPE ~ G3dBasic.Pair;
Triple:    TYPE ~ G3dBasic.Triple;
Light:     TYPE ~ G3dLight.Light;
LightSequence:  TYPE ~ G3dLight.LightSequence;
Matrix:    TYPE ~ G3dMatrix.Matrix;
Shape:     TYPE ~ G3dShape.Shape;
ShapeSequence:  TYPE ~ G3dShape.ShapeSequence;
Rectangle:    TYPE ~ Imager.Rectangle;
RGB:      TYPE ~ ImagerColor.RGB;
PixelMap:    TYPE ~ ImagerPixel.PixelMap;
SampleMap:   TYPE ~ ImagerSample.SampleMap;
ROPE:     TYPE ~ Rope.ROPE;
Local Types
DisplayMode:   TYPE ~ {gray, dither, fullColor};
RenderData:   TYPE ~ REF RenderDataRep;
RenderDataRep:  TYPE ~ RECORD [
renderStyle:     RenderStyle ¬ faceted,
color:       RGB ¬ [1, 1, 1],
diffuseReflectivity:   REAL ¬ 1.0,
specularReflectivity:  REAL ¬ 0.0,
metallicity:     REAL ¬ 0.0,
shininess:     REAL ¬ 0.0,
transmittance:    REAL ¬ 0.0,
textures:      LIST OF TextureMap ¬ NIL
];
RenderStyle:   TYPE ~ {
faceted,
smooth,
lines,
shadedLines,
hiddenLines,
linesWnormals,
controlPoints
}; 
TextureStyle:   TYPE ~ {none, intensity, color, bump, function};
TextureMap:   TYPE ~ REF TextureMapRep;
TextureMapRep:  TYPE ~ RECORD [
style:       TextureStyle,
name:       ROPE,
range:       Pair, -- circumvent seam matching
scale:       Pair,
bumpHeight:     REAL,
filter:       BOOL
];
Context3d:   TYPE ~ REF Context3dRep;
Context3dRep:  TYPE ~ RECORD [
Miscellany
props:      Atom.PropList ¬ NIL, -- catchall
clientData:    REF ANY ¬ NIL,   -- data storage for a client
Rendering
clear:      BOOL ¬ FALSE,   -- clear screen before rendering?
antiAliasing:    BOOL ¬ FALSE,   -- flag for antialiasing and alpha buffer
Background
backgroundColor:  RGB ¬ [0.7, 0.5, 1.0], -- background
backgroundName:  ROPE ¬ NIL,
backgroundImage:  SampleMap ¬ NIL,
matteBackground:  BOOL ¬ TRUE,   -- matte background?
Scene
frameNumber:   NAT ¬ 0,     -- current frame for animation routines
Camera
eyePoint:     Triple ¬ [1.0, -5.0, 2.0], -- point from which view is seen
lookAt:      Triple ¬ [0.0, 0.0, 0.0], -- defines center of image and focus
rollAngle:     REAL ¬ 0.0,    -- rotational angle about view direction
upDirection:     Triple ¬ [0.0, 0.0, 1.0], -- "heads-up" direction (redundant)
fieldOfView:    REAL ¬ 40.0,    -- horizontal angle for field of view
window:     Rectangle ¬ [0,0,0,0], -- clips field of view in eyespace
hitherLimit:    REAL ¬ 1.0,    -- anything closer to eyepoint is clipped
yonLimit:     REAL ¬ 1000.0,   -- further from eyepoint is clipped
scale:      REAL ¬ 1.0,    -- scale applied to view transformation
view:      Matrix ¬ NIL,   -- world space to eyespace
Display
viewport:     Rectangle ¬ [0,0,0,0], -- in floating pt. display coordinates
screenExtent:    Box ¬ [[0, 0], [0, 0]],  -- bounds area (while building image)
displayMode:    DisplayMode ¬ dither  -- type of image to be displayed
];
Context3d
Create: PROC RETURNS [Context3d];
Allocate a default.
View
SetViewFromParameters: PROC [
context3d: Context3d,
fieldOfView: REAL ¬ 40.0,
scale: REAL ¬ 1.0,
moves, rotates: Triple ¬ []];
Set the context3d view according to parameters.
SetView: PROC [
context3d: Context3d,
eyePoint: Triple,
lookAt: Triple,
fieldOfView: REAL ¬ 40.0,
rollAngle: REAL ¬ 0.0,
upDirection: Triple ¬ [0., 0., 1.],
hitherLimit: REAL ¬ .01,
yonLimit: REAL ¬ 1000.0];
Set the context3d view according to camera geometry. If fieldOfView = 0, it will be set to 40.
SetViewport: PROC [context3d: Context3d, size: Rectangle];
Display full image (with possibly different aspect ratio) in portion of screen.
SetWindow: PROC [context3d: Context3d, size: Rectangle];
Display only that part of full-screen image which lies within the window.
Background
NameBackgroundColor: PROC [context3d: Context3d, color: ROPE];
Set background color using color naming scheme.
SetBackgroundColor: PROC [context3d: Context3d, color: RGB];
Set background color.
SetBackgroundImage: PROC [context3d: Context3d, name: ROPE];
Use named image file as background image for scene instead of solid color.
EnableClear: PROC [context3d: Context3d, on: BOOL];
Enable clearing before rendering; if disabled (on = FALSE) images may be composited using successive renderings.
MatteBackground: PROC [context3d: Context3d, matte: BOOL];
If false, prevent final background matte step thereby preserving alpha buffer.
Shapes
RenderDataFrom: PROC [shape: Shape] RETURNS [data: RenderData];
Return rendering information associated with the shape.
SetRenderStyle: PROC [shape: Shape, renderStyle: RenderStyle];
Change the rendering style for a shape.
SetDiffuse: PROC [shape: Shape, diffuseReflectivity: REAL];
Set the shape's diffuse reflection.
SetSpecular: PROC [shape: Shape, specularReflectivity: REAL];
Set the shape's specular reflection.
SetMetallicity: PROC [shape: Shape, metallicity: REAL];
Set the shape's metallicity.
SetShininess: PROC [shape: Shape, shininess: REAL];
Set the shape's shininess.
SetColor: PROC [shape: Shape, color: RGB];
Set the color for the given shape.
SetTransmittance: PROC [shape: Shape, transmittance: REAL];
Change the transmittance of the shape; transmittance = 0 is opaque.
N.B: Rendering of transparent objects occurs only when anti-aliasing is enabled.
SetInvisible: PROC [shape: Shape];
Maintain data but don't display the shape.
SetVisible: PROC [shape: Shape];
Undo SetInvisible.
ShowBackfaces: PROC [shape: Shape];
Render back-facing polygons (for transparent or non-closed shapes, or debugging).
HideBackfaces: PROC [shape: Shape];
Don't render back-facing polygons (for transparent or non-closed shapes, or debugging).
AddAxes: PROC [
context3d: Context3d,
origin: Triple ¬ [0, 0, 0],
size: REAL ¬ 1.0,
scale: Triple ¬ [1, 1, 1],
nReticles: NAT ¬ 20];
Add a set of coordinate axes to the 3d context.
size is the length of an axis; the scales are the numeric size of each axis.
Textures
SetTextureMap: PROC [
shape: Shape,
fileName: ROPE,
textureStyle: TextureStyle ¬ intensity,
textureFiltering: BOOL ¬ FALSE]
RETURNS [error: ROPE];
Read in the appropriate texture map for the given shape.
GetTextureMap: PROC [shape: Shape, textureName: ROPE] RETURNS [TextureMap];
Return the named texture map associated with shape.
OffsetTextureCoords: PROC [shape: Shape, offset: Pair];
Offset the texture coordinates for the given shape.
SetTextureScale: PROC [shape: Shape, textureName: ROPE, scale: Pair ¬ [1.0, 1.0]];
Set the texture scale for the given shape.
SetTextureRange: PROC [shape: Shape, textureName: ROPE, range: Pair];
Circumvent seam matching; range to exceed twice the range for all shape polygons.
SetTextureFiltering: PROC [shape: Shape, textureName: ROPE, on: BOOL];
Turn on/off the texture filtering for the given shape.
SetBumpHeight: PROC [shape: Shape, textureName: ROPE, height: REAL ¬ 1.0];
Set the bump scale factor for this shape.
Rendering
Render: PROC [context3d: Context3d, image: REF, fork: BOOL ¬ TRUE] RETURNS [error: ROPE];
Perform the rendering process onto the given image. Typically image is an Imager.Context.
If fork, fork the rendering process; otherwise, return upon completion of the rendering.
RenderToFile: PROC [
context3d: Context3d,
fileName: ROPE,
fork: BOOL ¬ TRUE,
abekas: BOOL ¬ FALSE];
Render and then store to a file
WaitTilRenderDone: PROC;
Wait until a rendering process finishes. Does not distinguish between different context3ds.
IsRendering: PROC [context3d: Context3d] RETURNS [BOOL];
Return true iff context3d is rendering (forked or not).
AbortRender: PROC [context3d: Context3d];
Abort any current rendering within context3d.
SetAntiAliasing: PROC [context3d: Context3d, on: BOOL ¬ TRUE];
This will draw images using the alpha buffer; texture mapping is enabled.
AntiAliasingNeeded: PROC [context3d: Context3d] RETURNS [BOOL];
Determine if anti-aliasing is needed to render the shapes in their respective shading modes.
For example, anti-aliasing is necessary for bump-mapping, transparency, solid texture.
GetBuffer: PROC [context3d: Context3d, type: ATOM] RETURNS [SampleMap];
Get a sample map from the context3d; return NIL if no such map.
Miscellany
AtomFromTextureStyle: PROC [textureStyle: TextureStyle] RETURNS [ATOM];
Return an atom for non-typed operations.
AtomFromDisplayMode: PROC [displayMode: DisplayMode] RETURNS [ATOM];
Return an atom for non-typed operations.
RopeFromDisplayMode: PROC [displayMode: DisplayMode] RETURNS [ROPE];
Return the rope representing displayMode.
RopeFromRenderStyle: PROC [renderStyle: RenderStyle] RETURNS [ROPE];
Return the rope representing renderStyle.
RopeFromTextureStyle: PROC [textureStyle: TextureStyle] RETURNS [ROPE];
Return the rope representing textureStyle.
END.