aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Spear/Render/AnimatedModel.hs10
-rw-r--r--Spear/Render/StaticModel.hs10
2 files changed, 20 insertions, 0 deletions
diff --git a/Spear/Render/AnimatedModel.hs b/Spear/Render/AnimatedModel.hs
index 8db87c3..bdeb916 100644
--- a/Spear/Render/AnimatedModel.hs
+++ b/Spear/Render/AnimatedModel.hs
@@ -10,6 +10,7 @@ module Spear.Render.AnimatedModel
10, bind 10, bind
11, render 11, render
12, update 12, update
13, box
13) 14)
14where 15where
15 16
@@ -17,6 +18,8 @@ where
17import Spear.Assets.Model 18import Spear.Assets.Model
18import Spear.Render.Model 19import Spear.Render.Model
19import Spear.GLSL 20import Spear.GLSL
21import Spear.Math.AABB
22import Spear.Math.Vector2 (vec2)
20import Spear.Render.Material 23import Spear.Render.Material
21import Spear.Render.Program 24import Spear.Render.Program
22import Spear.Setup as Setup 25import Spear.Setup as Setup
@@ -186,3 +189,10 @@ render uniforms (AnimatedModelRenderer model _ _ _ curFrame fp) =
186 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi 189 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi
187 glUniform1f (fpLoc uniforms) (unsafeCoerce fp) 190 glUniform1f (fpLoc uniforms) (unsafeCoerce fp)
188 drawArrays gl_TRIANGLES (n*curFrame) n 191 drawArrays gl_TRIANGLES (n*curFrame) n
192
193
194-- | Get the model's ith bounding box.
195box :: Int -> AnimatedModelResource -> AABB
196box i model =
197 let (Box (Vec2 xmin ymin) (Vec2 xmax ymax)) = boxes model V.! i
198 in AABB (vec2 xmin ymin) (vec2 xmax ymax)
diff --git a/Spear/Render/StaticModel.hs b/Spear/Render/StaticModel.hs
index cefb7ed..ddf574d 100644
--- a/Spear/Render/StaticModel.hs
+++ b/Spear/Render/StaticModel.hs
@@ -7,6 +7,7 @@ module Spear.Render.StaticModel
7, Spear.Render.StaticModel.release 7, Spear.Render.StaticModel.release
8, bind 8, bind
9, render 9, render
10, box
10) 11)
11where 12where
12 13
@@ -14,6 +15,8 @@ where
14import Spear.Assets.Model 15import Spear.Assets.Model
15import Spear.Render.Model 16import Spear.Render.Model
16import Spear.GLSL 17import Spear.GLSL
18import Spear.Math.AABB
19import Spear.Math.Vector2 (vec2)
17import Spear.Render.Material 20import Spear.Render.Material
18import Spear.Render.Program 21import Spear.Render.Program
19import Spear.Setup as Setup 22import Spear.Setup as Setup
@@ -124,3 +127,10 @@ render uniforms (StaticModelRenderer model) =
124 uniformVec4 (ksLoc uniforms) ks 127 uniformVec4 (ksLoc uniforms) ks
125 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi 128 glUniform1f (shiLoc uniforms) $ unsafeCoerce shi
126 drawArrays gl_TRIANGLES 0 $ nVertices model 129 drawArrays gl_TRIANGLES 0 $ nVertices model
130
131
132-- | Get the model's ith bounding box.
133box :: Int -> StaticModelResource -> AABB
134box i model =
135 let (Box (Vec2 xmin ymin) (Vec2 xmax ymax)) = boxes model V.! i
136 in AABB (vec2 xmin ymin) (vec2 xmax ymax)