Permalink
Browse files

Ball

  • Loading branch information...
borodust committed Apr 16, 2017
1 parent 4262e0b commit 3c9041723f05bc4187b7c03ac22dde759266940c
@@ -15,9 +15,11 @@
:components ((:file "packages")
(:file "utils")
(:file "camera")
(:file "ball")
(:file "mortar")
(:file "dude")
(:file "shaders/dude")
(:file "shaders/passthru")
(:file "main")))
@@ -0,0 +1,54 @@
(in-package :mortar-combat)
;;;
;;;
;;;
(defclass ball-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"))
(color :initform (vec3 0.3 0.3 0.3))
(mesh-asset :initarg :mesh)
(program :initarg :program)))
(defmethod make-node-mesh ((this ball-mesh))
(with-slots (mesh-asset) this
(mesh-asset-mesh mesh-asset)))
(defmethod scene-pass ((this ball-mesh) (pass rendering-pass) input)
(with-slots (mesh-asset light program color) 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*))
(program-uniform-variable program "baseColor") color)
(apply-light-source light program)
(call-next-method))))
;;;
;;;
;;;
(defclass ball-model (model)
((mesh :initform nil)
(program :initform nil)))
(defmethod initialization-flow ((this ball-model) &key)
(with-slots (mesh program) this
(>> (resource-flow "Ball.0" (shading-program-resource-name "passthru-program"))
(instantly (m p)
(setf mesh m
program p))
(call-next-method))))
(defmethod model-graph-assembly-flow ((this ball-model))
(with-slots (mesh program) this
(scenegraph
((ball-mesh :mesh mesh :program program)))))
@@ -61,7 +61,7 @@
(defmethod model-graph-assembly-flow ((this dude-model))
(with-slots (animation skeleton control-skeleton mesh program color) this
(with-slots (animation skeleton mesh program color) this
(scenegraph
((animation-node :frames animation)
((animated-skeleton-node :root-bone skeleton)
@@ -20,6 +20,7 @@
(transform-node
((projection-node :aspect (/ 800 600))
(player-camera
(ball-model)
((transform-node :translation (vec3 -4.0 0.0 0.0))
(mortar-model)
((dude-model :color (vec3 0.4 0.4 0.9) :animation-name "Strafing.animation.1")))
@@ -46,7 +46,7 @@
(defmethod initialization-flow ((this mortar-model) &key)
(with-slots (mesh animation skeleton program animation-name) this
(with-slots (mesh animation skeleton program) this
(>> (resource-flow "Mortar.2" "MortarSkeleton"
"MortarRest.animation.2"
(shading-program-resource-name "dude-program"))
@@ -60,7 +60,7 @@
(defmethod model-graph-assembly-flow ((this mortar-model))
(with-slots (animation skeleton control-skeleton mesh program color) this
(with-slots (animation skeleton mesh program color) this
(scenegraph
((animation-node :frames animation)
((animated-skeleton-node :root-bone skeleton)
@@ -3,4 +3,4 @@
(define-shading-program dude-program
:vertex-shader "dude.v.glsl"
:fragment-shader "dude.f.glsl")
:fragment-shader "passthru.f.glsl")
File renamed without changes.
@@ -0,0 +1,6 @@
(in-package :mortar-combat)
(define-shading-program passthru-program
:vertex-shader "passthru.v.glsl"
:fragment-shader "passthru.f.glsl")
@@ -0,0 +1,24 @@
#version 410 core
#include <lighting>
layout(location = 0) in vec3 vPosition;
layout(location = 1) in vec3 vNormal;
out gl_PerVertex {
vec4 gl_Position;
};
out v_PerVertex {
vec4 color;
};
uniform mat4 modelViewProjection;
uniform mat3 normalTransform;
uniform DirectionalLight dLight;
uniform vec3 baseColor;
void main() {
color = computeLight(vec4(baseColor, 1.0), normalTransform * vNormal, dLight);
gl_Position = modelViewProjection * vec4(vPosition, 1.0);
}

0 comments on commit 3c90417

Please sign in to comment.