]> git.localhorst.tv Git - blobs.git/commitdiff
slightly better planet
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 16 Nov 2017 15:38:27 +0000 (16:38 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 16 Nov 2017 15:38:27 +0000 (16:38 +0100)
assets
src/app/app.cpp
src/blobs.cpp
src/world/world.cpp

diff --git a/assets b/assets
index cc062273ae5591bfa7910ca7fd71f23a35a3270e..d3823a8bfe773100bbbc3dce0622ef3950559d6f 160000 (submodule)
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit cc062273ae5591bfa7910ca7fd71f23a35a3270e
+Subproject commit d3823a8bfe773100bbbc3dce0622ef3950559d6f
index 6b8cfbfd5421e6061d2db1895d3824e4f87126bd..62de9abab0320ca56ae20fbb130e42c6ec7a4d60 100644 (file)
@@ -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);
index c09aea6b21279d6802fc518dab089532286f9577..dcc759052ee2d501d5631719657cdd849371b68a 100644 (file)
@@ -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()
index fb57c7c09bde150172b0304ceabd580624728e90..a3494b3024f700ca7d78f24e0e5426ed3a7ac515 100644 (file)
@@ -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;
                                }
                        }
                }