changed camera to new model
This commit is contained in:
parent
e2da50b6d9
commit
06bd9c4214
16
src/Main.hs
16
src/Main.hs
@ -43,11 +43,12 @@ import Graphics.GLUtil.BufferObjects (offset0)
|
||||
import Graphics.Rendering.OpenGL.Raw.ARB.TessellationShader
|
||||
-- Our modules
|
||||
import Map.Graphics
|
||||
import Render.Misc (checkError, createFrustum, getCam, curb,
|
||||
import Render.Misc (checkError, createFrustum, curb,
|
||||
genColorData)
|
||||
import Render.Render (initRendering,
|
||||
initMapShader,
|
||||
initHud)
|
||||
import Render.Types
|
||||
import UI.Callbacks
|
||||
import Types
|
||||
import Importer.IQM.Parser
|
||||
@ -146,10 +147,7 @@ main =
|
||||
, _yAngle = pi/2
|
||||
, _zDist = 10
|
||||
, _frustum = frust
|
||||
, _camPosition = Types.Position
|
||||
{ Types.__x = 25
|
||||
, Types.__y = 25
|
||||
}
|
||||
, _camObject = createFlatCam 25 25
|
||||
}
|
||||
, _io = IOState
|
||||
{ _clock = now
|
||||
@ -209,8 +207,7 @@ draw = do
|
||||
numVert = state ^. gl.glMap.mapVert
|
||||
map' = state ^. gl.glMap.stateMap
|
||||
frust = state ^. camera.frustum
|
||||
camX = state ^. camera.camPosition._x
|
||||
camY = state ^. camera.camPosition._y
|
||||
camPos = state ^. camera.camObject
|
||||
zDist' = state ^. camera.zDist
|
||||
tessFac = state ^. gl.glMap.stateTessellationFactor
|
||||
when (state ^. ui . uiHasChanged) prepareGUI
|
||||
@ -264,7 +261,7 @@ draw = do
|
||||
checkError "copy projection"
|
||||
|
||||
--set up camera
|
||||
let ! cam = getCam (camX,camY) zDist' xa ya
|
||||
let ! cam = getCam camPos zDist' xa ya
|
||||
with (distribute cam) $ \ptr ->
|
||||
glUniformMatrix4fv vmat 1 0 (castPtr (ptr :: Ptr (L.M44 CFloat)))
|
||||
checkError "copy cam"
|
||||
@ -387,8 +384,7 @@ run = do
|
||||
- 0.2 * kyrot * mults
|
||||
mody y' = y' + 0.2 * kxrot * mults
|
||||
- 0.2 * kyrot * multc
|
||||
modify $ (camera.camPosition._x %~ modx)
|
||||
. (camera.camPosition._y %~ mody)
|
||||
modify $ camera.camObject %~ (\c -> moveBy c (\(x,y) -> (modx x,mody y)))
|
||||
|
||||
{-
|
||||
--modify the state with all that happened in mt time.
|
||||
|
@ -89,7 +89,7 @@ lookAt eye center up' =
|
||||
y@(V3 yx yy yz) = normalize (cross z x)
|
||||
|
||||
|
||||
getCam :: (Double, Double) -- ^ Target in x/z-Plane
|
||||
{-getCam :: (Double, Double) -- ^ Target in x/z-Plane
|
||||
-> Double -- ^ Distance from Target
|
||||
-> Double -- ^ Angle around X-Axis (angle down/up)
|
||||
-> Double -- ^ Angle around Y-Axis (angle left/right)
|
||||
@ -110,7 +110,7 @@ getCam (x',z') dist' xa' ya' = lookAt (cpos ^+^ at') at' up
|
||||
z = realToFrac z'
|
||||
dist = realToFrac dist'
|
||||
xa = realToFrac xa'
|
||||
ya = realToFrac ya'
|
||||
ya = realToFrac ya'-}
|
||||
|
||||
curb :: Ord a => a -> a -> a -> a
|
||||
curb l h x
|
||||
|
@ -10,6 +10,7 @@ import Linear.Matrix (M44)
|
||||
import Control.Monad.RWS.Strict (RWST)
|
||||
import Control.Lens
|
||||
import Graphics.Rendering.OpenGL.GL.Texturing.Objects (TextureObject)
|
||||
import Render.Types
|
||||
|
||||
|
||||
--Static Read-Only-State
|
||||
@ -41,7 +42,7 @@ data CameraState = CameraState
|
||||
, _yAngle :: !Double
|
||||
, _zDist :: !Double
|
||||
, _frustum :: !(M44 CFloat)
|
||||
, _camPosition :: !Position --TODO: Get rid of cam-prefix
|
||||
, _camObject :: !Camera
|
||||
}
|
||||
|
||||
data IOState = IOState
|
||||
|
Loading…
Reference in New Issue
Block a user