wavey-wind/anim.scm

95 lines
2.1 KiB
Scheme
Raw Normal View History

2022-11-23 04:14:31 +01:00
(use-modules (chickadee)
(chickadee graphics color)
(chickadee graphics sprite)
(chickadee graphics text)
(chickadee graphics path)
2022-11-23 07:31:55 +01:00
(chickadee graphics pbr)
(chickadee graphics mesh)
2022-11-23 04:14:31 +01:00
(chickadee math vector)
(chickadee math rect)
(system repl coop-server))
(define repl (spawn-coop-repl-server))
2022-11-23 08:32:45 +01:00
(define (poglej)
(look-at! view-matrix
position
(vec3+ position (vec3 0.0 0.0 1.0))
(vec3 0.0 1.0 0.0)))
2022-11-23 04:14:31 +01:00
(define (update dt)
2022-11-23 08:32:45 +01:00
;; REPL!
(poll-coop-repl-server repl)
;; Stevec gor
2022-11-23 07:31:55 +01:00
(set! stevec (+ stevec 1))
(display (string-append (number->string stevec) "\n"))
2022-11-23 08:32:45 +01:00
(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))
2022-11-23 07:31:55 +01:00
(define (key-press key modifiers repeat?)
(cond
((eq? key 'q)
(abort-game))
((eq? key 'r)
(reset-stevec))))
2022-11-23 04:14:31 +01:00
2022-11-23 08:32:45 +01:00
(define stevec #f)
2022-11-23 04:14:31 +01:00
(define (reset-stevec)
2022-11-23 08:32:45 +01:00
(set! stevec 1))
2022-11-23 04:14:31 +01:00
2022-11-23 07:31:55 +01:00
(define camera-position (vec3 0.0 0.0 3.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))
2022-11-23 08:32:45 +01:00
(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)
2022-11-23 07:31:55 +01:00
(define (draw alpha)
(with-projection
projection
2022-11-23 08:32:45 +01:00
(draw-mesh (ustvari-objekt)
2022-11-23 07:31:55 +01:00
#:model-matrix model-matrix
#:view-matrix view-matrix
#:camera-position position)))
2022-11-23 08:32:45 +01:00
(define (load)
;; Moramo pogledat model
(poglej)
(reset-stevec)
(set! obj (ustvari-objekt)))
2022-11-23 04:14:31 +01:00
(run-game
#:draw draw
2022-11-23 07:31:55 +01:00
#:update update
2022-11-23 08:32:45 +01:00
#:key-press key-press
#:load load)