zelen kvadrat ki se vrti
parent
0e34584679
commit
e968814b45
65
anim.scm
65
anim.scm
|
@ -11,19 +11,34 @@
|
|||
|
||||
(define repl (spawn-coop-repl-server))
|
||||
|
||||
(define (update dt)
|
||||
;(poll-coop-repl-server repl)
|
||||
(set! stevec (+ stevec 1))
|
||||
(display (string-append (number->string stevec) "\n"))
|
||||
|
||||
(display dt)
|
||||
(display "\n")
|
||||
;; Moramo pogledat prav!
|
||||
(define (poglej)
|
||||
(look-at! view-matrix
|
||||
position
|
||||
(vec3+ position (vec3 0.0 0.0 1.0))
|
||||
(vec3 0.0 1.0 0.0))
|
||||
)
|
||||
(vec3 0.0 1.0 0.0)))
|
||||
|
||||
(define (update dt)
|
||||
;; REPL!
|
||||
(poll-coop-repl-server repl)
|
||||
|
||||
;; Stevec gor
|
||||
(set! stevec (+ stevec 1))
|
||||
(display (string-append (number->string stevec) "\n"))
|
||||
|
||||
(obj-anim dt))
|
||||
|
||||
(define rotX 0)
|
||||
(define rotY 0)
|
||||
(define rotZ 0)
|
||||
|
||||
(define (obj-anim dt)
|
||||
(set! rotX (+ rotX dt))
|
||||
(set! rotY (+ rotY (/ dt 2)))
|
||||
(set! rotZ (+ rotZ (/ dt 3)))
|
||||
|
||||
(matrix4-rotate-x! model-matrix rotX)
|
||||
(matrix4-rotate-y! model-matrix rotY)
|
||||
(matrix4-rotate-z! model-matrix rotZ))
|
||||
|
||||
(define (key-press key modifiers repeat?)
|
||||
(cond
|
||||
|
@ -32,30 +47,48 @@
|
|||
((eq? key 'r)
|
||||
(reset-stevec))))
|
||||
|
||||
(define stevec 0)
|
||||
(define stevec #f)
|
||||
|
||||
(define (reset-stevec)
|
||||
(set! stevec 0))
|
||||
(set! stevec 1))
|
||||
|
||||
(define camera-position (vec3 0.0 0.0 3.0))
|
||||
(define world (make-identity-matrix4))
|
||||
(define view (look-at camera-position (vec3 0.0 0.0 0.0) (vec3 0.0 1.0 0.0)))
|
||||
(define projection (perspective-projection (/ pi 3.0) (/ 4.0 3.0) 0.1 5.0))
|
||||
(define view-matrix (make-identity-matrix4))
|
||||
(define model-matrix (make-identity-matrix4))
|
||||
(define position (vec3 0.0 0.0 -4.0))
|
||||
|
||||
(define (ustvari-objekt)
|
||||
(let ;((velikost (* 1000 (log stevec))))
|
||||
((velikost (/ stevec 1000.0))
|
||||
(barva (vec3 0.2 0.8 0.4)))
|
||||
(make-cube velikost
|
||||
(make-pbr-material #:base-color-factor barva))
|
||||
|
||||
;(make-plane velikost
|
||||
; velikost
|
||||
; (make-pbr-material))
|
||||
))
|
||||
|
||||
(define obj #f)
|
||||
|
||||
(define (draw alpha)
|
||||
(with-projection
|
||||
projection
|
||||
(draw-mesh (make-cube (/ stevec 100) (make-pbr-material))
|
||||
(draw-mesh (ustvari-objekt)
|
||||
#:model-matrix model-matrix
|
||||
#:view-matrix view-matrix
|
||||
#:camera-position position)))
|
||||
|
||||
|
||||
(define (load)
|
||||
;; Moramo pogledat model
|
||||
(poglej)
|
||||
(reset-stevec)
|
||||
(set! obj (ustvari-objekt)))
|
||||
|
||||
(run-game
|
||||
#:draw draw
|
||||
#:update update
|
||||
#:key-press key-press)
|
||||
#:key-press key-press
|
||||
#:load load)
|
||||
|
|
Loading…
Reference in New Issue