Fog

From MHCGraphics

Jump to: navigation, search
; Mead example file - fog!
;
; Jim Teresco
; Computer Science 110
; Mount Holyoke College
;
; $Id: Fog.scm 643 2008-04-20 19:04:45Z terescoj $
;
(require (lib "Defs.ss" "Mead"))

; build a simple scene -- nothing exciting here
; our standard multiAdd
(define (multiAdd n obj group initialXform deltaXform)
  (if (<= n 0) group
      (begin
        (tell group
              (add obj initialXform)
              )
        (multiAdd (- n 1) obj group
                  (compose initialXform deltaXform)
                  deltaXform)
        )
      )
  )

; put a green floor in the scene
(tell scene
      (add (new Plane) greenPlaster)
      )

; and now a bunch of cubes
(object ourCube Cube
        (translate 0 50 0)
        (material redPlaster)
        )

; add a bunch
(define cubeSpacing 200)
(define cubesPerRow 10)
(define numRows 10)

; our main multiAdd
(multiAdd numRows
          ; the thing we add it itself the result of a multiAdd,
          ; which we can do because multiAdd returns the group,
          ; which we create as a new, unnamed Group!
          ; If this bothers you, rest assured that it could be
          ; just as well done with the techniques from the
          ; MoreDoughnuts example
          (multiAdd cubesPerRow ourCube (new Group)
                    (translate 0 0 0)
                    (translate 0 0 cubeSpacing)
                    )
          ; back to our outer multiAdd, we add to the scene
          scene
          (translate 0 0 0)
          (translate cubeSpacing 0 0)
          )

(tell image
      (background '(.5 .5 1))
      (fog) ; to turn on fog
      (fogAttenuation 1000) ; default is 100, fog is more dense
                            ; at lower numbers
      (fogColor white) ; the default
      (quality 10) ; fog is not rendered below quality 10
      )

(tell camera
      (pos '(0 500 0))
      (coi '(500 300 500))
      (shoot))
Personal tools