got rotate for models working. now working on axis specific stretch

This commit is contained in:
Dan Ballard 2012-06-17 15:39:56 -07:00
parent 3ca106b387
commit e3fcf269cb
2 changed files with 14 additions and 6 deletions

View File

@ -22,7 +22,7 @@
(float (+ start (* (- end start) (if (eql now 0.0) 0.0 (/ (min now duration) duration)))))))
;; returns a real lisp 2d array
;; returns a real lisp 2d array: args in radians
(defun make-rotation-matrix (xa ya za)
(let ((sxa (sin xa))
(cxa (cos xa))
@ -59,6 +59,9 @@
(defun scale-vector (v a)
(make-array (length v) :initial-contents (loop for i across v collecting (* i a))))
(defun scale-points (points a)
(make-array (length points) :initial-contents (loop for v across points collecting (scale-vector v a))))
; returns a vector with all elemts scaled to biggest 1 which is scaled to 1
; e.x. (scale-vector (8 4 2)) -> (1 .5 .25)
(defun scale-vector-1 (v)
@ -81,4 +84,5 @@
(make-array (length v1) :initial-contents (loop for i from 0 to (1- (length v1)) collecting (- (aref v1 i) (aref v2 i)))))
(defun vector+ (v1 v2)
(make-array (length v1) :initial-contents (loop for i from 0 to (1- (length v1)) collecting (+ (aref v1 i) (aref v2 i)))))
(make-array (length v1) :initial-contents (loop for i from 0 to (1- (length v1)) collecting (+ (aref v1 i) (aref v2 i)))))

View File

@ -59,7 +59,7 @@
; point up along +z, flat facing +y (into)
(defparameter *3pyramid-flat-points*
'((0.0 0.5 -0.5) (-0.5 -0.5 -0.5) (0.5 -0.5 -0.5) (0.0 -0.5 0.5)))
'((0.0 -0.5 -0.5) (0.0 0.5 0.5) (-0.5 -0.5 0.5) (0.5 -0.5 0.5)))
(defparameter *colors* (make-hash-table :test 'equal))
(setf (gethash "red" *colors*) '(255 0 0))
@ -106,7 +106,11 @@
(loop for tri in points collecting (rotate-triangle (make-array (length tri) :initial-contents tri) m)))
(defparameter *ship-model*
(make-model-3pyramid *3pyramid-flat-points*
;(rotate-triangle (make-2d-array 4 3 *3pyramid-flat-points*) (make-array 3 :initial-contents '(0 90.0 0)))
(make-model-3pyramid ;*3pyramid-flat-points*
(rotate-triangle (make-2d-array 4 3 *3pyramid-flat-points*) (make-rotation-matrix 0 0 0))
:face-colors '((196 196 196) (196 196 196) (196 196 196) (32 32 32))))
;'((0.0 -0.5 -1.5) (0.0 0.5 1.5) (-2.0 -0.5 1.5) (2.0 -0.5 1.5))
;(defparameter *ship-model*
; (make-model-3pyramid '((0.0 -0.5 -1.5) (0.0 0.5 1.5) (-2.0 -0.5 1.5) (2.0 -0.5 1.5))
; :face-colors '((196 196 196) (196 196 196) (196 196 196) (32 32 32))))