Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
63,922 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(in-package :mortar-combat) | ||
|
||
|
||
(defclass player-camera (camera-node) ()) | ||
|
||
|
||
(defmethod scene-pass ((this player-camera) pass input) | ||
(setf (transform-of this) (mult (translation-mat4 0 -5 -30) | ||
(euler-angles->mat4 (vec3 (/ pi -2) 0.0 0.0)))) | ||
(call-next-method)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
(in-package :mortar-combat) | ||
|
||
|
||
;;; | ||
;;; | ||
;;; | ||
(defclass dude-mesh (mesh-node) | ||
((light :initform (make-directional-light-source | ||
(vec3 -0.57735026 -0.57735026 -0.57735026) | ||
(vec4 0.2 0.2 0.2 1.0) | ||
(vec4 0.8 0.8 0.8 1.0) | ||
"dLight")) | ||
(mesh-asset :initarg :mesh) | ||
(program :initarg :program))) | ||
|
||
|
||
(defmethod make-node-mesh ((this dude-mesh)) | ||
(with-slots (mesh-asset) this | ||
(mesh-asset-mesh mesh-asset))) | ||
|
||
|
||
(defmethod scene-pass ((this dude-mesh) (pass rendering-pass) input) | ||
(with-slots (mesh-asset light program) this | ||
(with-active-shading-program (program) | ||
(setf (program-uniform-variable program "modelViewProjection") (model-view-projection-matrix) | ||
(program-uniform-variable program "normalTransform") (mat4->mat3 (mult *view-matrix* | ||
*model-matrix*))) | ||
(apply-light-source light program) | ||
(loop for (name . offset) across (mesh-asset-bones mesh-asset) | ||
for idx = 0 then (1+ idx) do | ||
(setf (program-uniform-variable program (format nil "bones[~d].transform" idx)) | ||
(mult (bone-transform name) offset))) | ||
(call-next-method)))) | ||
|
||
|
||
;;; | ||
;;; | ||
;;; | ||
(defclass dude-model (model) | ||
((mesh :initform nil) | ||
(program :initform nil) | ||
(animation :initform nil) | ||
(control-skeleton :initform nil) | ||
(skeleton :initform nil))) | ||
|
||
|
||
(defmethod initialization-flow ((this dude-model) &key) | ||
(with-slots (mesh animation skeleton program control-skeleton) this | ||
(>> (resource-flow "Dude.4" "Pelvis" "Bone" ".animation.0" | ||
(shading-program-resource-name "dude-program")) | ||
(instantly (m s cs a p) | ||
(setf mesh m | ||
skeleton s | ||
control-skeleton cs | ||
animation a | ||
program p)) | ||
(call-next-method)))) | ||
|
||
|
||
(defmethod model-graph-assembly-flow ((this dude-model)) | ||
(with-slots (animation skeleton control-skeleton mesh program) this | ||
(scenegraph | ||
((animation-node :frames animation) | ||
((animated-skeleton-node :root-bone control-skeleton) | ||
((animated-skeleton-node :root-bone skeleton) | ||
((dude-mesh :mesh mesh :program program)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#version 410 core | ||
|
||
out vec4 fColor; | ||
|
||
in v_PerVertex { | ||
vec4 color; | ||
}; | ||
|
||
void main() { | ||
fColor = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(in-package :mortar-combat) | ||
|
||
|
||
(define-shading-program dude-program | ||
:vertex-shader "dude.v.glsl" | ||
:fragment-shader "dude.f.glsl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#version 410 core | ||
|
||
#include <lighting> | ||
#include <skinning> | ||
|
||
layout(location = 0) in vec3 vPosition; | ||
layout(location = 1) in vec3 vNormal; | ||
|
||
layout(location = 2) in vec4 vWeights; | ||
layout(location = 3) in ivec4 vBones; | ||
|
||
|
||
out gl_PerVertex { | ||
vec4 gl_Position; | ||
}; | ||
|
||
out v_PerVertex { | ||
vec4 color; | ||
}; | ||
|
||
uniform mat4 modelViewProjection; | ||
uniform mat3 normalTransform; | ||
uniform DirectionalLight dLight; | ||
|
||
void main() { | ||
mat4 weightedTransform = weightedTransform(vBones, vWeights); | ||
color = computeLight(vec4(0.4, 0.2, 0.2, 1.0), | ||
normalTransform * mat3(weightedTransform) * vNormal, | ||
dLight); | ||
gl_Position = modelViewProjection * weightedTransform * vec4(vPosition, 1.0); | ||
} |