From 70fe036f20b68f797199dfbc98b8f2d8e8bc07de Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 22 Jul 2012 08:36:09 +0200 Subject: [PATCH] Turn and rotate meshes. --- src/views.scm | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) 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) -- 2.39.5