play around with the lights

This commit is contained in:
Dan Frumin 2019-12-29 11:55:52 +01:00
parent e29896e292
commit 2c271bfc03
1 changed files with 27 additions and 10 deletions

View File

@ -145,17 +145,30 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; the lights ;; the lights
(define (make-sunlight dsun) (define (make-sunlight i)
(sunlight (define cx (cos (degrees->radians i)))
(angles->dir -30 (* 10 dsun)) (define sx (sin (degrees->radians i)))
(emitted-hex "fffb96" 1/2))) (define cx2 (cos (* 8 (degrees->radians i))))
(define sx2 (sin (* 5 (degrees->radians i))))
(define light-pos
(pos (* 2 cx2) (* 3 sx2) (* 2 sx2)))
(combine
(with-emitted (emitted-hex "fffb96" 1/2)
(sphere light-pos 0.1))
(light light-pos (emitted-hex "fffb96" 10))
(sunlight
(angles->dir -30 30)
(emitted "white" 1))))
;; Calculate camera position based on the state ;; Calculate camera position based on the state. Returns a `pos`.
(define (camera-position s) (define (camera-position s)
(pos 0 (+ 4 (scene-state-dy s)) (- (scene-state-dz s) 4))) (pos (scene-state-dx s) (+ 4 (scene-state-dy s)) (- (scene-state-dz s) 4)))
;; Calculate camera direction based on the state
;; Calculate camera direction based on the state. Returns a `dir` or a `pos`.
(define (camera-direction s) (define (camera-direction s)
(angles->dir -90 55)) (angles->dir -90 55)
;;origin
)
(define (on-draw s n t) (define (on-draw s n t)
(combine (basis 'camera (combine (basis 'camera
@ -163,8 +176,8 @@
(camera-direction s))) (camera-direction s)))
(make-sunlight (scene-state-dsun s)) (make-sunlight (scene-state-dsun s))
;; (move-y (road t) -1) ;; (move-y (road t) -1)
;; (spheres t) (spheres t)
;; (scene t) (scene t)
frozen-sspheres frozen-sspheres
(mesh t) (mesh t)
)) ))
@ -184,6 +197,10 @@
[dz (+ (scene-state-dz s) 0.1)])] [dz (+ (scene-state-dz s) 0.1)])]
[("s") (struct-copy scene-state s [("s") (struct-copy scene-state s
[dz (- (scene-state-dz s) 0.1)])] [dz (- (scene-state-dz s) 0.1)])]
[("a") (struct-copy scene-state s
[dx (+ (scene-state-dx s) 0.5)])]
[("d") (struct-copy scene-state s
[dx (- (scene-state-dx s) 0.5)])]
[else s])) [else s]))
(define (stop-state? s n t) (scene-state-done? s)) (define (stop-state? s n t) (scene-state-done? s))