]> git.localhorst.tv Git - blobs.git/blob - src/blobs.cpp
earthlike planet gen prototype
[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
10 #include <cstdint>
11 #include <iostream>
12
13
14 using namespace blobs;
15
16 int main(int argc, char *argv[]) {
17         app::Init init(true, 8);
18         app::Assets assets;
19
20         world::Sun sun;
21         sun.Mass(1.0e12);
22         sun.Radius(10.0);
23         sun.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
24         sun.AngularMomentum(1.0e13);
25
26         world::Planet planet(11);
27         planet.SetParent(sun);
28         planet.Mass(1.0e9);
29         planet.GetOrbit().SemiMajorAxis(941.7);
30         planet.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
31         planet.AxialTilt(glm::dvec2(PI * 0.127, 0.0));
32         planet.AngularMomentum(1.25e9);
33
34         world::Planet moon(3);
35         moon.SetParent(planet);
36         moon.Mass(1.0e6);
37         moon.GetOrbit().SemiMajorAxis(25.0);
38         moon.Rotation(PI * 0.25);
39         moon.AngularMomentum(1.0e4);
40
41         world::Planet second_planet(9);
42         second_planet.SetParent(sun);
43         second_planet.Mass(1.0e9);
44         second_planet.GetOrbit().SemiMajorAxis(350.0);
45         second_planet.SurfaceTilt(glm::dvec2(PI * 0.125, PI * 0.25));
46         second_planet.AxialTilt(glm::dvec2(PI * 0.95, 0.0));
47         second_planet.AngularMomentum(1.0e8);
48
49         world::Simulation sim(sun);
50         sim.AddSun(sun);
51         sim.AddPlanet(planet);
52         sim.AddPlanet(second_planet);
53         sim.AddPlanet(moon);
54
55         world::GenerateEarthlike(planet);
56         world::GenerateTest(moon);
57         world::GenerateTest(second_planet);
58
59         std::cout << "length of year: " << planet.OrbitalPeriod() << "s" << std::endl;
60         std::cout << "length of moon cycle: " << moon.OrbitalPeriod() << "s" << std::endl;
61         std::cout << "length of day: " << planet.RotationalPeriod() << "s" << std::endl;
62         std::cout << "days per year: " << (planet.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
63         std::cout << "moon cycle in days: " << (moon.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
64         std::cout << "moon cycles per year: " << (planet.OrbitalPeriod() / moon.OrbitalPeriod()) << std::endl;
65
66         app::MasterState state(assets, sim);
67         state.GetCamera()
68                 .Reference(planet)
69                 // sunrise
70                 //.FirstPerson(0, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
71                 // sunset
72                 //.FirstPerson(3, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
73                 // from afar
74                 //.MapView(0, glm::vec3(0.0f, 0.0f, 25.0f), 0.0f)
75                 // from afar, rotating
76                 .Orbital(glm::vec3(-25.0f, 0.0f, 0.0f))
77         ;
78         // system view
79         //state.GetCamera()
80         //      .Reference(sun)
81         //      .Orbital(glm::vec3(-500.0f, 500.0f, 500.0f))
82         //;
83         planet.BuildVAOs();
84
85         app::Application app(init.window, init.viewport);
86         app.PushState(&state);
87         app.Run();
88
89         return 0;
90 }