forked from miguelfranca/BHRaytracer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Application.cpp
115 lines (85 loc) · 2.76 KB
/
Application.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "Application.h"
#include "Geodesic.hpp"
#include "Particle.hpp"
#include "Spacetime.hpp"
#include "Clock.hpp"
#include "ODEsolver.hpp"
#include "SkyMap.hpp"
Application::Application(std::string t)
{
title = t;
setStaticScreen(true);
setupWindow(1000, 1000, 1000, 0);
}
// called once before the loop starts
bool Application::onCreate()
{
/*
double M = 0.25;
Schwarzschild st(M);
VecD vel3 = {0.1, 0., 0.};
// VecD end_point = geo.shoot(pos3, vel3, true);
Geodesic geo(st, -1); // -1 for particles, 0 for light
// Geodesic geo(st, 0); // -1 for particles, 0 for light
VecD end_point = geo.shoot({10., M_PI / 2., 0.}, vel3, false, true);
return false;
*/
return true;
}
// first thing to be called every frame
bool Application::onHandleEvent(GF::Event &event)
{
// static double pan = M_PI / 180.;
static double pan = 0.;
// static double pan = M_PI / 180. * 6.5;
static double dpan = M_PI / 180. / 2.;
// if(pan >= 2. * M_PI)
// return false;
if (pan > 0.)
return true;
// Flat st;
double M = 0.25;
Schwarzschild st(M);
// double M = 0.25;
// double a = 0.;
// Kerr st(M, a);
// VecD position({10., M_PI / 2., pan});
VecD position({10., M_PI / 2., 0.});
VecD velocity({0., 0.0, 0.0});
double alpha = 180. / 180. * M_PI;
double beta = 0. / 180. * M_PI;
Particle par(st, position, velocity, alpha, beta, -1.);
par.setAngleViews(45. / 180. * M_PI, 45. / 180. * M_PI);
auto mat = par.view(200);
// mat.print();
//ImageSkyMap sky(st, "res/images/stars_3.jpg", false);
ColorSkyMap sky(st, false, M_PI / 18., M_PI / 180. / 5.);
sf::Image view = sky.getSkyView(mat);
sf::Texture txt;
txt.loadFromImage(view);
sf::Sprite sprt;
sprt.setTexture(txt, true);
sprt.setPosition(0, 0);
double sx = ((double)SCREENWIDTH) / mat.getNC();
double sy = ((double)SCREENHEIGHT) / mat.getNL();
sx = std::min(sx, sy);
sprt.scale(sx, sx);
window.draw(sprt);
view.saveToFile("tmp/screenshot" + std::to_string(time(NULL)) + ".png");
// char buffer[30];
// sprintf(buffer, "walk_around_%05d.png",
// (int)std::round(pan * 180. / M_PI * 100));
// view.saveToFile(buffer);
pan += dpan;
return true;
}
// called every frame before draw
bool Application::onUpdate(const float fElapsedTime, const float fTotalTime)
{
return true;
}
// last thing to be called every frame
bool Application::onDraw() { return true; }
// called before exiting the app
void Application::onDestroy() {}
void Application::onSwitch(std::string other) {}