Pyramid

From MHCGraphics

Jump to: navigation, search
; Mead example file to create a pyramid
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
; February 12, 2008
;
; $Id: Pyramid.scm 473 2008-02-13 03:42:44Z terescoj $
;
(require (lib "Defs.ss" "Mead"))

; define a polygon for the base, 100x100x100 in the xz-plane
(define base
  '((-50 0 -50) (-50 0 50) (50 0 50) (50 0 -50)))

; define a polygon for the front face
(define frontFace
  '((-50 0 -50) (0 100 0) (50 0 -50)))

; build the mesh object by adding polygons for the
; base and for each side
(object pyramid Mesh
        (addPoly base)
        (addPoly frontFace)
        (addPoly (polyXform frontFace (yRot 90)))
        (addPoly (polyXform frontFace (yRot 180)))
        (addPoly (polyXform frontFace (yRot 270)))
        )

; add a few pyramids to our scene to see what we've built
(tell scene
      (add pyramid redPlaster)
      (add pyramid greenPlaster
           (xform
            (scale 1 .5 1)
            (xRot -20)
            (translate 200 0 0)
            )
           )
      (add pyramid bluePlaster
           (xform
            (scale .4 2 .4)
            (yRot 20)
            (xzMirror)
            (translate -200 0 0)
            )
           )
      )

(tell camera
      (pos '(0 100 -500))
      (shoot))
Personal tools