|
@@ -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))))))) |