changed map a bit

This commit is contained in:
Nicole Dresselhaus 2014-04-22 11:27:07 +02:00
parent ae304ddc5c
commit 1bbf900ec4
3 changed files with 58 additions and 5 deletions

View File

@ -3,5 +3,32 @@ where
import Map.Types import Map.Types
-- | Generate a new Map of given Type and Size
--
-- TODO:
-- 1. Should take Size -> Type -> Playmap
-- 2. plug together helper-functions for that terraintype
newMap :: Int -> Int -> PlayMap newMap :: Int -> Int -> PlayMap
newMap = undefined newMap = undefined
-- | Basic Terrain-Generator. Will not implement "abnormal" Stuff for given Biome
-- (like Deserts on Grass-Islands or Grass on Deserts)
--
-- TODO: Implement Desert-Generator
heightToTerrain :: MapType -> YCoord -> TileType
heightToTerrain GrassIslandMap y
| y < 0.1 = Ocean
| y < 1 = Beach
| y < 5 = Grass
| y < 10 = Hill
| otherwise = Mountain
heightToTerrain _ _ = undefined
type Seed = (XCoord, ZCoord)
-- | Add lakes on generated Map from (possible) Seeds noted before.
--
-- TODO: implement and erode terrain on the way down.
addLakes :: PlayMap -> [Seeds] -> PlayMap
addLakes m s = undefined

View File

@ -88,7 +88,7 @@ fgVertexIndex = (ToFloat, mapVertexArrayDescriptor 3 7) --vertex after normal
getMapBufferObject :: IO (BufferObject, NumArrayIndices) getMapBufferObject :: IO (BufferObject, NumArrayIndices)
getMapBufferObject = do getMapBufferObject = do
myMap' <- return $ convertToGraphicsMap $ convertToStripeMap mapCenterMountain myMap' <- return $ convertToGraphicsMap $ convertToStripeMap mapNoise
! myMap <- return $ generateTriangles myMap' ! myMap <- return $ generateTriangles myMap'
len <- return $ fromIntegral $ P.length myMap `div` numComponents len <- return $ fromIntegral $ P.length myMap `div` numComponents
putStrLn $ P.unwords ["num verts in map:",show len] putStrLn $ P.unwords ["num verts in map:",show len]

View File

@ -3,9 +3,10 @@ where
import Map.Types import Map.Types
import Data.Array import Data.Array
import Map.Creation (heightToTerrain)
-- general 3D-Gaussian -- general 3D-Gaussian
gauss3Dgeneral :: Floating q => gauss3Dgeneral :: Floating q =>
q -- ^ Amplitude q -- ^ Amplitude
-> q -- ^ Origin on X-Achsis -> q -- ^ Origin on X-Achsis
-> q -- ^ Origin on Z-Achsis -> q -- ^ Origin on Z-Achsis
@ -18,7 +19,7 @@ gauss3Dgeneral amp x0 z0 sX sZ x z = amp * exp(-(((x-x0)^(2 :: Integer)/(2 * sX^
-- specialised 3D gaussian with an origin on 100/100, an amplitude of 15 and two sigmas of 15 -- specialised 3D gaussian with an origin on 100/100, an amplitude of 15 and two sigmas of 15
gauss3D :: Floating q => gauss3D :: Floating q =>
q -- ^ X-Coordinate q -- ^ X-Coordinate
-> q -- ^ Z-Coordinate -> q -- ^ Z-Coordinate
-> q -- ^ elevation on coordinate in quesion -> q -- ^ elevation on coordinate in quesion
gauss3D = gauss3Dgeneral 15 100.0 100.0 15.0 15.0 gauss3D = gauss3Dgeneral 15 100.0 100.0 15.0 15.0
@ -36,14 +37,39 @@ mapCenterMountain :: PlayMap
mapCenterMountain = array ((0,0),(199,199)) nodes mapCenterMountain = array ((0,0),(199,199)) nodes
where where
nodes = water ++ beach ++ grass ++ hill ++ mountain nodes = water ++ beach ++ grass ++ hill ++ mountain
water = [((a,b), (Full (a,b) 0.0 Ocean BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) > 95] water = [((a,b), (Full (a,b) 0.0 Ocean BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) > 95]
beach = [((a,b), (Full (a,b) (g2d a b) Beach BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 95, (m2d (a,b)) > 75] beach = [((a,b), (Full (a,b) (g2d a b) Beach BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 95, (m2d (a,b)) > 75]
grass = [((a,b), (Full (a,b) (g2d a b) Grass BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 75, (m2d (a,b)) > 25] grass = [((a,b), (Full (a,b) (g2d a b) Grass BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 75, (m2d (a,b)) > 25]
hill = [((a,b), (Full (a,b) (g2d a b) Hill BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 25, (m2d (a,b)) > 10] hill = [((a,b), (Full (a,b) (g2d a b) Hill BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 25, (m2d (a,b)) > 10]
mountain = [((a,b), (Full (a,b) (g2d a b) Mountain BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 10] mountain = [((a,b), (Full (a,b) (g2d a b) Mountain BNothing NoPlayer NoPath Plain [])) | a <- [0..199], b <- [0..199], (m2d (a,b)) <= 10]
g2d :: Int -> Int -> Float g2d :: Int -> Int -> Float
g2d x y = gauss3D (fromIntegral x) (fromIntegral y) g2d x y = gauss3D (fromIntegral x) (fromIntegral y)
m2d :: (Int,Int) -> Int m2d :: (Int,Int) -> Int
m2d (x,y) = mnh2D (x,y) (100,100) m2d (x,y) = mnh2D (x,y) (100,100)
-- small helper for some hills. Should be replaced by multi-layer perlin-noise
-- TODO: Replace as given in comment.
_noisyMap :: (Floating q) => q -> q -> q
_noisyMap = \x y -> gauss3Dgeneral 15 100.0 100.0 15.0 15.0 x y
+ gauss3Dgeneral 5 10.0 10.0 10.0 10.0 x y
+ gauss3Dgeneral 5 150.0 120.0 10.0 10.0 x y
+ gauss3Dgeneral 5 50.0 75.0 10.0 10.0 x y
-- generates a noisy map
-- TODO: add real noise to a simple pattern
mapNoise :: PlayMap
mapNoise = array ((0,0),(199,199)) nodes
where
nodes = [((a,b), (Full
(a,b)
(height a b)
(heightToTerrain GrassIslandMap $ height a b)
BNothing
NoPlayer
NoPath
Plain
[])) | a <- [0..199], b <- [0..199]]
where
height a b = (_noisyMap (fromIntegral a) (fromIntegral b))