Newer
Older
#include "ComponentForModulation.h"
bool f = true;
// Function prototypes
void updatesin(GLfloat x, std::vector<GLfloat>& coord);
// Window dimensions
const GLuint WIDTH = 800, HEIGHT = 600;
// The MAIN function, from here we start the application and run the game loop
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* *** Инициализация спутника для моделирования *** */
//инициализаиця входных параметров
Kepler_elements_orbit element{ 26559.81038, 0.01203, 56.6024, 106.997, 53.2777, 154.03184 }; //кеплеровские элементы орбиты
satellite_parameters param{ 1,3,1.5 }; //физические парметры спутника
orbit_date start_time{ 2022, 7, 19, 18,20, 0 }; //время начала моделирования
orbit_date end_time{ 2022, 8, 21, 20, 20, 0 }; //время окончания моделирования
double input_step = 3600; // шаг моделирования в секундах
Ot _mtime{};
//перевод времени в формат модифицированных юлианских дней
double step = input_step/86400;
double start_MJD = _mtime.convert_GDs_to_MJD(start_time);
double end_MJD = _mtime.convert_GDs_to_MJD(end_time);
double current_time = start_MJD + step;
//создание планет
Earth _earth{};
Moon _moon{ start_MJD };
Sun _sun{ start_MJD };
Satellite satellite{ start_MJD, param, element, &_moon, &_sun, &_earth };
_earth = Earth{ start_MJD, satellite.getDCS() };
std::vector<GLfloat> modeling_DCS{}; //Массив хранящий вычесленные координаты в формате вершин
std::vector<GLfloat> modeling_DVS{}; //Массив хранящий вычесленные компоненты скорости в формате вершин
/*modulation(satellite, current_time, end_MJD, modeling_DCS, modeling_DVS);
current_time += step;*/
GLfloat max_DCS = 1; //максимальное по модулю значение координаты, необходим для масштабирования
/* *** инициализация opengl *** */
std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
// Init GLFW
glfwInit();
// Set all the required options for GLFW
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
// Create a GLFWwindow object that we can use for GLFW's functions
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr);
if (window == nullptr)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Set the required callback functions
glfwSetKeyCallback(window, key_callback);
// Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions
glewExperimental = GL_TRUE;
// Initialize GLEW to setup the OpenGL Function pointers
if (glewInit() != GLEW_OK)
{
std::cout << "Failed to initialize GLEW" << std::endl;
return -1;
}
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
// Define the viewport dimensions
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
/* *** Инициализаицая необоходимых пременных для отображения графики *** */
Shader myShaders{ "./shaders/shader.vert", "./shaders/shader.frag" };
std::vector<GLfloat> coord_vertices{};
GLuint VAO_for_coord;
glGenBuffers(1, &VAO_for_coord);
GLuint i = 0;
GLfloat x = -0.98f;
// Game loop
while (!glfwWindowShouldClose(window))
{
// Check if any events have been activiated (key pressed, mouse moved etc.) and call corresponding response functions
glEnable(GL_DEPTH_TEST);
glfwPollEvents();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
draw_coord_axis(VAO_for_coord);
// Render
// Clear the colorbuffer
myShaders.Use();
modulation(satellite, current_time, end_MJD, modeling_DCS, modeling_DVS);
//scaling(modeling_DCS, max_DCS);
draw_modulation(modeling_DCS, modeling_DVS, max_DCS, myShaders);
// Swap the screen buffers
glfwSwapBuffers(window);
current_time = (current_time <= end_MJD)?current_time+step: current_time;
}
// Terminate GLFW, clearing any resources allocated by GLFW.
glfwTerminate();
return 0;
}