G3dRender.mesa
Copyright Ó 1985, 1989 by Xerox Corporation. All rights reserved.
Bloomenthal, September 18, 1989 6:47:50 pm PDT
Crow, September 21, 1989 4:20:01 pm PDT
Glassner, July 19, 1989 12:04:39 pm PDT
DIRECTORY Atom, G3dBasic, G3dHierarchy, G3dLight, G3dMatrix, G3dShape, Imager, ImagerPixel, ImagerSample, ImagerColor, IO, Rope, Terminal, ViewerClasses;
G3dRender: CEDAR DEFINITIONS
~ BEGIN
Errors
Error:     SIGNAL [code: ATOM, reason: ROPE]; -- we're able to resume this error
Types
Miscellaneous Types
ROPE:     TYPE ~ Rope.ROPE;
PropList:    TYPE ~ Atom.PropList;
Virtual:    TYPE ~ Terminal.Virtual;
Viewer:    TYPE ~ ViewerClasses.Viewer;
RefSeq:    TYPE ~ REF RefSeqRep;
RefSeqRep:   TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF REF
];
Imported Sequences
RealSequence:  TYPE ~ G3dBasic.RealSequence;
IntegerSequence:  TYPE ~ G3dBasic.IntegerSequence;
IntSequence:   TYPE ~ G3dBasic.IntSequence;
NatSequence:   TYPE ~ G3dBasic.NatSequence;
NatSequenceRep:  TYPE ~ G3dBasic.NatSequenceRep;
PairSequence:  TYPE ~ G3dBasic.PairSequence;
IntegerPairSequence: TYPE ~ G3dBasic.IntegerPairSequence;
TripleSequence:  TYPE ~ G3dBasic.TripleSequence;
QuadSequence:  TYPE ~ G3dBasic.QuadSequence;
Pixel Definitions
RGB:      TYPE ~ ImagerColor.RGB;
RGBSequence:  TYPE ~ REF RGBSequenceRep;
RGBSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF RGB
];
NatRGB:    TYPE ~ RECORD [r, g, b: NAT];
NatRGBSequence:  TYPE ~ REF NatRGBSequenceRep;
NatRGBSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF NatRGB
];
Spot:     TYPE ~ RECORD [
coverage:      REAL ← 1.0,    -- % of pixel area covered by surface
mask:       BYTE ← 255,   -- code for covered area, default: all covered
partShiny:     REAL ← 1.0,   -- amount shiny surface shows (1.0 = all)
val:       RealSequence ← NIL, -- interpolated values for shading
yIncr:       RealSequence ← NIL, -- vertical increments for interpolation
xIncr:       RealSequence ← NIL, -- horizontal increments for interpolation
xySwapped:     BOOL,     -- if TRUE, xincr and yincr are swapped
props:       PropList ← NIL  -- catchall
];
SpotProc:    TYPE ~ PROC [
context:      Context,
shading:      REF ShadingClass,
spot:       REF Spot,
data:       REF ANYNIL];
PixelPart:    TYPE ~ {r, g, b, a, z};      -- addressing within Pixels
Pixel:      TYPE ~ ARRAY PixelPart OF CARDINAL; -- r, g, b, alpha, z (depth)
Geometric Definitions
Pair:     TYPE ~ G3dBasic.Pair;
IntegerPair:   TYPE ~ G3dBasic.IntegerPair;    -- RECORD [x, y: INTEGER];
Triple:    TYPE ~ G3dBasic.Triple;
Quad:     TYPE ~ G3dBasic.Quad;      -- RECORD [x, y, z, w: REAL];
Matrix:    TYPE ~ G3dMatrix.Matrix;     -- REF 4 by 4 ARRAY OF REAL
MatrixRep:   TYPE ~ G3dMatrix.MatrixRep;
Image Definitions
SampleMap:   TYPE ~ ImagerSample.SampleMap;
PixelMap:    TYPE ~ ImagerPixel.PixelMap;
Box:     TYPE ~ G3dShape.Box2d;     -- [min, max: Pair]
Rectangle:    TYPE ~ Imager.Rectangle;     -- RECORD [x, y, w, h: REAL]
ScaleAndAddXfm:  TYPE ~ RECORD [scaleX, scaleY, scaleZ, addX, addY, addZ: REAL];
ClipState:    TYPE ~ G3dShape.ClipState;    -- {in, out, clipped, unknown}
OutCode:    TYPE ~ RECORD [left, right, bottom, top, near, far: BOOL];
SixSides:    TYPE ~ {Left, Right, Bottom, Top, Near, Far};
Constants
NoneOut:    OutCode ~ [FALSE, FALSE, FALSE, FALSE, FALSE, FALSE];
AllOut:    OutCode ~ [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE];
IdentityXfm:   ScaleAndAddXfm ~ [1.0, 1.0, 1.0, 0.0, 0.0, 0.0];
Texture Definitions
TextureStyle:   TYPE ~ {none, intensity, color, bump, function};
TextureInfo:   TYPE ~ RECORD [name: ROPE, type: TextureStyle, filtered: BOOL];
TextureFunction: TYPE ~ RECORD [name: ATOM, proc: SpotProc, props: PropList];
TextureMap:   TYPE ~ RECORD [type: ATOM, pixels: REF ANY, props: Atom.PropList];
SummedTexture:  TYPE ~ RECORD [SEQUENCE length: NAT OF REF SumSequence];
SumSequence:  TYPE ~ RECORD [SEQUENCE length: NAT OF IntSequence];
Control Point Definitions
CtlPoint:    TYPE ~ RECORD [
x,y,z:       REAL ← 0.0,      -- object coordinates
ex, ey, ez:     REAL ← 0.0,      -- eyespace coordinates
sx, sy, sz:     REAL ← 0.0,      -- screen coordinates
clip:       OutCode ← NoneOut  -- clip code
];
CtlPointSequence: TYPE ~ REF CtlPointSequenceRep;
CtlPointSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF REF CtlPoint
];
Shading:    TYPE ~ RECORD [
xn, yn, zn:     REAL ← 0.0, -- normal vector to surface
exn, eyn, ezn:    REAL ← 0.0, -- normal in eyespace
r, g, b:      REAL ← 1.0, -- vertex color (def = white) scaled by shape color
t:        REAL ← 1.0, -- original transmittance
txtrX, txtrY:     REAL ← 0.0, -- texture mapping coordinates
er, eg, eb, et:    REAL ← 0.0 -- computed color, transmittance (for lights, etc)
];
ShadingSequence: TYPE ~ REF ShadingSequenceRep;
ShadingSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF REF Shading
];
CtlPtInfo:    TYPE ~ RECORD [
coord:       CtlPoint ← [],
shade:       Shading ← [],
vtxPtr:      NAT ← 0,
data:       REFNIL
];
CtlPtInfoSequence: TYPE ~ REF CtlPtInfoSequenceRep;
CtlPtInfoSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF REF CtlPtInfo
];
CtlPtInfoProc:  TYPE ~ PROC [context: Context, vtx: CtlPtInfo, data: REF ANYNIL]
         RETURNS [CtlPtInfo];
CtlPtToRealSeqProc: TYPE ~ PROC [dest: RealSequence, source: CtlPtInfo, data: REFNIL]
        RETURNS [RealSequence];
Patch Definitions
FacingDir:   TYPE ~ {front, back, unknown};
Patch:     TYPE ~ RECORD [
type:       ATOMNIL,
oneSided:      BOOLTRUE,
nVtces:      NAT ← 0,
clipState:      ClipState ← unknown,
dir:       FacingDir ← unknown,
renderData:     REF RenderData,
props:       PropList ← NIL,
ctlPt:       SEQUENCE maxLength: NAT OF CtlPtInfo
];
Implemented patch types: $ConvexPolygon, $Bezier; props usage: $Shape (parent shape)
PatchSequence:  TYPE ~ REF PatchSequenceRep;
PatchSequenceRep: TYPE ~ RECORD [
length:      CARDINAL ← 0,
element:      SEQUENCE maxLength: CARDINAL OF REF Patch
];
PatchProc:   TYPE ~ PROC [context: Context, patch: REF Patch, data: REF ANYNIL]
          RETURNS [REF Patch];
Shape Definitions
Shape:     TYPE ~ G3dShape.Shape;
ShapeSequence:  TYPE ~ G3dShape.ShapeSequence;
Hierarchy:   TYPE ~ G3dHierarchy.Hierarchy;
RenderData:   TYPE ~ RECORD [      -- becomes shape.renderData 
class:       REF ShapeClass ← NIL,  -- surface type, display procs
shadingClass:    REF ShadingClass ← NIL, -- shading parameters and procs
props:       PropList ← NIL,    -- catchall ($LinesList, $Hidden)
shadingProps:    PropList ← NIL,    -- shading status and parameters
patch:       PatchSequence ← NIL,  -- built from vertex and surface data
patchesValid:    BOOLFALSE     -- FALSE if patches need update
];
Uses for RenderData.props: $ClippedPatches, $ClippedVertices, $Hidden, $LinesList,
Uses for RenderData.fixedProps:
$Closed, $PatchColors, $PatchColorsInFile, $PatchInfo, $PatchNormalsInFile, $PatchTransmittancesInFile, $VertexColorsInFile, $VertexNormalsInFile, $VertexTextureInFile, $VertexTransmittanceInFile
Uses for RenderData.shadingProps:
$AuxiliaryVtxData, $PolygonInfoComputed, $Scale, $ShapeLerp, $TextureScale, $TxtrCoordParams, $TxtrCoordRange, $TxtrCoordType, $TxtrTranslation, $VtxInfoComputed
ShadingClass:  TYPE ~ RECORD [
type:       ATOMNIL,     -- defaults to $Default
renderMethod:    REFNIL,      -- RenderStyle or ShapeProc
color:       RGB ← [0.7, 0.7, 0.7],   -- of shape, mixable w/ vertex color
diffuseReflectivity:   REAL ← 1.0,     -- diffuse reflection coefficient
specularReflectivity:  REAL ← 1.0,     -- specular reflection coefficient
metallicity:     REAL ← 1.0,     -- 0 = plastic, 1 = metallic
shininess:     REAL ← 0.0,      -- hilight exp., usu 30-300, (0=none)
clientShadingData:   REF ANYNIL,    -- client-defined shading info
transmittance:    REAL ← 0.0,     -- surface transmittance of object
texture:      LIST OF REF ANYNIL, -- textureMap, solid texture, etc.
textureScale:     Pair ← [1.0, 1.0],    -- texture coordinates scale factors
bumpScale:     REAL ← 1.0,     -- scale factor for bump height
cnvrtVtx:      CtlPtToRealSeqProc ← NIL, -- convert vertex to real sequence
getColor:      SpotProc ← NIL,    -- calculates shade at pixel
shadeVtx:      CtlPtInfoProc ← NIL   -- calculates shade from vertex info
];    
ShapeClass:   TYPE ~ RECORD [
type:       ATOMNIL,    -- $ConvexPolygon, $Bezier, $Light, etc
validate:      ShapeProc ← NIL,  -- update vertices, shading after change
display:      ShapeProc ← NIL,  -- display shape (speed optimized?)
displayPatch:     PatchProc ← NIL,   -- display patch
doBeforeFrame:    LIST OF ShapeProc ← NIL-- do before disp. (for animation, etc)
];
ShapeProc:   TYPE ~ PROC [context: Context, shape: Shape, data: REF ANYNIL]
        RETURNS [Shape];
Light Definitions
Light:     TYPE ~ G3dLight.Light;
LightSequence:  TYPE ~ G3dLight.LightSequence;
Context Definition
RenderStyle: TYPE ~ {
faceted, smooth, lines, shadedLines, hiddenLines, linesWnormals, controlPoints};
DisplayMode: TYPE ~ {gray, dither, fullColor};
Context:  TYPE ~ REF ContextRep;
ContextRep: TYPE ~ RECORD [
Miscellany
class:    REF ContextClass ← NIL,
stopMe:    REF BOOLNIL,  -- stop flag for bailing out (ref for inheritance)
imageReady:  BOOLFALSE,   -- flag for useable image in display
changed:   BOOLTRUE,    -- call ValidateContext if true
clientData:  REF ANYNIL,   -- data storage for a client
Scene description
shapes:    ShapeSequence ← NIL, -- current collection of shapes and lights
visibleShapes:  ShapeSequence ← NIL, -- computed by ValidateContext
lightSources:  LightSequence ← NIL, -- computed by ValidateContext
hierarchy:  Hierarchy ← NIL,  -- shapes organized in a tree hierarchy
frameNumber:  NAT ← 0,     -- current frame for animation routines
environment:  PropList ← NIL,   -- for reflection map, ambient light proc, etc.
View description
eyePoint:   Triple ← [1.0, -5.0, 2.0], -- defines 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 direction of view
upDirection:   Triple ← [0.0, 0.0, 1.0], -- defines "heads-up" direction (redundant)
fieldOfView:  REAL ← 40.0,    -- horizontal angle included in field of view
window:    REF Rectangle ← NIL, -- window clips field of view in eyespace
hitherLimit:   REAL ← 1.0,    -- anything closer to eyepoint is clipped
yonLimit:   REAL ← 1000.0,   -- anything further from eyepoint is clipped
clippingPlanes:  ARRAY SixSides OF Quad, -- computed clip planes
eyeSpaceXfm:  Matrix ← NIL,   -- world space to eyespace
eyeToNdc:   ScaleAndAddXfm ← IdentityXfm, -- eyespace to normalized disp. coords
ndcToPixels:   ScaleAndAddXfm ← IdentityXfm, -- to screen coords
Display description
viewer:    Viewer,     -- viewer record if in Viewer ELSE NIL
terminal:    Virtual ← NIL,   -- virtual terminal for this context, if displayed
displayInValid:  BOOLTRUE,    -- true whenever display parameter updated
pixels:    PixelMap ← NIL,   -- where the bits are
pixelAspectRatio: REAL ← 1.0,    -- physical width/height of displayed pixel
viewPort:   REF Rectangle ← NIL, -- viewport in floating pt. display coordinates
preferredViewPort: Rectangle ← [0., 0., 65536., 65536.], -- maximum viewport size
screenExtent:  Box ← [[0, 0], [0, 0]],  -- bounds area used (while building image)
preferredRenderMode: ATOMNIL,   -- $Pixels, $Imager (fancy vs. device indep.)
displayProps:  PropList ← NIL,   -- $Depth, $Alpha (Pixel posn),
             -- $FullDisplayMemory, $ViewerAdjusted
Rendering Style
autoRedraw:   BOOLFALSE,   -- quick image hint, redraw if viewer changes
delayClear:   BOOLFALSE,   -- delay clearing buffer when rendering
doVisibly:   BOOLTRUE,   -- build image on display
antiAliasing:  BOOLFALSE,   -- flag for antialiasing and alpha buffer
depthBuffering: BOOLFALSE,   -- buffer for cheap hidden-surface removal
depthResolution: NAT ← 8192,     -- number of buckets for depth sorting
sortSequence:  REFNIL,    -- shapes or surfaces sorted for display
props:    PropList ← NIL   -- catchall, global uses:
        $WDir    - working directory
        $Log     - log file for messages
        $BackGround  - background color or context (images)
        $DitherContext  - for dithering RGB to pseudocolor
        $OutputFile  - output file for interpress or animation
        $ImagerCtx   - context for Imager calls, if no viewer
        $SortToPriority  - forces priority sort, poly intersections
];
ContextClass: TYPE ~ RECORD [
displayType:   ATOMNIL,  -- includes:
            $PseudoColor,
            $Gray,
            $FullColor,
            $ImagerGray
            $ImagerDithered,
            $ImagerFullClr,
            $Bitmap,
            $Interpress
setUpDisplayType: ContextProc,   -- ensures there are bits to write, sets up colors
validateDisplay:  ContextProc,  -- makes sure viewPort changes, etc. take effect
render:    ContextProc,  -- call this to display the scene
loadBackground:  ContextProc,  -- clear to background
 2d drawing primitives use normalized display coordinates (-1.0 < x < 1.0, -.75 < y < .75)
draw2DLine:   PROC [context: Context, p1, p2: Pair, color: Pixel], -- display a line
draw2DPolygon:  PROC [context: Context, poly: PairSequence, color: Pixel],
draw2DRope:   PROC [context: Context, rope: ROPE, position: Pair,
         color: Pixel ←[255,255,128,0,0], size: REAL �, font: ROPENIL],
displayPolygon:   PatchProc,         -- 3 dimensional shading 
drawInViewer:  PROC [context: Context, procRec: REF ImagerProcRec],
updateViewer:  ContextProc
];
ContextProc:  TYPE ~ PROC [context: Context, data: REF ANYNIL];
ImagerProc:  TYPE ~ PROC [context: Context, imagerCtx: Imager.Context, data: REFNIL];
ImagerProcRec: TYPE ~ RECORD [proc: ImagerProc, data: REF ANYNIL];
RopeProc:   TYPE ~ PROC [
       context: Context,
       rope: ROPE,
       position: Pair,
       color: Pixel ← [255, 255, 255, 0, 0],
       size: REAL ← 20,
       font: ROPENIL];
Classes Registration
RegisterDisplayClass: PROC [class: ContextClass, type: ATOM];
Add class to list of registered ContextClasses, containing display-specific procs, etc.
GetDisplayClass: PROC [type: ATOM] RETURNS [class: ContextClass];
Retrieve registered class for use or modification.
LoadDisplayClass: PROC [context: Context, type: ATOM];
Set proper color map and rendering procs.
RegisterShapeClass: PROC [class: ShapeClass, type: ATOM];
Add class to list of registered ShapeClasses, containing surface-specific procs, etc.
GetShapeClass: PROC [type: ATOM] RETURNS [class: ShapeClass];
Retrieve registered class for use or modification.
LoadShapeClass: PROC [shape: Shape, type: ATOM];
Load ShapeClass (patch expansion and rendering procs) and ShadingClass for surface type.
Context
Create: PROC RETURNS [Context];
Allocate a context.
CreateUndisplayedContext: PROC [
oldContext: Context ← NIL,
width: NAT ← 1024,
height: NAT ← 768,
displayMode: DisplayMode ← fullColor,
keepLog: BOOLFALSE]
RETURNS [context: Context];
Return a context with memory allocated for the indicated number of pixels.
If oldContext is not NIL then copy existing scene, background, lights, etc. from it,
otherwise initialize context to standard defaults and set RGB background to [0.2, 0.2, 0.7].
InitializeRawColorDisplayContext: PROC [
antiAliasing: BOOLTRUE,
background: RGB ← [0.2, 0.2, 0.7],
displayMode: DisplayMode ← gray]
RETURNS [context: Context];
Return an initialized Context (one light source, nominal viewpoint).
This call will utilize the entire color display without the Viewers mechanism.
StoreImage: PUBLIC PROC [
context: Context,
fileName: ROPE,
sequenceNo: NATLAST[NAT],
log: BOOLFALSE,
abekasFormat: BOOLFALSE];
Store the image last computed by the context to the file indicated.
A sequence number may be specified if the image is a frame from an animation.
If abekas true, then RGB (Abekas) format is written to the file.
If log, then a message is appended to the log file (named <fileName-root>.log).
CloseDisplay: PROC [context: Context];
Shut down display gracefully, restore standard color map.
CloseColorViewers: PROC;
Close any open viewers on the color display.
KillUntitledColorViewers: PROC;
Kill any untitled color viewers (presumably the unwanted G3dRender viewer).
GetTmpContext: PUBLIC PROC [srcCtx: Context] RETURNS[dstCtx: Context];
Copies context so temporary modifications can be made (don't change shapes however.
CopyContextData: PUBLIC PROC [dstCtx, srcCtx: Context];
Copies REFed data to dstCtx to insulate srcCtx from changes (except for shapes).
CopyContextShapes: PUBLIC PROC [dstCtx, srcCtx: Context];
Copies shape data to dstCtx to insulate srcCtx shapes from changes.
View
SetViewFromParameters: PROC [
context: Context,
fieldOfView: REAL ← 40.0,
scale: REAL ← 1.0,
moves, rotates: Triple ← []];
Set the context view according to parameters. If fieldOfView = 0, it will be set to 40.
SetView: PROC [
context: Context,
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 context view according to camera geometry. If fieldOfView = 0, it will be set to 40.
SetViewPort: PROC [context: Context, size: Rectangle];
Display full image (with possibly diferent aspect ratio) in portion of screen.
SetWindow: PROC[context: Context, size: Rectangle];
Display only that part of full-screen image which lies within the window.
Lighting
SetAmbientLight: PROC [context: Context, rgb: RGB];
Set the ambient lighting for context.
NameAmbientLight: PROC [context: Context, color: ROPE];
Set ambient light color using color naming scheme.
GetAmbientLight: PROC [context: Context] RETURNS [RGB];
Return the ambient lighting for context.
AddLight: PROC [
context: Context, name: ROPE, position: Triple, color: RGB ← [1, 1, 1], type: ATOM ← $Default];
Install a new light source in the scene, or change a previously named one.
DeleteLight: PROC [context: Context, name: ROPE];
Remove an existing light source from the scene.
DeleteAllLights: PROC [context: Context];
Remove all existing light sources from the scene.
LightsFromContext: PROC [context: Context] RETURNS [LightSequence];
Create a light sequence from those context shapes that are lights.
LightsToContext: PROC [lights: LightSequence, context: Context];
Set the context lights.
Background
NameBackgroundColor: PROC [context: Context, color: ROPE];
Set background color using color naming scheme.
SetBackgroundColor: PROC [context: Context, color: RGB];
Set background color.
GetBackgroundColor: PROC [context: Context] RETURNS [color: RGB];
Return the background for context.
SetBackgroundImage: PROC [context: Context, aisFile: ROPE];
Use named AIS file as background image for scene instead of solid color.
GetBackgroundImage: PROC [context: Context] RETURNS [ROPE];
Return the name of the background image (NIL if none).
SetBackgroundContext: PROC [context, bkGrdCtx: Context];
Use named 3d context as background image for scene (contexts may be stacked arbitrarily).
EnableClear: PROC [context: Context, on: BOOL];
Enable clearing before rendering; if disabled (on = FALSE) images may be composited using successive renderings.
DontMatteBackground: PROC [context: Context];
Prevents final background matte step thereby preserving alpha buffer.
Shapes
AddShape: PROC [context: Context, shape: Shape];
Add a shape to the context.
AddShapeFromFile: PROC [
context: Context,
shapeName: ROPE,
fileName: ROPE,
position: Triple ← [0.0, 0.0, 0.0]];
Convenience function for reading in a shape from a file and positioning it in a scene;
clones previously read shape if file has been used before.
FindShape: PROC [context: Context, shapeName: ROPE] RETURNS [Shape];
Return the named shape; raises SIGNAL $MisMatch if shape not found.
ShapeFromRope: PROC [
name: ROPENIL,
message: ROPE,
color: ROPENIL,
size: REAL ← 0.5,
font: ROPENIL]
RETURNS [Shape];
Build a shape to display a message within the scene.
Shape is two-dimensional, always facing the eyepoint, but changes in size with perspective.
ChangeRopeMessage: PUBLIC PROC [context: Context, shapeName: ROPE, newMessage: ROPE];
Changes the message displayed for a rope shape.
DeleteShape: PROC [context: Context, shapeName: ROPE];
Removes a shape from a context.
DeleteAllShapes: PROC [context: Context];
Delete all shapes (whose name does not begin with "Light") from context.
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 [
context: Context,
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.
Internal Shape Structures for Rendering
RenderDataFrom: PROC [shape: Shape] RETURNS [REF RenderData];
Return the renderData for this shape.
ShapeClassFrom: PROC [shape: Shape] RETURNS [REF ShapeClass];
Return the shapeClass for this shape.
ShadingClassFrom: PROC [shape: Shape] RETURNS [REF ShadingClass];
Return the shadingClass for this shape.
PatchesFrom: PROC [shape: Shape] RETURNS [PatchSequence];
Get shape.renderData.patch, the patch-by-patch description, of the surface, conveniently.
Textures
SetTextureMap: PROC [
context: Context,
shapeName: ROPE,
aisName: ROPE,
textureStyle: TextureStyle ← intensity,
textureFiltering: BOOLFALSE]
RETURNS [error: ROPE];
Read in the appropriate texture map for the given shape.
Uses summed area tables if textureFiltering, else point sampling.
OffsetTextureCoords: PROC [shape: Shape, offset: Pair];
Offset the texture coordinates for the given shape.
GetTextureInfo: PROC [shape: Shape] RETURNS [LIST OF TextureInfo];
Return a list of texture information associated with the shape.
ScaleTexture: PROC [context: Context, shape: Shape, scale: Pair];
Scale the texture coordinates associated with shape.
SetTextureScale: PROC [shape: Shape, scale: Pair ← [1.0, 1.0]];
Set the texture scale for the given shape.
GetTextureScale: PROC [shape: Shape] RETURNS [Pair ← [1.0, 1.0]];
Return the texture scale for the given shape.
SetTextureRange: PROC [shape: Shape, textureRange: Pair];
Permits circumvention of seam matching in G3dMappedAndSolidTexture.AdjustTexture.
textureRange should exceed twice the texture range for all polygons in shape.
SetTextureFiltering: PROC [context: Context, shape: Shape, on: BOOL];
Turn on/off the texture filtering for the given shape.
GetBumpScale: PROC [shape: Shape] RETURNS [REAL];
Return the bump scale factor for the given shape.
SetBumpScale: PROC [shape: Shape, scale: REAL ← 1.0];
Set the bump scale factor for this shape.
Rendering
StartLog: PROC [context: Context] RETURNS[IO.STREAM];
Open typescript log.
FlushLog: PROC [context: Context];
For safety from potential disasters.
    
CloseLog: PROC [context: Context];
Close when done to flush.
Render: PROC [context: Context, fork: BOOLTRUE];
Perform the rendering process.
RendertoAISFile: PROC [context: Context, name: ROPE, fork: BOOLTRUE];
Render and then store as indicated AIS file
WaitTilRenderDone: PROC;
Wait until a rendering process finishes.
NotRendering: PROC [context: Context] RETURNS [BOOL];
Return true iff context is not forked or not rendering.
AbortRender: PROC [context: Context];
Abort any current rendering within context.
GetDisplayMode: PROC [context: Context] RETURNS [DisplayMode];
Return the display mode.
SetAntiAliasing: PROC [context: Context, on: BOOLTRUE];
This will draw images using the alpha buffer; texture mapping is enabled.
AntiAliasingNeeded: PROC [context: Context] 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 [context: Context, type: ATOM] RETURNS [SampleMap];
Get a sample map from the context; returns NIL if no such map.
GetAlphaBuffer: PROC [context: Context] RETURNS [SampleMap];
Get the alpha buffer from the context; returns NIL if no such buffer.
GetDepthBuffer: PROC [context: Context] RETURNS [SampleMap];
Get the depth buffer from the context; returns NIL if no such buffer.
Miscellany
PrependWorkingDirectory: PROC [context: Context, file: ROPE] RETURNS [ROPE];
Prepend working directory saved in context to the given file name, if the file name is local.
TackOnExtension: PROC [file, extension: ROPE] RETURNS [ROPE];
Append extension to the file name.
GetLogFileName: PUBLIC PROC[fileRoot: Rope.ROPE] RETURNS[Rope.ROPE];
Gets name of log file for updating animation status
PasteInSequenceNo: PUBLIC PROC[fileRoot: Rope.ROPE, number: NAT] RETURNS[Rope.ROPE];
Adds sequence number to file root name, just before extension, for animations
PasteInLabel: PROC[fileRoot: Rope.ROPE, label: Rope.ROPE] RETURNS[Rope.ROPE];
Puts supplied label before file name extension, for adding "-red, -grn, -blu" etc.
IntersectRectangles: PROC [Rectangle, Rectangle] RETURNS [Rectangle];
Return intersection (overlapping) portion of combined rectangles.
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.