(FILECREATED "12-MAR-83 16:31:43" {PHYLUM}<BLUEBONNET>GRAPHICSDISPLAY.;1 11670  

      changes to:  (FNS DisplayFrameListAsOverlay)

      previous date: " 4-MAR-83 12:27:56" {PHYLUM}<DMRUSSELL>GRAPHICS>GRAPHICSDISPLAY.;14)


(PRETTYCOMPRINT GRAPHICSDISPLAYCOMS)

(RPAQQ GRAPHICSDISPLAYCOMS ((FNS ApplyTransform CreateSimpleAnimation DisplayCurrentScene DisplayFace 
				 DisplayFrameList DisplayFrameListAsOverlay DisplayObject 
				 DisplayObject1 DisplayProjLineList DisplaySubassembly FindMaxXOfObj 
				 FindMaxYOfObj FindMinXOfObj FindMinYOfObj FindMaxYOfObj 
				 InterpolateBetweenFrames MakeNewLine ObjectP)
	(VARS (DEBUGFLG NIL))))
(DEFINEQ

(ApplyTransform
  [LAMBDA (transform object)                                 (* edited: "27-FEB-83 14:02")
    (PROG NIL
          (COND
	    ((EQ transform identityMatrix)
	      (RETURN object)))                              (* otherwise, MatMult each point in object by the 
							     transform matrix.)
          [SETQ tmp (for face in (fetch (GRAPHICSOBJECT FACELIST) of object)
		       collect (create FACE
				       COLOR ←(fetch (FACE COLOR) of face)
				       LINELIST ←(for line in (fetch (FACE LINELIST) of face)
						    collect (MakeNewLine transform line]
          (RETURN (create GRAPHICSOBJECT
			  NAME ←(fetch (GRAPHICSOBJECT NAME) of object)
			  FACELIST ← tmp])

(CreateSimpleAnimation
  [LAMBDA (obj rotx roty rotz numberOfFrames rotPt)          (* edited: " 9-JAN-83 09:19")
    (PROG NIL
          [COND
	    ((NULL rotPt)
	      (SETQ rotPt (create POINT
				  X ← 0
				  Y ← 0
				  Z ← 0]
          [SETQ tmp (for i from 1 to numberOfFrames
		       collect (PRINT i)
			       (ConvertObjectToLineSet (TranslateObject (FastRotate obj
										    (ITIMES rotx i)
										    (ITIMES roty i)
										    (ITIMES rotz i))
									(fetch X of rotPt)
									(fetch Y of rotPt)
									(fetch Z of rotPt]
          (RETURN (create FRAMELIST
			  LINESETLIST ← tmp])

(DisplayCurrentScene
  [LAMBDA (ds)                                               (* edited: " 5-JAN-83 14:45")
    (for elt in currentScene do (DisplaySubassembly elt ds])

(DisplayFace
  [LAMBDA (face ds transX transY)                            (* edited: "30-DEC-82 20:06")
    (PROG NIL
          (COND
	    ((NULL ds)
	      (SETQ ds myDS)))
          (COND
	    ((NULL transX)
	      (SETQ transX 0)))
          (COND
	    ((NULL transY)
	      (SETQ transY 0)))
          (for line in (fetch LINELIST of face) do (DRAWLINE (IPLUS (fetch X1 of line)
								    transX)
							     (IPLUS (fetch Y1 of line)
								    transY)
							     (IPLUS (fetch X2 of line)
								    transX)
							     (IPLUS (fetch Y2 of line)
								    transY)
							     1 NIL ds])

(DisplayFrameList
  [LAMBDA (frames ds interFrameWait)                         (* edited: " 9-JAN-83 09:27")
                                                             (* frames is a list of PROJLINE-s.
							     Your job: Throw them up on the ds as quickly as 
							     possible.)
    (PROG ([scratchBM (BITMAPCREATE (fetch WIDTH of (WINDOWPROP ds (QUOTE REGION)))
				    (fetch HEIGHT of (WINDOWPROP ds (QUOTE REGION]
	   (dsp (DSPCREATE))
	   waitTime)
          (DSPDESTINATION scratchBM dsp)
          (COND
	    ((NULL interFrameWait)
	      (SETQ interFrameWait 0)))
          (for f in (fetch LINESETLIST of frames) as i from 1 to (LENGTH (fetch LINESETLIST
									    of frames))
	     do (SETQ startTime (CLOCK))
		(DisplayProjLineList f dsp)
		(SETQ waitTime (IDIFFERENCE interFrameWait (IDIFFERENCE (CLOCK)
									startTime)))
		(COND
		  ((AND (LESSP waitTime 0)
			(NEQ interFrameWait 0))
		    (VIDEOCOLOR T)))
		(DISMISS waitTime)
		(BITBLT scratchBM NIL NIL ds NIL NIL NIL NIL NIL (QUOTE REPLACE))
		(CLEAR dsp))
          (VIDEOCOLOR NIL])

(DisplayFrameListAsOverlay
  [LAMBDA (frames ds interFrameWait eraseFinalFrameFlag)     (* edited: "12-MAR-83 16:30")

          (* frames is a list of PROJLINE-s. Your job: Throw them up on the ds as quickly as possible.
	  This is a modification of DisplayFrameList -- this one is supposed to live happily with anything that is currently
	  painted on the screen)


    (PROG (waitTime (previousFrame NIL))
          (if interFrameWait=NIL
	      then interFrameWait←0)
          (for f in frames:LINESETLIST as i from 1 to (LENGTH frames:LINESETLIST)
	     do (startTime←(CLOCK)
		  (if previousFrame
		      then (DisplayProjLineList previousFrame ds 1 (QUOTE INVERT)))
		  (DisplayProjLineList f ds 1 (QUOTE INVERT))
		  previousFrame←f
		  waitTime←interFrameWait-((CLOCK)
		   -startTime)
		  (DISMISS waitTime)))
          (if eraseFinalFrameFlag
	      then (DisplayProjLineList previousFrame ds 1 (QUOTE INVERT])

(DisplayObject
  [LAMBDA (obj ds centeredFlg offsetX offsetY)               (* edited: " 4-JAN-83 13:58")
    (PROG NIL
          (DisplayObject1 (fetch FACELIST of obj)
			  ds centeredFlg offsetX offsetY])

(DisplayObject1
  [LAMBDA (obj ds centeredFlg offsetX offsetY)               (* edited: " 4-JAN-83 13:57")
    (PROG (maxX maxY minX minY centerX centerY centerWindowX centerWindowY)
          (COND
	    ((NULL ds)
	      (SETQ ds myDS)))
          (COND
	    ((NULL offsetX)
	      (SETQ offsetX 0)))
          (COND
	    ((NULL offsetY)
	      (SETQ offsetY 0)))
          [COND
	    (centeredFlg (SETQ maxX (FindMaxXOfObj obj))
			 (SETQ maxY (FindMaxYOfObj obj))
			 (SETQ minX (FindMinXOfObj obj))
			 (SETQ minY (FindMinYOfObj obj))
			 (SETQ centerX (IQUOTIENT (IPLUS maxX minX)
						  2))
			 (SETQ centerY (IQUOTIENT (IPLUS maxY minY)
						  2))
			 (SETQ centerWindowX (IQUOTIENT (WINDOWPROP ds (QUOTE WIDTH))
							2))
			 (SETQ centerWindowY (IQUOTIENT (WINDOWPROP ds (QUOTE HEIGHT))
							2))
			 (SETQ offsetX (IDIFFERENCE centerWindowX centerX))
			 (SETQ offsetY (IDIFFERENCE centerWindowY centerY]
          (for face in obj do (COND
				((ObjectP face)
				  (DisplayObject1 face ds centeredFlg offsetX offsetY))
				(T (COND
				     ((NOT (EQUAL -1 (fetch (FACE COLOR) of face)))
				       (DisplayFace face ds offsetX offsetY])

(DisplayProjLineList
  [LAMBDA (pll ds width operation)                           (* edited: " 4-MAR-83 09:12")
    (for l in pll do (DRAWLINE l:PX1 l:PY1 l:PX2 l:PY2 width operation ds])

(DisplaySubassembly
  [LAMBDA (sub ds)                                           (* edited: " 5-JAN-83 14:48")
    (PROG (obj)
          (if sub:SUBASSEMBLY.OBJECT~=NIL
	      then obj←(ApplyTransform sub:TRANSFORM sub:SUBASSEMBLY.OBJECT)
		   (DisplayObject obj ds)
	    else (for elt in sub:SUBASSEMBLYLIST do (DisplaySubassembly elt ds])

(FindMaxXOfObj
  [LAMBDA (obj)                                              (* edited: "30-DEC-82 20:06")
                                                             (* return the largest Y value in this obj)
    (PROG ((max -999999)
	   face)
          [for face in obj do (for line in (fetch LINELIST of face)
				 do (SETQ max (MAX (fetch X1 of line)
						   (fetch X2 of line)
						   max]
          (RETURN max])

(FindMaxYOfObj
  [LAMBDA (obj)                                              (* edited: "30-DEC-82 20:08")
                                                             (* return the largest Y value in this obj)
    (PROG ((max -999999)
	   face)
          [for face in obj do (for line in (fetch LINELIST of face)
				 do (SETQ max (MAX (fetch Y1 of line)
						   (fetch Y2 of line)
						   max]
          (RETURN max])

(FindMinXOfObj
  [LAMBDA (obj)                                              (* edited: "30-DEC-82 20:10")
                                                             (* return the largest Y value in this obj)
    (PROG ((min 999999)
	   face)
          [for face in obj do (for line in (fetch LINELIST of face)
				 do (SETQ min (MIN (fetch X1 of line)
						   (fetch X2 of line)
						   min]
          (RETURN min])

(FindMinYOfObj
  [LAMBDA (obj)                                              (* edited: "30-DEC-82 20:08")
                                                             (* return the largest Y value in this obj)
    (PROG ((min 999999)
	   face)
          [for face in obj do (for line in (fetch LINELIST of face)
				 do (SETQ min (MIN (fetch Y1 of line)
						   (fetch Y2 of line)
						   min]
          (RETURN min])

(FindMaxYOfObj
  [LAMBDA (obj)                                              (* edited: "30-DEC-82 20:08")
                                                             (* return the largest Y value in this obj)
    (PROG ((max -999999)
	   face)
          [for face in obj do (for line in (fetch LINELIST of face)
				 do (SETQ max (MAX (fetch Y1 of line)
						   (fetch Y2 of line)
						   max]
          (RETURN max])

(InterpolateBetweenFrames
  [LAMBDA (frame1 frame2 i numInterFrames)                   (* edited: " 4-MAR-83 08:44")
                                                             (* given 2 frames, compute the i-th frames out of 
							     numInterFrames between them and return it as a frame.)
    (PROG NIL
          (coef←(FQUOTIENT i-1 numInterFrames))
          (RETURN (for line1 in frame1 as line2 in frame2
		     collect (create PROJLINE
				     PX1 ←(FPLUS line1:PX1 (FTIMES coef (FDIFFERENCE line2:PX1 
										     line1:PX1)))
				     PY1 ←(FPLUS line1:PY1 (FTIMES coef (FDIFFERENCE line2:PY1 
										     line1:PY1)))
				     PX2 ←(FPLUS line1:PX2 (FTIMES coef (FDIFFERENCE line2:PX2 
										     line1:PX2)))
				     PY2 ←(FPLUS line1:PY2 (FTIMES coef (FDIFFERENCE line2:PY2 
										     line1:PY2])

(MakeNewLine
  [LAMBDA (transform line)                                   (* edited: " 5-JAN-83 14:59")

          (* given a transform as a matrix and a line, create two new mats for each point, and MatMult.
	  Recompose into a line and return the new line.)


    (PROG (pt1 pt2 newpt1 newpt2)
          (pt1←(ARRAY 4))
          (pt2←(ARRAY 4))
          (newpt1←(ARRAY 4))
          (newpt2←(ARRAY 4))
          ((ELT pt1 1)←X1)
          ((ELT pt1 2)←Y1)
          ((ELT pt1 3)←Z1)
          ((ELT pt1 4)←1)
          ((ELT pt2 1)←X2)
          ((ELT pt2 2)←Y2)
          ((ELT pt2 3)←Z2)
          ((ELT pt2 4)←1)
          (MatMult pt1 transform newpt1)
          (MatMult pt2 transform newpt2)
          (RETURN (create LINE
			  X1 ←(ELT pt1 1)
			  Y1 ←(ELT pt1 2)
			  Z1 ←(ELT pt1 3)
			  X2 ←(ELT pt2 1)
			  Y2 ←(ELT pt2 2)
			  Z2 ←(ELT pt2 3])

(ObjectP
  [LAMBDA (X)                                                (* edited: "12-OCT-82 14:11")
                                                             (* return T if the CAAR of X is a point -- i.e. of 
							     length 2)
    (NOT (ATOM (fetch (FACE COLOR) of X])
)

(RPAQQ DEBUGFLG NIL)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (653 11622 (ApplyTransform 663 . 1436) (CreateSimpleAnimation 1438 . 2108) (
DisplayCurrentScene 2110 . 2306) (DisplayFace 2308 . 2967) (DisplayFrameList 2969 . 4118) (
DisplayFrameListAsOverlay 4120 . 5122) (DisplayObject 5124 . 5351) (DisplayObject1 5353 . 6562) (
DisplayProjLineList 6564 . 6771) (DisplaySubassembly 6773 . 7157) (FindMaxXOfObj 7159 . 7639) (
FindMaxYOfObj 7641 . 8121) (FindMinXOfObj 8123 . 8602) (FindMinYOfObj 8604 . 9083) (FindMaxYOfObj 9085
 . 9565) (InterpolateBetweenFrames 9567 . 10437) (MakeNewLine 10439 . 11318) (ObjectP 11320 . 11620)))
))
STOP