G3dAnimationSupport.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, April 21, 1989 11:38:16 am PDT
DIRECTORY Rope, G3dRender, ImagerPixel;
G3dAnimationSupport: CEDAR DEFINITIONS
~ BEGIN
Basic Types
ROPE:    TYPE ~ Rope.ROPE;
Context:    TYPE ~ G3dRender.Context;
Pair:     TYPE ~ G3dRender.Pair;
Triple:    TYPE ~ G3dRender.Triple;       -- RECORD [ x, y, z: REAL];
TripleSequence: TYPE ~ G3dRender.TripleSequence;
Shape:    TYPE ~ G3dRender.Shape;
PixelMap:   TYPE ~ ImagerPixel.PixelMap;
ViewProc:   TYPE ~ PROC[context: Context, lookingFrom, lookingAt: Triple, frameNo: NAT];
FrameSequence: TYPE ~ RECORD[ currentFrame: NAT ← 0, length: NAT,
          labels: BOOLEAN ← FALSE,
          frames: SEQUENCE maxLength: NAT OF PixelMap ];
Procedures for Storage and Playback of Image Sequences from Files
ShowAISCacheFrame: PROC[context: Context, frames: REF FrameSequence];
Shows the specified frame from a frame sequence cached in VM
PlayBackNumberedAISFiles: PROC[context: Context, fileRoot : ROPE,
         startNum, numFiles, framesPerSec, secondsPlayingTime : NAT];
Plays back a sequenced set of AIS files, cycling through the files ad nauseum
- startNum specifies the first image in the sequence to display
- numFiles specifies the number of different images to be displayed
- framesPerSec ranges from 1 up to 30 (performance is limited by bitblt speed)
- secondsPlayingTime limits the running time
Stores image on display in named file(s), non-defaulted sequence number is added to file name
CacheAISFiles: PROC[context: Context, fileOfNames: ROPE, labeled: BOOLFALSE]
     RETURNS[REF FrameSequence];
Stores a cache of images, named in a file of ROPEs, in memory for playback. Returns a handle to the cache
CacheNumberedAISFiles: PROC[context: Context, fileRoot: ROPE,
           numFiles: NAT, start: NAT ← 0, labeled: BOOLFALSE]
        RETURNS[REF FrameSequence];
Stores a cache of images, with sequentially numbered file names, in memory for flexible playback. Returns a handle to the cache. File names of the form: name0.ais, name1.ais, name64.ais, etc. Start indicates file name to begin sequence with.
PlayBackAISCache: PROC[context: Context, frames: REF FrameSequence,
        framesPerSec, secondsPlayingTime: NAT,
        bothWays: BOOLEANFALSE, startNum: NAT ← 0];
Plays back a cached set of images as above, will cycle through the sequence or run back and forth over the sequence if bothWays is set TRUE, the playback may be started in midsequence if startNum is nonzero
ShowNextAISCacheFrame: PROC[context: Context,
          frames: REF FrameSequence, framesPerSec: INTEGER ← 0];
Shows next frame in sequence, delaying enough time to ensure framesPerSec not exceeded, handy for interactive control of frame rate, negative framesPerSec shows previous frame
Procedures for Making Simple Animations
These generate a sequence of frames with options to store to files
Orbit: PROC [context: Context, lookingFrom, lookingAt, axis, base: Triple,
    moveEPNotCI: BOOLEANTRUE,
    framesPerRev: NAT ← 16, startAt: NAT ← 0, endAt: NAT ← 32767,
    filename: Rope.ROPENIL
    ];
Calculate elliptical orbit about center of interest (or eyepoint if moveEPNotCI is FALSE), write images to series of numbered files if filename # NIL
MakeFramesFromTo: PROC [context: Context,
         lookingFrom, lookingAt, toLookingFrom, toLookingAt: Triple,
         framesOnLine: NAT, startAt, endAt: NAT ← 0,
         filename: Rope.ROPENIL ];
Calculate and display (if a displayed context) frames along a straightline path
MakeFramesOnPath: PROC [context: Context, lookingFrom, lookingAt: LIST OF Triple,
         framesOnPath: NAT, startAt, endAt: NAT ← 0,
         filename: Rope.ROPENIL, closed: BOOLEANTRUE ];
Calculate and display (if a displayed context) frames along a cubic path through control points
Procedures for Eyepoint-Ctr of Interest Trajectories
These generate a sequence of positions to drive animations
MoveEyePointInOrbit: PROC[ context: Context, eyePt, lookingAt, axis, base: Triple,
          displayProc: ViewProc,
         framesPerRev: NAT, startAt, endAt: NAT ← 0 ];
MoveCtrOfInterestInOrbit: PROC[ context: Context, eyePt, lookingAt, axis, base: Triple,
           displayProc: ViewProc,
          framesPerRev: NAT, startAt, endAt: NAT ← 0 ];
MoveOnLine: PROC[ context: Context, eyePt, lookingAt, toEyePt, toLookingAt: Triple,
       displayProc: ViewProc, framesOnLine: NAT, startAt, endAt: NAT ← 0 ];
MoveOnOpenCurve: PROC[ context: Context, eyePts, lookingAts: TripleSequence,
         displayProc: ViewProc,
         framesOnCurve: NAT, startAt, endAt: NAT ← 0 ];
MoveOnClosedCurve: PROC[ context: Context, eyePts, lookingAts: TripleSequence,
         displayProc: ViewProc,
         framesOnCurve: NAT, startAt, endAt: NAT ← 0 ];
Procedures for Viewing Trajectories
ShowOpenCurve: PROC[ context: Context, eyePts, lookingAts: TripleSequence,
        numFrames: NAT, startAt: NAT ← 0 ];
ShowClosedCurve: PROC[ context: Context, eyePts, lookingAts: TripleSequence,
        numFrames: NAT, startAt: NAT ← 0 ];
ShowOrbit: PROC[ context: Context, startPt, axis, base: Triple, framesPerRev: NAT ];
Adds description of path to data for current scene, will be displayed just like any other shape. "Trajectory" is name given to resulting Shape.
Procedures for Texture Animation
SetTxtrTranslation: PROC[ context: Context, shapeName: Rope.ROPE,
        translation: Pair, frames: NAT ];
Sets up translation by [translation.x, translation.y] over "frames" frames
Procedures for Shape Interpolation
SetShapeInterpolation: PUBLIC PROC[ context: Context, shapeName: Rope.ROPE,
            begin, end: REF Shape, frames: NAT ];
Sets up interpolation between "begin" shape and "end" shape, over "frames" frames
Procedures for Registering Shape Manipulation Procedures for Animation
SetShapeManipulation: PUBLIC PROC[ context: Context, shapeName: Rope.ROPE,
            prop, propVal: REF ANY,
            proc: G3dRender.ShapeProc ];
Way of registering single procedure to be called to modify shape before each frame, clears away any previous list of procedures
AddShapeManipulation: PUBLIC PROC[ context: Context, shapeName: Rope.ROPE,
            prop, propVal: REF ANY,
            proc: G3dRender.ShapeProc ];
Way of registering additional procedure to be called to modify shape before each frame
END.