got rotate for models working. now working on axis specific stretch
This commit is contained in:
parent
3ca106b387
commit
e3fcf269cb
|
@ -22,7 +22,7 @@
|
||||||
(float (+ start (* (- end start) (if (eql now 0.0) 0.0 (/ (min now duration) duration)))))))
|
(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)
|
(defun make-rotation-matrix (xa ya za)
|
||||||
(let ((sxa (sin xa))
|
(let ((sxa (sin xa))
|
||||||
(cxa (cos xa))
|
(cxa (cos xa))
|
||||||
|
@ -59,6 +59,9 @@
|
||||||
(defun scale-vector (v a)
|
(defun scale-vector (v a)
|
||||||
(make-array (length v) :initial-contents (loop for i across v collecting (* i 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
|
; 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)
|
; e.x. (scale-vector (8 4 2)) -> (1 .5 .25)
|
||||||
(defun scale-vector-1 (v)
|
(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)))))
|
(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)
|
(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)))))
|
||||||
|
|
||||||
|
|
12
model.lisp
12
model.lisp
|
@ -59,7 +59,7 @@
|
||||||
|
|
||||||
; point up along +z, flat facing +y (into)
|
; point up along +z, flat facing +y (into)
|
||||||
(defparameter *3pyramid-flat-points*
|
(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))
|
(defparameter *colors* (make-hash-table :test 'equal))
|
||||||
(setf (gethash "red" *colors*) '(255 0 0))
|
(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)))
|
(loop for tri in points collecting (rotate-triangle (make-array (length tri) :initial-contents tri) m)))
|
||||||
|
|
||||||
(defparameter *ship-model*
|
(defparameter *ship-model*
|
||||||
(make-model-3pyramid *3pyramid-flat-points*
|
(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)))
|
(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))))
|
: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))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue