Skip to content

Commit

Permalink
Dude body
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Apr 21, 2017
1 parent c0207d3 commit 3a8cd03
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
40 changes: 22 additions & 18 deletions client/src/dude.lisp
@@ -1,40 +1,44 @@
(in-package :mortar-combat) (in-package :mortar-combat)




(defvar *dude-bounds-initial-position* (vec4 0.0 7.5 0.0 1.0))
(defvar *dude-bounds-initial-rotation* (euler-angles->mat4 (vec4 (/ pi 2) 0.0 0.0)))

(defclass dude-bounds (collidable cylinder-geom) ()) (defclass dude-bounds (collidable cylinder-geom) ())




(defclass dude-body (disposable) (defclass dude-body (disposable)
(body bounds)) (bounds))




(defmethod initialize-instance :after ((this dude-body) &key) (defmethod initialize-instance :after ((this dude-body) &key)
(with-slots (body bounds) this (with-slots (bounds) this
(setf body (make-rigid-body) (setf bounds (make-instance 'dude-bounds
bounds (make-instance 'dude-bounds
:radius 2.0 :radius 2.0
:length 13.0)) :length 13.0))
#++(bind-geom bounds body))) (setf (position-of bounds) (vec3 (x *dude-bounds-initial-position*)
(y *dude-bounds-initial-position*)
(z *dude-bounds-initial-position*))
(rotation-of bounds) (mat4->mat3 *dude-bounds-initial-rotation*))))




(define-destructor dude-body (body bounds) (define-destructor dude-body (bounds)
(dispose bounds) (dispose bounds))
(dispose body))




(defmethod (setf position-of) (value (this dude-body)) (defmethod (setf position-of) ((value vec3) (this dude-body))
(with-slots (body) this (with-slots (bounds) this
(setf (position-of body) value))) (setf (position-of bounds) value)))




(defmethod transform-of ((this dude-body)) (defmethod transform-of ((this dude-body))
(with-slots (body) this (with-slots (bounds) this
(transform-of body))) (transform-of bounds)))




(defmethod rotation-of ((this dude-body)) (defmethod rotation-of ((this dude-body))
(with-slots (body) this (with-slots (bounds) this
(rotation-of body))) (rotation-of bounds)))


;;; ;;;
;;; ;;;
Expand Down Expand Up @@ -121,14 +125,14 @@


(defmethod scene-pass ((this dude-model) (pass simulation-pass) input) (defmethod scene-pass ((this dude-model) (pass simulation-pass) input)
(with-slots (body) this (with-slots (body) this
#++(let* ((pos (mult *model-matrix* (vec4 0.0 0.0 0.0 1.0))) (let* ((pos (mult *model-matrix* *dude-bounds-initial-position*))
(w (w pos))) (w (w pos)))
(flet ((w/ (v) (flet ((w/ (v)
(/ v w))) (/ v w)))
(setf (position-of body) (vec3 (w/ (x pos)) (setf (position-of body) (vec3 (w/ (x pos))
(w/ (y pos)) (w/ (y pos))
(w/ (z pos)))))) (w/ (z pos)))))))
(call-next-method))) (call-next-method))




(defmethod scene-pass ((this dude-model) (pass rendering-pass) input) (defmethod scene-pass ((this dude-model) (pass rendering-pass) input)
Expand Down
5 changes: 3 additions & 2 deletions client/src/main.lisp
Expand Up @@ -28,8 +28,9 @@
((player-camera :player player) ((player-camera :player player)
(room-model) (room-model)
((scene-node :name :ball-group)) ((scene-node :name :ball-group))
((dude-model :color (vec3 0.9 0.4 0.4)) ((transform-node :translation (vec3 4.0 0.0 0.0))
(mortar-model))))))) ((dude-model :color (vec3 0.9 0.4 0.4))
(mortar-model))))))))




(defmethod dispatch ((this mortar-combat) (task function) invariant &key) (defmethod dispatch ((this mortar-combat) (task function) invariant &key)
Expand Down

0 comments on commit 3a8cd03

Please sign in to comment.