(use-modules (chickadee) (chickadee graphics color) (chickadee graphics sprite) (chickadee graphics text) (chickadee graphics path) (chickadee graphics pbr) (chickadee graphics mesh) (chickadee math vector) (chickadee math rect) (system repl coop-server)) (define repl (spawn-coop-repl-server)) (define (poglej) (look-at! view-matrix position (vec3+ position (vec3 0.0 0.0 1.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 ((eq? key 'q) (abort-game)) ((eq? key 'r) (reset-stevec)))) (define stevec #f) (define (reset-stevec) (set! stevec 1)) (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)) (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 (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 #:load load)