From MHCGraphics
; Mead example file - moving cubes!
; This demonstrates the ability to get handles on Mead objects
; at various times, and how to use them to animate objects
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
;
; $Id: MovingCubes.scm 624 2008-04-13 21:01:46Z terescoj $
;
(require (lib "Defs.ss" "Mead"))
(tell image
(background white)
(fileName "MovingCubes")
(frameNumber 0)
(viewResult #f)
)
; let's add some cubes, some using the default Cube, which we know
; is defined by Mead as:
; (object cube Cube)
; and some we define to have a different size
(object myCube Cube
(scale .5 .5 .5))
(define c1
(tell scene
(add cube redPlaster
(translate -100 100 0)
)
)
)
(define c2
(tell scene
(add cube bluePlaster
(translate -100 -100 0)
)
)
)
(define c3
(tell scene
(add myCube greenPlaster
(translate 100 100 0)
)
)
)
(define c4
(tell scene
(add myCube magentaPlaster
(translate 100 -100 0)
)
)
)
; define a movement function for our cubes
(define (moveCubes whichCube pos scaling yRotVal)
(tell whichCube
(absoluteXform
(compose
(yRot yRotVal)
(scale scaling scaling scaling)
(translate (car pos)(cadr pos)(caddr pos))
)
)
)
)
; another movement function
(define (relativeScaleCubes whichCube scaling)
; this one is a relativeXform, so it scales "in place"
(tell whichCube
(scale scaling scaling scaling)
)
)
(define (absoluteScaleCubes whichCube scaling)
; this one is a relativeXform, so it scales "in place"
(tell whichCube
(absoluteXform
(scale scaling scaling scaling)
)
)
)
; lots of possibilities for animations:
; try each to see what happens and understand why
(tell camera
;(film 30 moveCubes c1 '((-100 100 0)) 1 '(0 90))
;(film 30 moveCubes c2 '((-100 -100 0)) 1 '(0 90))
;(film 30 moveCubes c3 '((100 100 0)) 1 '(0 90))
;(film 30 moveCubes c4 '((100 -100 0)) 1 '(0 90))
;(film 30 relativeScaleCubes cube .9)
;(film 30 absoluteScaleCubes cube '(1 .1 1))
;(film 30 relativeScaleCubes myCube .9)
;(film 30 absoluteScaleCubes myCube '(1 .1 1))
(film 30 relativeScaleCubes c3 .9)
;(film 30 absoluteScaleCubes c3 '(1 .1 1))
(buildMovie)
)