ThreeDMisc.mesa
Last Edited by: Crow, June 3, 1986 4:17:53 pm PDT
DIRECTORY
IO USING [STREAM],
Terminal USING [Virtual],
Rope USING [ROPE],
Imager USING [Context],
ImagerColor USING [RGB],
Vector3d USING [Triple, Pair, Quad],
Pixels USING [Extent, BYTE, SampleSet],
ScanConvert USING [RealSequence, GetColorProc, IntRGB],
ThreeDScenes USING [ClipState, Context, VtxToRealSeqProc];
ThreeDMisc:
CEDAR
DEFINITIONS
~ BEGIN
Types
Context: TYPE ~ ThreeDScenes.Context;
Triple: TYPE ~ Vector3d.Triple;
Pair: TYPE ~ Vector3d.Pair; -- RECORD [ x, y: REAL];
RGB: TYPE ~ ImagerColor.RGB;
IntRGB: TYPE ~ ScanConvert.IntRGB;
Rectangle: TYPE ~ Pixels.Extent;
RealSequence: TYPE ~ ScanConvert.RealSequence;
Utility Procedures
RGBtoPixelValue: PROC[context: REF ThreeDScenes.Context, clr: RGB, values: Pixels.SampleSet]
RETURNS[ Pixels.SampleSet ]; -- get color for low-level functions
PutPixel: PROC[context: REF Context, x, y: NAT, clr: RGB]; -- a very slow way to set a pixel
ClipLineWithPlane: PROC[plane: Vector3d.Quad, p1, p2: Triple]
RETURNS[ insidePt, clippedPt: Triple, state: ThreeDScenes.ClipState ];
DrawRGBLine: PROC[context: REF Context, inP1, inP2: Triple, clr: RGB]; -- 3D lines, clipped
PrependWorkingDirectory: PROC[context: REF Context, file: Rope.ROPE] RETURNS[Rope.ROPE];
GetImagerContext: PROC[context: REF Context] RETURNS[Imager.Context];
SetViewPortFromImager: PROC[context: REF Context,
imagerCtx: Imager.Context];
CopyContextData: PROC [dstCtx, srcCtx: REF Context];
RegisterSurfaceType: PROC[context: REF Context, type: ATOM];
StartLog: PROC [context: REF Context] RETURNS[IO.STREAM];
FlushLog: PUBLIC PROC [context: REF Context];
CloseLog: PUBLIC PROC [context: REF Context];
Colors and Text
GetMappedColor: PROC[context: REF Context, clr: IntRGB]
RETURNS[Pixels.BYTE];
SetNamedColor: PROC [context: REF Context, color: Rope.ROPE];
SetRGBColor: PROC [context: REF Context, clr: RGB];
LoadStd8BitClrMap: PROC [vt: Terminal.Virtual];
Rotate8BitClrMap: PROC [vt: Terminal.Virtual, firstValue, lastValue, duration: NAT ← 0];
Show8BitClrMap: PROC [context: REF Context];
LoadColorRamp: PROC [vt: Terminal.Virtual, clr1, clr2, exponent: RGB];
LoadMultiRamps: PROC [vt: Terminal.Virtual, colors: LIST OF RGB];
AdjustValueRamp: PROC[context: REF Context, exponent: RGB];
AdjustSaturation: PROC[context: REF Context, percent: REAL];
LoadOldStd8BitClrMap: PUBLIC PROC [vt: Terminal.Virtual];
SetUpTerrainColors: PROC[vt: Terminal.Virtual];
ShowRope: PROC[context: REF Context, x, y: REAL, rope: Rope.ROPE,
fontRope: Rope.ROPE ← NIL, size: REAL ← 20];
AIS Files and Texture Images
DitherImage: PROC[dstContext, rgbContext: REF Context];
ScaleDownImage: PROC[dstContext, srcContext: REF Context];
MakeStripes: PROC[context: REF Context, numStripes, min, max, power: REAL];
MakeStretchedSpots: PROC[context: REF Context,
spotsAcross, min, max, power: REAL, stretched: BOOLEAN ← FALSE];
DrawQuad:
PROC[context:
REF Context, intensity:
REAL,
x1, y1, x2, y2, x3, y3, x4, y4:
REAL];
View and Lighting control
SetAmbientLight: PROC [context: REF Context, color: Rope.ROPE];
SetBackground: PROC [context: REF Context, color: Rope.ROPE];
GetBackground: PUBLIC PROC [context: REF Context] RETURNS [color: RGB];
Shape Manipulation
Hide: PROC[context: REF Context, shapeName: Rope.ROPE]; -- maintain data but don't display
Reveal: PROC[context: REF Context, shapeName: Rope.ROPE]; -- undo Hide
MakePlane: PROC[context: REF Context, shapeName: Rope.ROPE,
squaresPerSide: NAT];
AddShapeAt: PROC[context: REF Context, shapeName: Rope.ROPE, fileName: Rope.ROPE,
position: Triple ← [0.,0.,0.],
type: ATOM ← $ConvexPolygon, insideVisible: BOOLEAN ← FALSE ];
SetFacetedColor: PROC[context: REF Context, shapeName: Rope.ROPE, color: RGB];
SetSmoothColor: PROC[context: REF Context, shapeName: Rope.ROPE, color: RGB];
SetLinesColor: PUBLIC PROC[context: REF Context, shapeName: Rope.ROPE, color: RGB];
SetShininess: PROC[context: REF Context, shapeName: Rope.ROPE, shininess: REAL ← 12.0];
SetTransmittance: PROC[context: REF Context, shapeName: Rope.ROPE, t: REAL];
ShadingProcName: PROC[context: REF Context, shapeName, procName: Rope.ROPE ];
GetShadingProcs: PROC[context: REF Context, shapeName: Rope.ROPE,
storeProc: ThreeDScenes.VtxToRealSeqProc,
shadeProc: ScanConvert.GetColorProc];
GetNormals: PROC[context: REF Context, shapeName, normalFile: Rope.ROPE];
GetVertexColors: PROC[context: REF Context, shapeName, colorFile: Rope.ROPE];
GetPolygonColors: PROC[context: REF Context, shapeName, colorFile:Rope.ROPE];
GetTextureCoords: PROC[context: REF Context, shapeName, coordinateFile: Rope.ROPE];
Scene Manipulation
SaveOnFile: PROC[context: REF Context, fileName: Rope.ROPE];
RestoreFromFile: PROC[context: REF Context, fileName: Rope.ROPE];
MakeFrameFromFile:
PROC[context:
REF Context, fileName: Rope.
ROPE];
Renders a scene described by a file without disturbing the current scene
Frame Generation and Animation
MakeFrame: PROC[context: REF Context]; -- makes new frame from context
MakeHiResFrame:
PROC[context:
REF ThreeDScenes.Context,
-- makes new context and
width, height:
NAT, name: Rope.
ROPE];
-- outputs AIS file
Implemented in DistributedDisplayImpl.mesa
RemoteMakeFrame: PROC[context: REF ThreeDScenes.Context, numForksHint: NAT ← 0];
ShowShapes: PROC[context: REF Context]; -- adds to existing frame
ShowWireFrameShapes: PROC[context: REF Context]; -- for quick linedrawings
OrbitEye: PROC[ context: REF Context,
lookingFrom, lookingAt, axis: Triple, framesPerRev: NAT,
filename: Rope.ROPE ← NIL, numFrames: NAT ← 32767, startAt: NAT ← 0];
MakeFramesFromTo: PROC[context: REF Context,
lookingFrom, lookingAt, toLookingFrom, toLookingAt: Triple,
numFrames: NAT, startAt: NAT ← 0, filename: Rope.ROPE ← NIL];
END.