2011-07-30 22:09:37 +02:00
|
|
|
(in-package #:flight-sim)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defclass game-object ()
|
|
|
|
((model :initarg :model :accessor model :initform (make-instance 'model))
|
|
|
|
(body :initarg :body :accessor body :initform (make-instance 'body))
|
|
|
|
(attachments :initarg :attachments :accessor attachments :initform '())
|
|
|
|
(active-attachments :initarg :active-attachments :accessor active-attachments :initform '())))
|
|
|
|
|
|
|
|
|
2011-08-02 09:12:46 +02:00
|
|
|
;(defmethod coords ((object game-object))
|
|
|
|
; (coords (body object)))
|
2011-07-30 22:09:37 +02:00
|
|
|
|
2011-08-07 02:20:23 +02:00
|
|
|
(defgeneric activate (object start-time))
|
|
|
|
(defgeneric activate-attachment (object sym start-time))
|
|
|
|
|
|
|
|
(defgeneric deactivate (object))
|
|
|
|
(defgeneric deactivate-attachment (object sym))
|
|
|
|
|
|
|
|
(defmethod activate-attachment ((object game-object) sym start-time)
|
2011-08-03 07:55:24 +02:00
|
|
|
(push sym (active-attachments object))
|
2011-08-04 08:13:25 +02:00
|
|
|
(activate (getf (attachments object) sym) start-time))
|
2011-08-03 07:55:24 +02:00
|
|
|
|
2011-08-07 02:20:23 +02:00
|
|
|
(defmethod deactivate-attachment ((object game-object) sym)
|
|
|
|
(setf (active-attachments object) (remove sym (active-attachments object))))
|
|
|
|
|
2011-08-03 07:55:24 +02:00
|
|
|
(defmethod draw :before ((object game-object) time)
|
2011-07-30 22:09:37 +02:00
|
|
|
(gl:push-matrix)
|
2011-08-02 09:12:46 +02:00
|
|
|
(gl:translate (aref (coords (body object)) 0) (aref (coords (body object)) 1) (aref (coords (body object)) 2))
|
|
|
|
(gl:rotate (aref (angles (body object)) 0) 1 0 0)
|
|
|
|
(gl:rotate (aref (angles (body object)) 1) 0 1 0)
|
|
|
|
(gl:rotate (aref (angles (body object)) 2) 0 0 1))
|
2011-07-30 22:09:37 +02:00
|
|
|
|
2011-08-03 07:55:24 +02:00
|
|
|
(defmethod draw :after ((object game-object) time)
|
2011-07-30 22:09:37 +02:00
|
|
|
(gl:pop-matrix))
|
|
|
|
|
2011-08-03 07:55:24 +02:00
|
|
|
(defmethod draw ((object game-object) time)
|
2011-08-07 02:20:23 +02:00
|
|
|
(draw (model object) time)
|
|
|
|
(loop for a in (active-attachments object) do
|
|
|
|
(draw (getf (attachments object) a) time)))
|