diff options
author | Joshua Rahm <joshua.rahm@colorado.edu> | 2014-04-27 23:51:51 -0600 |
---|---|---|
committer | Joshua Rahm <joshua.rahm@colorado.edu> | 2014-04-27 23:51:51 -0600 |
commit | 2407f9f400875b2162c93527f95f49b69ca98dd1 (patch) | |
tree | 07a79913c4159bbbdc9631ca0334a912cbcb032d /Graphics/Glyph/GLMath.hs | |
parent | a32da62b52b6f0e4039ae4226e3e2867880ca05c (diff) | |
download | terralloc-2407f9f400875b2162c93527f95f49b69ca98dd1.tar.gz terralloc-2407f9f400875b2162c93527f95f49b69ca98dd1.tar.bz2 terralloc-2407f9f400875b2162c93527f95f49b69ca98dd1.zip |
made first person motion work well with strafing. Added king of hill map.
Diffstat (limited to 'Graphics/Glyph/GLMath.hs')
-rw-r--r-- | Graphics/Glyph/GLMath.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Graphics/Glyph/GLMath.hs b/Graphics/Glyph/GLMath.hs index 361ca16..ac3e93a 100644 --- a/Graphics/Glyph/GLMath.hs +++ b/Graphics/Glyph/GLMath.hs @@ -191,6 +191,17 @@ rotationMatrix ang (Vec3 (u,v,w)) = zRotationMatrix :: GLfloat -> Mat3 GLfloat zRotationMatrix ang = rotationMatrix ang (Vec3 (0,0,1)) +maybeNormalize :: (Vector f a, Eq f) => a f -> a f +maybeNormalize x = if norm x == 0 then x else normalize x + +coordinateConvert :: Vec3 GLfloat -> Vec3 GLfloat -> Vec3 GLfloat -> Vec3 GLfloat +coordinateConvert forward up' vector = + if vector == Vec3 (0,0,0) then vector else + let right = forward × up' + up = right × forward in + case (normalize forward, normalize up, normalize right, vector) of + (za,ya,xa,Vec3 (x,y,z)) -> (x `vScale` xa) <+> (y `vScale` ya) <+> (z `vScale` za) + rotateFrom :: Vec3 GLfloat -> Vec3 GLfloat -> Vec3 GLfloat -> Vec3 GLfloat rotateFrom vector relative newRelative = if vector == Vec3 (0,0,0) then vector else |