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