TinkerToys

From MHCGraphics

Jump to: navigation, search
; Tinkertoys (c) 2007 Duane A. Bailey
; Building a ten piece Mort
(require (lib "Defs.ss" "Mead"))

; Tinkertoy constants (see tinkerAtoms.png)
(define rodDiam (/ 3 16))
(define yellowLength 2)
(define blueLength (+ 3 (/ 3 8)))
(define redLength 5)
(define greenLength 7.5)
(define capLength 0.5)
(define capDiam .3)
(define spoolDiam 1.25)
(define holeDepth 0.25) ; depth of the holes
(define innerRadius ; radius of spool below holes
  (- (/ spoolDiam 2) holeDepth))
(define spoolThick 0.5)

; Now, define everything in terms of unit cylinders
(object yellowStick Cylinder
        (translate 0 50 0)
        (scale 0.01 0.01 0.01)
        (scale rodDiam yellowLength rodDiam)
        (material yellowPlaster)
        )

(object blueStick Cylinder
        (translate 0 50 0)
        (scale 0.01 0.01 0.01)
        (scale rodDiam blueLength rodDiam)
        (material bluePlaster)
        )

(object redStick Cylinder
        (translate 0 50 0)
        (scale 0.01 0.01 0.01)
        (scale rodDiam redLength rodDiam)
        (material redPlaster)
        )

(object greenStick Cylinder
        (translate 0 50 0)
        (scale 0.01 0.01 0.01)
        (scale rodDiam greenLength rodDiam)
        (material greenPlaster)
        )

(object orangePlaster Material
        (type 'plaster)
        (color '(1 .25 0))
        )

(object cap Cylinder
        (translate 0 50 0)
        (scale 0.01 0.01 0.01)
        (scale capDiam capLength capDiam)
        (material orangePlaster)
        )

(object spool Cylinder
        (xRot 90)
        (scale 0.01 0.01 0.01)
        (scale spoolDiam spoolDiam spoolThick)
        (material yellowPlaster)
        )

;; And now, Mort.
; limbs: could be legs (or even arms)
; this little limb has a sock...
(object limbWCap Group
        (add blueStick)
        (add cap 
             (translate 0 (- blueLength holeDepth) 0)
             )
        )

; a pair of limbs: one gloved, one not
(object limbPair Group
        (add spool)
        (add blueStick
             (xform (translate 0 innerRadius 0)
                    (zRot 135)
                    )
             )
        (add limbWCap
             (xform (translate 0 innerRadius 0)
                    (zRot -135)
                    )
             )
        )

; Er, stylized head:
(object head Group
        (add spool)
        )

; Mort, assembled:
(object body Group
        ; legs
        (add limbPair)
        ; torso
        (add yellowStick (translate 0 innerRadius 0))
        ; arms
        (add limbPair
             (xform
                 (xRot 180)
                 (yRot 30)
                 (translate 0 (+ yellowLength
                                 (* 2 innerRadius)) 0)
                 ))
        ; head
        (add head
             (xform
              (xRot -30) ; angle of contemplation
              (translate 0
                         (+ yellowLength
                            (* 2 spoolDiam)) 0)
              )
        )
)

(tell scene
      (add body 
           (xform
            (translate 0 (/ -2 yellowLength) 0)
            (scale 20 20 20) ; whatever seems appropriate
            )
           )
      )

(tell camera
      (shoot)
      )
Personal tools