Separate out concrete part of world
This commit is contained in:
@@ -7,31 +7,31 @@ import Geometry
|
||||
worldPosToScreenNorm :: Configuration -> World -> Point2 -> Point2
|
||||
worldPosToScreenNorm cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
||||
where
|
||||
doTranslate p = p -.- _cameraCenter w
|
||||
doZoom p = _cameraZoom w *.* p
|
||||
doRotate p = rotateV (negate $ _cameraRot w) p
|
||||
doTranslate p = p -.- _cameraCenter (_cWorld w)
|
||||
doZoom p = _cameraZoom (_cWorld w) *.* p
|
||||
doRotate p = rotateV (negate $ _cameraRot (_cWorld w)) p
|
||||
{- | Transform world coordinates to scaled screen coordinates.
|
||||
- These have to be scaled according to the size of the window to get actual screen positions.
|
||||
- This allows for line thicknesses etc to correspond to pixel sizes.-}
|
||||
worldPosToScreen :: World -> Point2 -> Point2
|
||||
worldPosToScreen w
|
||||
= rotateV (negate $ _cameraRot w)
|
||||
. (_cameraZoom w *.*)
|
||||
. (-.- _cameraCenter w)
|
||||
= rotateV (negate $ _cameraRot (_cWorld w))
|
||||
. (_cameraZoom (_cWorld w) *.*)
|
||||
. (-.- _cameraCenter (_cWorld w))
|
||||
{- | Transform coordinates from the map position to screen
|
||||
coordinates. -}
|
||||
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
|
||||
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
|
||||
where
|
||||
doTranslate p = p -.- _carteCenter (_hud w)
|
||||
doZoom p = _carteZoom (_hud w) *.* p
|
||||
doRotate p = rotateV (negate $ _carteRot (_hud w)) p
|
||||
doTranslate p = p -.- _carteCenter (_hud (_cWorld w))
|
||||
doZoom p = _carteZoom (_hud (_cWorld w)) *.* p
|
||||
doRotate p = rotateV (negate $ _carteRot (_hud (_cWorld w))) p
|
||||
crToMousePosOffset :: Creature -> World -> (Point2,Float)
|
||||
crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr,0)
|
||||
{- | The mouse position in world coordinates. -}
|
||||
mouseWorldPos :: World -> Point2
|
||||
mouseWorldPos w = _cameraCenter w +.+ (1/_cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
|
||||
mouseWorldPos w = _cameraCenter (_cWorld w) +.+ (1/_cameraZoom (_cWorld w)) *.* rotateV (_cameraRot (_cWorld w)) (_mousePos (_cWorld w))
|
||||
{- | The mouse position in map coordinates -}
|
||||
mouseCartePos :: World -> Point2
|
||||
mouseCartePos w = _carteCenter (_hud w) +.+ (1/_carteZoom (_hud w))
|
||||
*.* rotateV (_carteRot (_hud w)) (_mousePos w)
|
||||
mouseCartePos w = _carteCenter (_hud (_cWorld w)) +.+ (1/_carteZoom (_hud (_cWorld w)))
|
||||
*.* rotateV (_carteRot (_hud (_cWorld w))) (_mousePos (_cWorld w))
|
||||
|
||||
Reference in New Issue
Block a user