From MHCGraphics
; Mead example file -- a simple animation of a ball
; tossed from one point to another
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
;
; $Id: BallToss.scm 612 2008-04-06 01:19:20Z terescoj $
;
(require (lib "Defs.ss" "Mead"))
; Some image settings appropriate for animations
(tell image
; set the filename of the images
(fileName "BallToss")
; frameNumbers must start at 0
(frameNumber 0)
; set to #t for default behavior: view images,
; but here we only want to see the final movie
(viewResult #f)
)
; And some standard image properties
(tell image
(background '(.5 .5 1))
)
; get a new scene with my own light
(object sun Light
(intensity 1)
(translate 0 500 -500))
; and the ground
(object ground Plane
(material greenPlaster)
)
(object scene Group
(add sun)
(add ground)
)
; The object we will be animating is a white sphere,
; which we create here and add to the scene
(object ball Sphere
(material whitePlastic)
;(scale .5 .5 .5)
)
(tell scene (add ball))
; next, we define an adjustment function that sets the
; position of the ball for each frame of our film
(define (moveBall pos)
(tell ball
; absoluteXform forgets any previous
; transformations of the object.
; we have been using relativeXform (the default)
(absoluteXform
(compose
(scale .33 .33 .33)
(translate (car pos)(cadr pos)(caddr pos))
)
)
)
)
; tell the camera to film!
(tell camera
(pos '(0 100 -600))
(coi '(0 50 0))
; we send a film message which uses morph to create
; a series of values to pass to the given function.
; The parameters to morph are the lists of values
; given after the function name.
; In this case, there is just a single list, so
; moveBall has one parameter -- one set the coordinates
; returned by (morph 50 ...) on the parameters given.
(film 50 moveBall
'((-200 50 0) (-100 300 0) (100 300 0) (200 50 0)))
; now tell the camera to take the frames it just filmed
; and paste them together into a movie
(buildMovie)
)