Materials

From MHCGraphics

Jump to: navigation, search
; Mead example file -- Materials
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
; February 19, 2008
;
; Based on "A materials playroom. (c) 2007 duane a. bailey"
;
; $Id: Materials.scm 496 2008-02-20 03:00:21Z terescoj $
;
(require (lib "Defs.ss" "Mead"))

; a 1000x1000x1000 room with no front
(object panel Plane
        (translate 0 -500 0)
        )
(object room Group
        (add panel)
        (add panel (xRot -90))
        (add panel (zRot -90))
        (add panel (zRot 90))
        (material whitePlaster)
        )

; several materials
(object clearMaterial Material
        (color red)
        (ambient 0.2)
        (diffuse 0.2)
        (transparency 0.5)
        (roughness 0.05)
        (specularity 0.2)
        (reflection 0.2)
        (refraction 1.5)
        )
(object plasterMaterial Material
        (color white)
        (ambient 0.2)
        (diffuse 0.9)
        (roughness 10)
        (specularity 0)
        )
(define leftMaterial clearMaterial)
(object plasticMaterial Material
        (color white)
        (ambient 0.1)
        (diffuse 0.7)
        (roughness 0.05)
        (specularity 0.7)
        )
(define middleMaterial plasterMaterial)
(object mirrorMaterial Material
        (ambient 0)
        (diffuse 0.1)
        (reflection 0.9)
        )
(define rightMaterial mirrorMaterial)
(object redShiny Material
        (ambient 0)
        (diffuse .9)
        (color red)
        (reflection 0.6)
        )
(define bottomMaterial redShiny)
(define topMaterial bluePlastic)

; set up scene
(object scene Group
        (add room)
        (add sphere leftMaterial (translate -150 0 0))
        (add sphere middleMaterial)
        (add sphere rightMaterial (translate 150 0 0))
        (add sphere bottomMaterial (xform (xRot -45) (translate 0 -150 0)))
        (add cube topMaterial (translate 0 150 0))
        (add bulb (translate -300 300 -400))
        (add bulb (translate 300 300 -400))
        )

; constructs a 1-polygon billboard
(object collegePicture Material
        (surfaceImage "clapplab.png")
        )

(object billboard Mesh
        (addUVPoly '((-100 -100 0) (100 -100 0) (100 100 0) (-100 100 0)) '((0 0) (1 0) (1 1) (0 1)))
        (scale 1.024 .640 1)
        (scale 4 4 4)
        (material collegePicture)
        )

; add billboard to scene, lit from above
(tell scene
        (add billboard (translate 0 0 490))
        (add bulb (translate 0 400 400))
        )

(tell camera
      (shoot))
Personal tools