From MHCGraphics
; Mead example file of a lamp
;
; Model by Duane A. Bailey, modified by Jim Teresco
;
; $Id: Lamp.scm 482 2008-02-13 18:19:36Z terescoj $
;
(require (lib "Defs.ss" "Mead"))
(define 100-watt bulb)
;
; The base of the lamp
;
(object base Group
(add cylinder (scale 1.6 0.1 1.6))
(add cone (xform (scale 1.6 0.15 1.6) (translate 0 12.5 0))))
;
; A wheel to be used for the joints of the arm
;
(object wheel Group
(add cylinder (xform (scale 0.4 0.1 0.4) (xRot 90)))
(material whitePlastic))
;
; A rectangular strut to be used for the links of the arm
;
(object strut Group
(add cube (scale 0.15 2 0.05)))
;
; A completed link for the arm is positioned with the wheel's axis at the
; origin and aligned with the Z axis, with the strut sticking up in the
; vertical direction
;
(object link Group
(add wheel)
(add strut (translate 0 100 0)))
;
; A lamp shade
;
(object lampShadeOutside Group
(add cylinder (scale 0.4 1.2 0.4))
(add cone (scale 1.2 1.2 1.2))
)
(object lampShadeInside Group
(add cone (xform
(scale 1.2 1.2 1.2)
(translate 0 -2 0)))
)
(object lampShade Difference
(add lampShadeOutside)
(add lampShadeInside)
)
;
; The little black switch
;
(object switch Group
(add cylinder (scale 0.05 0.1 0.05))
(material blackPlastic))
;
; The completed shade includes the switch stuck on the end
; and the light bulb
;
(object shadeAssembly Group
(add 100-watt (translate 0 -30 0))
(add lampShade)
(add switch (translate 0 65 0)))
;
; The shade together with its support, hinged so the shade can swing back & forth
; Angle shade-angle determines degree of swing of the shade.
;
(define shadeAngle -30)
(object tiltedShade Group
(add shadeAssembly (xform (translate 0 -40 0) (xRot shadeAngle)))
(add cube (xform (scale 0.4 0.15 0.05) (translate -40 0 0))))
;
; Finally, connect the shade with its wheeled hinge, leaving the wheel positioned
; as for a line (see above), and with the shade positioned vertically above the wheel
;
(object fullShade Group
(add wheel)
(add tiltedShade (xform (translate 60 0 0) (zRot 90))))
;
; The end-link is the link that connects to the shade. The hinge angle is
; link1-angle
;
(define link1Angle -15) ; was -15
(object endLink Group
(add link)
(add fullShade (xform (zRot link1Angle) (translate 0 200 0))))
;
; The arm consists of a link connected to the end link. The hinge angle between
; the two links is hinge-angle
;
(define hingeAngle -105)
(object arm Group
(add link)
(add endLink (xform (zRot hingeAngle) (translate 0 200 0))))
;
; Finally, the completed lamp is made by connecting the arm and the base together
; The angle that the bottom of the arm makes with the base is arm-angle
;
(define armAngle 30)
(object lamp Group
(add base)
(add arm (xform (zRot armAngle) (translate 0 40 0)))
(material yellowPlastic))
;
; Now make a table top to put the lamp on
;
(object tableTop Group
(add cube (scale 8 0.4 8))
(material ltGrayPlaster))
;
; The completed scene with the center of desk lamp positioned about at the origin
; and an extra light put in to illuminate the scene
;
(object scene Group
(add lamp (translate -50 -150 0))
(add bulb (translate 100 100 -200))
(add tableTop (translate 0 -170 0)))
(tell image
(width 800))
(tell camera
(pos '(548.077 245.695 -916.95))
(coi '(-0.5 -0.224143 0.836516))
(pos (yRot -90))
(shoot)
)