]> git.localhorst.tv Git - blobs.git/blob - src/blobs.cpp
(slightly) better camera handling
[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.0e9);
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::Simulation sim(sun);
44         sim.AddSun(sun);
45         sim.AddPlanet(planet);
46         sim.AddPlanet(moon);
47
48         std::cout << "length of year: " << planet.OrbitalPeriod() << "s" << std::endl;
49         std::cout << "length of moon cycle: " << moon.OrbitalPeriod() << "s" << std::endl;
50         std::cout << "length of day: " << planet.RotationalPeriod() << "s" << std::endl;
51         std::cout << "days per year: " << (planet.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
52         std::cout << "moon cycle in days: " << (moon.OrbitalPeriod() / planet.RotationalPeriod()) << std::endl;
53         std::cout << "moon cycles per year: " << (planet.OrbitalPeriod() / moon.OrbitalPeriod()) << std::endl;
54
55         app::MasterState state(assets, sim);
56         state.GetCamera()
57                 .Reference(planet)
58                 // sunrise
59                 .FirstPerson(0, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
60                 // sunset
61                 //.FirstPerson(3, glm::vec3(0.0f, 0.0f, 0.1f), glm::vec3(1.0f, -0.75f, 0.1f))
62                 // from afar
63                 //.MapView(0, glm::vec3(0.0f, 0.0f, 25.0f), 0.0f)
64                 // system view
65                 //.Orbital(glm::vec3(50.0f, 2500.0f, 50.0f));
66         ;
67         planet.BuildVAOs();
68
69         app::Application app(init.window, init.viewport);
70         app.PushState(&state);
71         app.Run();
72
73         return 0;
74 }