Key

From MHCGraphics

Jump to: navigation, search
; Mead example file -- a key
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
; February 24, 2008
;
; $Id: Key.scm 504 2008-02-25 03:35:47Z terescoj $
;
(require (lib "Defs.ss" "Mead"))

; first, build the basic framework of a key with a round head
; the key is height 150 from end to end and is defined aligned
; along the y-axis, with the head at the top
(object keyBlankPart Group
        (add cube 
             (compose
              (scale .2 1 .05)
              (translate 0 50 0)
              )
             )
        (add cylinder
             (compose
              (xRot 90)
              (scale .6 .6 .05)
              (translate 0 120 0)
              )
             )
        )

; now drill a keyhole and shave off the end of the key to make it pointed
(object keyBlank Difference
        (add keyBlankPart)
        ; the hole
        (add cylinder
             (compose
              (xRot 90)
              (scale .15 .15 1)
              (translate 0 137 0)
              )
             )
        ; angled cut at the base of the key
        (add cube
             (compose
              (zRot 45)
              (scale .2 .2 .2)
              (translate -10 0 0)
              )
             )
        )

; now, let's make it look like a real key
(object key Difference
        (add keyBlank)
        ; cut a ridge along the front face
        (add cube
             (compose
              (scale .05 .9 .05)
              (translate 5 45 -2)
              )
             )
        ; another ridge on the back
        (add cube
             (compose
              (scale .075 .9 .05)
              (translate -5 45 2)
              )
             )
     
        ; and a few notches along the edge
        (add cube
             (compose
              (scale .05 .05 .1)
              (zRot 45)
              (translate -10 75 0)
              )
             )
        (add cube
             (compose
              (scale .1 .1 .1)
              (zRot 45)
              (translate -10 55 0)
              )
             )
        (add cylinder
             (compose
              (scale .1 .1 .1)
              (xRot 90)
              (translate -10 25 0)
              )
             )
        )

; Let's make a metallic gold material
(object goldMat Material
        (color '(.5 .3 0))
        (reflection 0.5)
        (specularity .3)
  )

; And a metallic silver material
(object silverMat Material
        (color '(.5 .5 .5))
        (reflection 0.5)
        (specularity .3)
  )

(tell image
      (background white)
      )

; add three keys in different positions to see our design
(tell scene
      (add key goldMat
           (translate 100 0 0))
      (add key silverMat
           (zRot -70)
           (yRot 20)
           (translate -100 0 0))
      (add key bluePlastic
           (xyMirror)
           (zRot 50)
           (yRot -30)
           (translate 0 -150 0))
      (add key cyanPlaster
           (yRot 70)
           (xRot 70)
           (translate 100 -100 -50))
      )

; a little extra light
(tell scene
      (add bulb (translate 100 100 -300)))

(tell camera
      (shoot))
Personal tools