-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.cpp
More file actions
84 lines (76 loc) · 2.11 KB
/
Copy pathscene.cpp
File metadata and controls
84 lines (76 loc) · 2.11 KB
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
#include "main.hpp"
#include "geometry.hpp"
#include "keys.hpp"
#include "physics.hpp"
#include "bodymanager.hpp"
#include "body.hpp"
#include "camera.hpp"
#include <iostream>
const float time_factor = 1.0f;
BodyManager planets;
Camera camera;
void
init_scene()
{
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
float yellow[4] = {1.0f,0.8f,0.2f,1.0f};
planets.addBody(Body(
vector3(1.0f, 0.0f, 0.0f),
vector3(0.0f, 0.0f, 0.0f),
10.0f, 0.3f,
get_geometry(3,true),yellow, true));
float blue[4] = {0.5f,0.5f,1.0f,1.0f};
planets.addBody(Body(
vector3(0.0f,5.0f,0.0f),
vector3(0.0f,0.0f,1.0f),
1.0f, 0.2f,
get_geometry(1,true),blue, false));
float red[4] = {0.9f,0.4f,0.2f,1.0f};
planets.addBody(Body(
vector3(10.0f,0.0f,0.0f),
vector3(0.0f,0.0f,1.0f),
1.0f, 0.2f,
get_geometry(2,true), red, false));
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0);
camera.setBodyList(&planets);
}
void
tick_scene()
{
if(key_released('q'))
{
exit(0);
}
if(key_released('r')){
planets.addRandomBody(false);
}
if(key_released('t')){
planets.addRandomBody(true);
}
physics::physicsIteration(planets.getBodyList(), time_factor*get_time());
camera.tickControl();
}
void
render_scene()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluLookAt(0.0, 1.1e7, 0.0, target.getPosition().x, target.getPosition().y, target.getPosition().z, 1.0, 0.0, 0.0);
camera.setCamera();
//Navigationsgitter
glPushMatrix();
glRotated(90.0, 0.0, 1.0, 0.0);
float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, white);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);
glPopMatrix();
glutWireSphere(500.0, 36, 18);
planets.drawBodys();
}