]> git.localhorst.tv Git - blobs.git/blob - src/blobs.cpp
half-assed implementation of "other" body rendering
[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         world::GenerateTest(planet);
28         planet.SetParent(sun);
29         planet.Mass(1.0e9);
30         planet.GetOrbit().SemiMajorAxis(941.7);
31         planet.SurfaceTilt(glm::dvec2(PI * 0.25, PI * 0.25));
32         planet.AxialTilt(glm::dvec2(PI * 0.127, 0.0));
33         planet.AngularMomentum(1.25e9);
34
35         world::Planet moon(3);
36         world::GenerateTest(moon);
37         moon.SetParent(planet);
38         moon.Mass(1.0e6);
39         moon.GetOrbit().SemiMajorAxis(25.0);
40         moon.Rotation(PI * 0.25);
41         moon.AngularMomentum(1.0e4);
42
43         world::Planet second_planet(9);
44         world::GenerateTest(second_planet);
45         second_planet.SetParent(sun);
46         second_planet.Mass(1.0e9);
47         second_planet.GetOrbit().SemiMajorAxis(350.0);
48         second_planet.SurfaceTilt(glm::dvec2(PI * 0.125, PI * 0.25));
49         second_planet.AxialTilt(glm::dvec2(PI * 0.95, 0.0));
50         second_planet.AngularMomentum(1.0e8);
51
52         world::Simulation sim(sun);
53         sim.AddSun(sun);
54         sim.AddPlanet(planet);
55         sim.AddPlanet(second_planet);
56         sim.AddPlanet(moon);
57
58         std::cout << "length of year: " << planet.OrbitalPeriod() << "s" << std::endl;
59         std::cout << "length of moon cycle: " << moon.OrbitalPeriod() << "s" << std::endl;
60         std::cout << "length of day: " << planet.RotationalPeriod() << "s" << std::endl;
61         std::cout << "days per year: " << (planet.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
62         std::cout << "moon cycle in days: " << (moon.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
63         std::cout << "moon cycles per year: " << (planet.OrbitalPeriod() / moon.OrbitalPeriod()) << std::endl;
64
65         app::MasterState state(assets, sim);
66         state.GetCamera()
67                 .Reference(planet)
68                 // sunrise
69                 .FirstPerson(0, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
70                 // sunset
71                 //.FirstPerson(3, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
72                 // from afar
73                 //.MapView(0, glm::vec3(0.0f, 0.0f, 25.0f), 0.0f)
74         ;
75         // system view
76         //state.GetCamera()
77         //      .Reference(sun)
78         //      .Orbital(glm::vec3(-500.0f, 500.0f, 500.0f))
79         //;
80         planet.BuildVAOs();
81
82         app::Application app(init.window, init.viewport);
83         app.PushState(&state);
84         app.Run();
85
86         return 0;
87 }