Permalink
Browse files

Add animation blending

  • Loading branch information...
borodust committed Apr 19, 2017
1 parent cea602a commit 750002abe96882125a12a84c5b445bf8aaaf019b
Showing with 34 additions and 15 deletions.
  1. +31 −11 client/src/dude.lisp
  2. +1 −1 client/src/main.lisp
  3. +2 −3 client/src/mortar.lisp
@@ -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)
this
(>> (resource-flow "mesh.Dude" "Stickman"
"animation.Resting"
"animation.Running"
"animation.Strafing"
(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))
(call-next-method))))
strafe-animation strafe
run-animation run
rest-animation rest
program p))
(call-next-method)
(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
(scenegraph
((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)))))))
@@ -23,7 +23,7 @@
(room-model)
((transform-node :translation (vec3 4.0 0.0 0.0))
(mortar-model)
((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))
@@ -54,14 +54,13 @@
(setf mesh m
skeleton s
animation a
program p)
(start-animation animation t))
program p))
(call-next-method))))
(defmethod model-graph-assembly-flow ((this mortar-model))
(with-slots (animation skeleton mesh program color) this
(scenegraph
((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.