]> git.localhorst.tv Git - blobs.git/blob - src/blobs.cpp
separate tile type and texture
[blobs.git] / src / blobs.cpp
1 #include "const.hpp"
2 #include "app/Application.hpp"
3 #include "app/Assets.hpp"
4 #include "app/init.hpp"
5 #include "app/MasterState.hpp"
6 #include "world/Planet.hpp"
7 #include "world/Simulation.hpp"
8 #include "world/Sun.hpp"
9 #include "world/TileSet.hpp"
10 #include "world/TileType.hpp"
11
12 #include <cstdint>
13 #include <iostream>
14
15
16 using namespace blobs;
17
18 int main(int argc, char *argv[]) {
19         app::Init init(true, 8);
20         app::Assets assets;
21
22         world::TileSet tiles;
23         tiles.Add({ "ice",     "Ice",     0, 0 });
24         tiles.Add({ "black",   "Black",   0, 1 });
25         tiles.Add({ "red",     "Red",     0, 2 });
26         tiles.Add({ "grass",   "Grass",   0, 3 });
27         tiles.Add({ "water",   "Water",   0, 4 });
28         tiles.Add({ "sand",    "Sand",    0, 5 });
29         tiles.Add({ "tundra",  "Tundra",  0, 6 });
30         tiles.Add({ "magenta", "Magenta", 0, 7 });
31         tiles.Add({ "rock",    "Rock",    0, 8 });
32
33         world::Sun sun;
34         sun.Mass(1.0e12);
35         sun.Radius(10.0);
36         sun.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
37         sun.AngularMomentum(1.0e13);
38
39         world::Planet planet(11);
40         planet.SetParent(sun);
41         planet.Mass(1.0e9);
42         planet.GetOrbit().SemiMajorAxis(941.7);
43         planet.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
44         planet.AxialTilt(glm::dvec2(PI * 0.127, 0.0));
45         planet.AngularMomentum(1.25e9);
46
47         world::Planet moon(3);
48         moon.SetParent(planet);
49         moon.Mass(1.0e6);
50         moon.GetOrbit().SemiMajorAxis(25.0);
51         moon.Rotation(PI * 0.25);
52         moon.AngularMomentum(1.0e4);
53
54         world::Planet second_planet(9);
55         second_planet.SetParent(sun);
56         second_planet.Mass(1.0e9);
57         second_planet.GetOrbit().SemiMajorAxis(350.0);
58         second_planet.SurfaceTilt(glm::dvec2(PI * 0.125, PI * 0.25));
59         second_planet.AxialTilt(glm::dvec2(PI * 0.95, 0.0));
60         second_planet.AngularMomentum(1.0e8);
61
62         world::Simulation sim(sun);
63         sim.AddSun(sun);
64         sim.AddPlanet(planet);
65         sim.AddPlanet(second_planet);
66         sim.AddPlanet(moon);
67
68         world::GenerateEarthlike(tiles, planet);
69         world::GenerateTest(tiles, moon);
70         world::GenerateTest(tiles, second_planet);
71
72         std::cout << "length of year: " << planet.OrbitalPeriod() << "s" << std::endl;
73         std::cout << "length of moon cycle: " << moon.OrbitalPeriod() << "s" << std::endl;
74         std::cout << "length of day: " << planet.RotationalPeriod() << "s" << std::endl;
75         std::cout << "days per year: " << (planet.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
76         std::cout << "moon cycle in days: " << (moon.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
77         std::cout << "moon cycles per year: " << (planet.OrbitalPeriod() / moon.OrbitalPeriod()) << std::endl;
78
79         app::MasterState state(assets, sim);
80         state.GetCamera()
81                 .Reference(planet)
82                 // sunrise
83                 //.FirstPerson(0, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
84                 // sunset
85                 //.FirstPerson(3, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
86                 // from afar
87                 //.MapView(0, glm::vec3(0.0f, 0.0f, 25.0f), 0.0f)
88                 // from afar, rotating
89                 .Orbital(glm::vec3(-25.0f, 0.0f, 0.0f))
90         ;
91         // system view
92         //state.GetCamera()
93         //      .Reference(sun)
94         //      .Orbital(glm::vec3(-500.0f, 500.0f, 500.0f))
95         //;
96
97         app::Application app(init.window, init.viewport);
98         app.PushState(&state);
99         app.Run();
100
101         return 0;
102 }