diff options
author | Marc Sunet <jeannekamikaze@gmail.com> | 2012-08-29 12:44:52 +0200 |
---|---|---|
committer | Marc Sunet <jeannekamikaze@gmail.com> | 2012-08-29 12:44:52 +0200 |
commit | 8bcacfa20da130a31abd6ecbba842586b0a20395 (patch) | |
tree | 32edceb305dbf769d36579a15f20aba43bc6370e | |
parent | bca29ddc48d3ce78f5f63aca96af97ae5cc580aa (diff) |
Added box function
-rw-r--r-- | Spear/Render/AnimatedModel.hs | 10 | ||||
-rw-r--r-- | Spear/Render/StaticModel.hs | 10 |
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 | ) |
14 | where | 15 | where |
15 | 16 | ||
@@ -17,6 +18,8 @@ where | |||
17 | import Spear.Assets.Model | 18 | import Spear.Assets.Model |
18 | import Spear.Render.Model | 19 | import Spear.Render.Model |
19 | import Spear.GLSL | 20 | import Spear.GLSL |
21 | import Spear.Math.AABB | ||
22 | import Spear.Math.Vector2 (vec2) | ||
20 | import Spear.Render.Material | 23 | import Spear.Render.Material |
21 | import Spear.Render.Program | 24 | import Spear.Render.Program |
22 | import Spear.Setup as Setup | 25 | import 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. | ||
195 | box :: Int -> AnimatedModelResource -> AABB | ||
196 | box 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 | ) |
11 | where | 12 | where |
12 | 13 | ||
@@ -14,6 +15,8 @@ where | |||
14 | import Spear.Assets.Model | 15 | import Spear.Assets.Model |
15 | import Spear.Render.Model | 16 | import Spear.Render.Model |
16 | import Spear.GLSL | 17 | import Spear.GLSL |
18 | import Spear.Math.AABB | ||
19 | import Spear.Math.Vector2 (vec2) | ||
17 | import Spear.Render.Material | 20 | import Spear.Render.Material |
18 | import Spear.Render.Program | 21 | import Spear.Render.Program |
19 | import Spear.Setup as Setup | 22 | import 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. | ||
133 | box :: Int -> StaticModelResource -> AABB | ||
134 | box i model = | ||
135 | let (Box (Vec2 xmin ymin) (Vec2 xmax ymax)) = boxes model V.! i | ||
136 | in AABB (vec2 xmin ymin) (vec2 xmax ymax) | ||