From: Daniel Karbach Date: Thu, 16 Nov 2017 15:38:27 +0000 (+0100) Subject: slightly better planet X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=fec78f7f01a03f10f8ff75c9b87929bf8c2d61e4;p=blobs.git slightly better planet --- diff --git a/assets b/assets index cc06227..d3823a8 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit cc062273ae5591bfa7910ca7fd71f23a35a3270e +Subproject commit d3823a8bfe773100bbbc3dce0622ef3950559d6f diff --git a/src/app/app.cpp b/src/app/app.cpp index 6b8cfbf..62de9ab 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -171,16 +171,21 @@ Assets::Assets() , skin_path(path + "skins/") { graphics::Format format; textures.tiles.Bind(); - textures.tiles.Reserve(256, 256, 9, format); - LoadTileTexture("1", textures.tiles, 0); - LoadTileTexture("2", textures.tiles, 1); - LoadTileTexture("3", textures.tiles, 2); - LoadTileTexture("4", textures.tiles, 3); - LoadTileTexture("5", textures.tiles, 4); - LoadTileTexture("6", textures.tiles, 5); - LoadTileTexture("7", textures.tiles, 6); - LoadTileTexture("8", textures.tiles, 7); - LoadTileTexture("9", textures.tiles, 8); + textures.tiles.Reserve(256, 256, 14, format); + LoadTileTexture("algae", textures.tiles, 0); + LoadTileTexture("desert", textures.tiles, 1); + LoadTileTexture("forest", textures.tiles, 2); + LoadTileTexture("grass", textures.tiles, 3); + LoadTileTexture("ice", textures.tiles, 4); + LoadTileTexture("jungle", textures.tiles, 5); + LoadTileTexture("mountain", textures.tiles, 6); + LoadTileTexture("ocean", textures.tiles, 7); + LoadTileTexture("rock", textures.tiles, 8); + LoadTileTexture("sand", textures.tiles, 9); + LoadTileTexture("taiga", textures.tiles, 10); + LoadTileTexture("tundra", textures.tiles, 11); + LoadTileTexture("water", textures.tiles, 12); + LoadTileTexture("wheat", textures.tiles, 13); textures.skins.Bind(); textures.skins.Reserve(256, 256, 9, format); LoadSkinTexture("1", textures.skins, 0); diff --git a/src/blobs.cpp b/src/blobs.cpp index c09aea6..dcc7590 100644 --- a/src/blobs.cpp +++ b/src/blobs.cpp @@ -21,34 +21,39 @@ int main(int argc, char *argv[]) { app::Assets assets; world::TileSet tiles; - tiles.Add({ "ice", "Ice", 0, 0 }); - tiles.Add({ "black", "Black", 0, 1 }); - tiles.Add({ "red", "Red", 0, 2 }); - tiles.Add({ "grass", "Grass", 0, 3 }); - tiles.Add({ "water", "Water", 0, 4 }); - tiles.Add({ "sand", "Sand", 0, 5 }); - tiles.Add({ "tundra", "Tundra", 0, 6 }); - tiles.Add({ "magenta", "Magenta", 0, 7 }); - tiles.Add({ "rock", "Rock", 0, 8 }); + tiles.Add({ "algae", "Algae", 0, 0 }); + tiles.Add({ "desert", "Desert", 0, 1 }); + tiles.Add({ "forest", "Forest", 0, 2 }); + tiles.Add({ "grass", "Grass", 0, 3 }); + tiles.Add({ "ice", "Ice", 0, 4 }); + tiles.Add({ "jungle", "Jungle", 0, 5 }); + tiles.Add({ "mountain", "Mountain", 0, 6 }); + tiles.Add({ "ocean", "Ocean", 0, 7 }); + tiles.Add({ "rock", "Rock", 0, 8 }); + tiles.Add({ "sand", "Sand", 0, 9 }); + tiles.Add({ "taiga", "Taiga", 0, 10 }); + tiles.Add({ "tundra", "Tundra", 0, 11 }); + tiles.Add({ "water", "Water", 0, 12 }); + tiles.Add({ "wheat", "Wheat", 0, 13 }); world::Sun sun; - sun.Mass(1.0e12); - sun.Radius(10.0); + sun.Mass(1.0e14); + sun.Radius(20.0); sun.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25)); sun.AngularMomentum(1.0e13); - world::Planet planet(11); + world::Planet planet(25); planet.SetParent(sun); - planet.Mass(1.0e9); + planet.Mass(1.0e10); planet.GetOrbit().SemiMajorAxis(941.7); planet.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25)); planet.AxialTilt(glm::dvec2(PI * 0.127, 0.0)); - planet.AngularMomentum(1.25e9); + planet.AngularMomentum(6.0e10); world::Planet moon(3); moon.SetParent(planet); moon.Mass(1.0e6); - moon.GetOrbit().SemiMajorAxis(25.0); + moon.GetOrbit().SemiMajorAxis(37.0); moon.Rotation(PI * 0.25); moon.AngularMomentum(1.0e4); @@ -91,9 +96,9 @@ int main(int argc, char *argv[]) { // sunset //.FirstPerson(3, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f)) // from afar - //.MapView(0, glm::vec3(0.0f, 0.0f, 25.0f), 0.0f) + //.MapView(0, glm::vec3(0.0f, 0.0f, 60.0f), 0.0f) // from afar, rotating - .Orbital(glm::vec3(-25.0f, 0.0f, 0.0f)) + .Orbital(glm::vec3(-60.0f, 0.0f, 0.0f)) ; // system view //state.GetCamera() diff --git a/src/world/world.cpp b/src/world/world.cpp index fb57c7c..a3494b3 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -389,17 +389,24 @@ void GenerateEarthlike(const TileSet &tiles, Planet &p) noexcept { rand::SimplexNoise elevation_gen(0); const int ice = tiles["ice"].id; - const int grass = tiles["grass"].id; + const int ocean = tiles["ocean"].id; const int water = tiles["water"].id; const int sand = tiles["sand"].id; - const int rock = tiles["rock"].id; + const int grass = tiles["grass"].id; + const int tundra = tiles["tundra"].id; + const int desert = tiles["desert"].id; + const int mntn = tiles["mountain"].id; + constexpr double ocean_thresh = -0.2; constexpr double water_thresh = 0.0; constexpr double beach_thresh = 0.1; constexpr double mountain_thresh = 0.5; const glm::dvec3 axis(glm::dvec4(0.0, 1.0, 0.0, 0.0) * glm::eulerAngleXY(p.SurfaceTilt().x, p.SurfaceTilt().y)); - const double cap_thresh = std::cos(p.AxialTilt().x); + const double cap_thresh = std::abs(std::cos(p.AxialTilt().x)); + const double equ_thresh = 2.0 * (1.0 - cap_thresh); + const double fzone_start = equ_thresh - (equ_thresh - cap_thresh) / 3.0; + const double fzone_end = cap_thresh + (equ_thresh - cap_thresh) / 3.0; for (int surface = 0; surface <= 5; ++surface) { for (int y = 0; y < p.SideLength(); ++y) { @@ -419,14 +426,25 @@ void GenerateEarthlike(const TileSet &tiles, Planet &p) noexcept { 2, // amplitude 2 // growth ); - if (elevation < water_thresh) { + if (elevation < ocean_thresh) { + p.TileAt(surface, x, y).type = ocean; + } else if (elevation < water_thresh) { p.TileAt(surface, x, y).type = water; } else if (elevation < beach_thresh) { p.TileAt(surface, x, y).type = sand; } else if (elevation < mountain_thresh) { - p.TileAt(surface, x, y).type = grass; + // TODO: perturb climate rings a little + if (near_axis < equ_thresh) { + p.TileAt(surface, x, y).type = desert; + } else if (near_axis < fzone_start) { + p.TileAt(surface, x, y).type = grass; + } else if (near_axis < fzone_end) { + p.TileAt(surface, x, y).type = tundra; + } else { + p.TileAt(surface, x, y).type = grass; + } } else { - p.TileAt(surface, x, y).type = rock; + p.TileAt(surface, x, y).type = mntn; } } }