diff options
author | Marc Sunet <jeannekamikaze@gmail.com> | 2012-09-07 17:22:01 +0200 |
---|---|---|
committer | Marc Sunet <jeannekamikaze@gmail.com> | 2012-09-07 17:22:01 +0200 |
commit | e430ea93566adf4a38d09050ed20dbd7fa613ff2 (patch) | |
tree | 3c2fa522fb7314999f31ed7c29d9db9eb8e7f4eb | |
parent | cc806ac30e006e55bf0e64b37b81265bfcc779f5 (diff) |
Tidied up
-rw-r--r-- | Spear/Scene/GameObject.hs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Spear/Scene/GameObject.hs b/Spear/Scene/GameObject.hs index a109a35..53a03b5 100644 --- a/Spear/Scene/GameObject.hs +++ b/Spear/Scene/GameObject.hs | |||
@@ -17,6 +17,7 @@ module Spear.Scene.GameObject | |||
17 | , goUpdate | 17 | , goUpdate |
18 | , setAnimation | 18 | , setAnimation |
19 | , setAnimationSpeed | 19 | , setAnimationSpeed |
20 | , setAxis | ||
20 | , withCollisioners | 21 | , withCollisioners |
21 | , setCollisioners | 22 | , setCollisioners |
22 | , setViewInverse | 23 | , setViewInverse |
@@ -132,13 +133,17 @@ instance S2.Spatial2 GameObject where | |||
132 | in go { transform = M3.transform (M3.right m) (M3.forward m) pos } | 133 | in go { transform = M3.transform (M3.right m) (M3.forward m) pos } |
133 | 134 | ||
134 | lookAt p go = | 135 | lookAt p go = |
135 | let position = S2.pos go | 136 | let position = S2.pos go |
136 | fwd = V2.normalise $ p - position | 137 | fwd = V2.normalise $ p - position |
137 | r = perp fwd | 138 | r = perp fwd |
139 | toDeg = (*(180/pi)) | ||
138 | in | 140 | in |
139 | go | 141 | go |
140 | { transform = M3.transform r fwd position | 142 | { transform = M3.transform r fwd position |
141 | , angle = acos $ r `V2.dot` V2.unitx | 143 | , angle = (-180) + |
144 | if V2.y r > 0 | ||
145 | then toDeg . acos $ r `V2.dot` V2.unitx | ||
146 | else (+180) . toDeg . acos $ r `V2.dot` (-V2.unitx) | ||
142 | } | 147 | } |
143 | 148 | ||
144 | 149 | ||
@@ -206,7 +211,12 @@ setAnimation a go = case renderer go of | |||
206 | setAnimationSpeed :: AM.AnimationSpeed -> GameObject -> GameObject | 211 | setAnimationSpeed :: AM.AnimationSpeed -> GameObject -> GameObject |
207 | setAnimationSpeed s go = case renderer go of | 212 | setAnimationSpeed s go = case renderer go of |
208 | Left _ -> go | 213 | Left _ -> go |
209 | Right amr -> go { renderer = Right $ AM.setAnimationSpeed s amr } | 214 | Right amr -> go { renderer = Right $ AM.setAnimationSpeed s amr } |
215 | |||
216 | |||
217 | -- | Set the game object's axis of rotation. | ||
218 | setAxis :: Vector3 -> GameObject -> GameObject | ||
219 | setAxis ax go = go { axis = ax } | ||
210 | 220 | ||
211 | 221 | ||
212 | -- | Set the game object's collisioners. | 222 | -- | Set the game object's collisioners. |
@@ -238,7 +248,7 @@ goRender sprog aprog cam go = | |||
238 | transf = S2.transform go | 248 | transf = S2.transform go |
239 | normal = fastNormalMatrix modelview | 249 | normal = fastNormalMatrix modelview |
240 | modelview = case style of | 250 | modelview = case style of |
241 | RPG -> view * rpgTransform 0 a axis' (M3.position transf) viewI | 251 | RPG -> view * goRPGtransform go |
242 | PLT -> view * pltTransform transf | 252 | PLT -> view * pltTransform transf |
243 | in case renderer go of | 253 | in case renderer go of |
244 | Left smr -> | 254 | Left smr -> |