finally show engine
This commit is contained in:
parent
bfda5bc4df
commit
32fa1cd3e0
|
@ -13,6 +13,7 @@
|
||||||
((template-vertices :initarg :template-vertices :accessor template-vertices :initform nil)
|
((template-vertices :initarg :template-vertices :accessor template-vertices :initform nil)
|
||||||
(template-colors :initarg :template-colors :accessor template-colors :initform nil)))
|
(template-colors :initarg :template-colors :accessor template-colors :initform nil)))
|
||||||
|
|
||||||
|
|
||||||
(defun generate-step-2d-array (2darr time)
|
(defun generate-step-2d-array (2darr time)
|
||||||
(let ((len-arr (length 2darr))
|
(let ((len-arr (length 2darr))
|
||||||
(len-row (length (first 2darr))))
|
(len-row (length (first 2darr))))
|
||||||
|
@ -26,7 +27,6 @@
|
||||||
|
|
||||||
; take 2 seconds to fully fire
|
; take 2 seconds to fully fire
|
||||||
(defmethod regen-model ((model engine-model) time)
|
(defmethod regen-model ((model engine-model) time)
|
||||||
(format t "REGNE MODEL~%")
|
|
||||||
(setf (vertices model) (generate-step-2d-array (template-vertices model) time))
|
(setf (vertices model) (generate-step-2d-array (template-vertices model) time))
|
||||||
(setf (colors model) (generate-step-2d-array (template-colors model) time)))
|
(setf (colors model) (generate-step-2d-array (template-colors model) time)))
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@
|
||||||
|
|
||||||
|
|
||||||
(defmethod draw ((object engine-object) time)
|
(defmethod draw ((object engine-object) time)
|
||||||
(if (< (- time (start-time object)) (activation-time object))
|
(if (< (- time (start-time object)) (activation-time object)) ;; hack since times are in templates!!!
|
||||||
(regen-model (model object) time))
|
(regen-model (model object) (- time (start-time object))))
|
||||||
(call-next-method))
|
(call-next-method))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,14 +112,14 @@
|
||||||
; (object-draw (engine object)))))
|
; (object-draw (engine object)))))
|
||||||
|
|
||||||
|
|
||||||
(defun draw-world (time)
|
(defun draw-world (start-time)
|
||||||
;; clear the buffer
|
;; clear the buffer
|
||||||
(gl:clear :color-buffer-bit :depth-buffer-bit)
|
(gl:clear :color-buffer-bit :depth-buffer-bit)
|
||||||
;; move to eye position
|
;; move to eye position
|
||||||
;;draw (make-instance 'powered-object :motion (make-instance 'motion :coords (vector 0 0 -3)) :model *ship-model* :engine (engine *self*)))
|
;;draw (make-instance 'powered-object :motion (make-instance 'motion :coords (vector 0 0 -3)) :model *ship-model* :engine (engine *self*)))
|
||||||
(let ((orig-coords (coords (body *self*))))
|
(let ((orig-coords (coords (body *self*))))
|
||||||
(setf (coords (body *self*)) (vector 0 0 -3))
|
(setf (coords (body *self*)) (vector 0 0 -3))
|
||||||
(draw *self* time)
|
(draw *self* start-time)
|
||||||
(setf (coords (body *self*)) orig-coords))
|
(setf (coords (body *self*)) orig-coords))
|
||||||
|
|
||||||
(gl:translate (- (aref (coords (body *self*)) 0)) (- (aref (coords (body *self*)) 1)) (- (aref (coords (body *self*)) 2))) ;; eye
|
(gl:translate (- (aref (coords (body *self*)) 0)) (- (aref (coords (body *self*)) 1)) (- (aref (coords (body *self*)) 2))) ;; eye
|
||||||
|
@ -127,12 +127,12 @@
|
||||||
(loop for entity across *world* do
|
(loop for entity across *world* do
|
||||||
; only draw if its infront of me
|
; only draw if its infront of me
|
||||||
(if (< (aref (coords (body entity)) 2) (+ 10 (aref (coords (body *self*)) 2)))
|
(if (< (aref (coords (body entity)) 2) (+ 10 (aref (coords (body *self*)) 2)))
|
||||||
(draw entity time)))
|
(draw entity start-time)))
|
||||||
|
|
||||||
(gl:matrix-mode :modelview)
|
(gl:matrix-mode :modelview)
|
||||||
(gl:load-identity)
|
(gl:load-identity)
|
||||||
|
|
||||||
(glu:look-at 0 6 10 ;; pos
|
(glu:look-at 0 6 10 ;; 0 6 10 pos
|
||||||
0 0 0 ;; center
|
0 0 0 ;; center
|
||||||
0 1 0 ;; up in y pos
|
0 1 0 ;; up in y pos
|
||||||
)
|
)
|
||||||
|
@ -198,13 +198,13 @@
|
||||||
|
|
||||||
|
|
||||||
(incf *num-frames*)
|
(incf *num-frames*)
|
||||||
(if (not (eql (floor *last-time*) (floor time)))
|
; (if (not (eql (floor *last-time*) (floor time)))
|
||||||
(let* ((short-interval time)
|
; (let* ((short-interval time)
|
||||||
(long-interval (- start-time *start-time*) )
|
; (long-interval (- start-time *start-time*) )
|
||||||
(short-fps (floor (if (zerop short-interval) 0 (/ 1 short-interval))))
|
; (short-fps (floor (if (zerop short-interval) 0 (/ 1 short-interval))))
|
||||||
(long-fps (floor (if (zerop long-interval) 0 (/ *num-frames* long-interval)))))
|
; (long-fps (floor (if (zerop long-interval) 0 (/ *num-frames* long-interval)))))
|
||||||
|
|
||||||
(format t "FPS since last:~a since start:~a (~a frames in ~a seconds)~%" short-fps long-fps *num-frames* long-interval)))
|
; (format t "FPS since last:~a since start:~a (~a frames in ~a seconds)~%" short-fps long-fps *num-frames* long-interval)))
|
||||||
|
|
||||||
(setf *last-time* start-time)))
|
(setf *last-time* start-time)))
|
||||||
|
|
||||||
|
@ -261,9 +261,12 @@
|
||||||
:activation-time 2
|
:activation-time 2
|
||||||
:model (make-instance 'engine-model
|
:model (make-instance 'engine-model
|
||||||
:template-vertices *thruster-vertices*
|
:template-vertices *thruster-vertices*
|
||||||
:template-colors *thruster-colors*)
|
:template-colors *thruster-colors*
|
||||||
|
:faces (make-2d-array 4 3 '((0 1 3) (0 2 1) (0 3 2) (1 2 3)))
|
||||||
|
:face-colors (make-2d-array 4 3 '((0 1 3) (0 2 1) (0 3 2) (1 2 3))))
|
||||||
|
|
||||||
:body (make-instance 'body
|
:body (make-instance 'body
|
||||||
:coords (vector 0 0 3))))))
|
:coords (vector 0 0.5 3))))))
|
||||||
;:engines (list :engines (list :thrust
|
;:engines (list :engines (list :thrust
|
||||||
; (make-instance 'engine-object
|
; (make-instance 'engine-object
|
||||||
; :motion (make-instance 'motion :coords (vector 0 0.5 3.0))
|
; :motion (make-instance 'motion :coords (vector 0 0.5 3.0))
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
:faces (make-2d-array 8 3 '((0 3 1) (0 2 4) (0 1 2) (0 4 3)
|
:faces (make-2d-array 8 3 '((0 3 1) (0 2 4) (0 1 2) (0 4 3)
|
||||||
(3 5 1) (2 5 4) (1 5 2) (4 5 3)))))
|
(3 5 1) (2 5 4) (1 5 2) (4 5 3)))))
|
||||||
|
|
||||||
|
;; returns a model of a 3 pyramid
|
||||||
(defun make-model-3pyramid (points &key (face-colors nil) (point-colors nil))
|
(defun make-model-3pyramid (points &key (face-colors nil) (point-colors nil))
|
||||||
(make-instance 'model
|
(make-instance 'model
|
||||||
:vertices points
|
:vertices points
|
||||||
|
|
Loading…
Reference in New Issue