Skip to content


Browse files Browse the repository at this point in the history
Add animation blending
  • Loading branch information
borodust committed Apr 19, 2017
1 parent cea602a commit 750002a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
42 changes: 31 additions & 11 deletions client/src/dude.lisp
Expand Up @@ -41,28 +41,48 @@
(defclass dude-model (model)
((mesh :initform nil)
(program :initform nil)
(animation :initform nil)
(run-animation :initform nil)
(rest-animation :initform nil)
(strafe-animation :initform nil)
(color :initarg :color)
(animation-name :initarg :animation-name)
(skeleton :initform nil)))

(defmethod initialize-instance :after ((this dude-model) &key))

(defmethod initialization-flow ((this dude-model) &key)
(with-slots (mesh animation skeleton program animation-name) this
(>> (resource-flow "mesh.Dude" "Stickman" animation-name
(with-slots (mesh animation skeleton program
strafe-animation run-animation rest-animation)
(>> (resource-flow "mesh.Dude" "Stickman"
(shading-program-resource-name "dude-program"))
(instantly (m s a p)
(instantly (m s rest run strafe p)
(setf mesh m
skeleton s
animation a
program p)
(start-animation animation t))
strafe-animation strafe
run-animation run
rest-animation rest
program p))
(instantly ()
(let ((node (find-node (model-root-of this) :dude-animation)))
(subscribe-body-to (keyboard-event (key state)) (events)
(case key
(:w (case state
(:pressed (play-node-animation node run-animation 0.15))
(:released (play-node-animation node rest-animation 0.15))))
(:d (case state
(:pressed (play-node-animation node strafe-animation 0.15))
(:released (play-node-animation node rest-animation 0.15)))))))))))

(defmethod model-graph-assembly-flow ((this dude-model))
(with-slots (animation skeleton mesh program color) this
(with-slots (skeleton mesh program color rest-animation) this
((animation-node :frames animation)
((animation-node :initial-animation rest-animation :name :dude-animation)
((animated-skeleton-node :root-bone skeleton)
((dude-mesh :mesh mesh :program program :color color)))))))
2 changes: 1 addition & 1 deletion client/src/main.lisp
Expand Up @@ -23,7 +23,7 @@
((transform-node :translation (vec3 4.0 0.0 0.0))
((dude-model :color (vec3 0.9 0.4 0.4) :animation-name "animation.Resting"))))))))
((dude-model :color (vec3 0.9 0.4 0.4) :animation-name "animation.Running"))))))))

(defmethod initialize-system :after ((this mortar-combat))
Expand Down
5 changes: 2 additions & 3 deletions client/src/mortar.lisp
Expand Up @@ -54,14 +54,13 @@
(setf mesh m
skeleton s
animation a
program p)
(start-animation animation t))
program p))

(defmethod model-graph-assembly-flow ((this mortar-model))
(with-slots (animation skeleton mesh program color) this
((animation-node :frames animation)
((animation-node :initial-animation animation)
((animated-skeleton-node :root-bone skeleton)
((mortar-mesh :mesh mesh :program program)))))))

0 comments on commit 750002a

Please sign in to comment.