From: Javier Sancho Date: Sun, 22 Jul 2012 06:36:09 +0000 (+0200) Subject: Turn and rotate meshes. X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=70fe036f20b68f797199dfbc98b8f2d8e8bc07de;p=gacela.git Turn and rotate meshes. --- diff --git a/src/views.scm b/src/views.scm index 63c162a..2873bdb 100644 --- a/src/views.scm +++ b/src/views.scm @@ -38,31 +38,51 @@ (case option ((draw) (video:glmatrix-block - (video:rotate rx ry rz) - (video:translate x y z) (video:rotate ax ay az) + (video:translate x y z) + (video:rotate rx ry rz) (primitive))) ((translate) (set! x (+ x (car params))) (set! y (+ y (cadr params))) (set! z (+ z (caddr params)))) + ((turn) + (set! ax (+ ax (car params))) + (set! ay (+ ay (cadr params))) + (set! az (+ az (caddr params)))) + ((rotate) + (set! rx (+ rx (car params))) + (set! ry (+ ry (cadr params))) + (set! rz (+ rz (caddr params)))) ((get-properties) (get-properties)) ((get-property) (assoc-ref (get-properties) (car params)))))))) -(define* (show-mesh mesh #:optional (view default-view)) +(define* (show mesh #:optional (view default-view)) (let ((id (mesh 'get-property 'id))) (if (not (hash-ref view id)) (hash-set! view id mesh)))) -(define* (hide-mesh mesh #:optional (view default-view)) +(define* (hide mesh #:optional (view default-view)) (hash-remove! view (mesh 'get-property 'id))) (define* (translate mesh x y #:optional (z 0)) (mesh 'translate x y z) mesh) +(define (turn mesh . params) + (if (>= (length params) 3) + (apply mesh (cons 'turn params)) + (mesh 'turn 0 0 (car params))) + mesh) + +(define (rotate mesh . params) + (if (>= (length params) 3) + (apply mesh (cons 'rotate params)) + (mesh 'rotate 0 0 (car params))) + mesh) + (define-macro (define-primitives . symbols) (cond ((null? symbols) `#t)