-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBody.h
More file actions
78 lines (51 loc) · 1.76 KB
/
Body.h
File metadata and controls
78 lines (51 loc) · 1.76 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
/// C++ libraries
#include <iostream>
/// GL libraries
#include <GL/gl.h>
#include <GL/glut.h>
/// C libraries
#include <cstdio>
#include <cstdlib>
/// Other libraries
#include <math.h>
#ifndef BODY_H
#define BODY_H
#define SHOW_FORCE_VECTOR 0
#define SHOW_SPEED_VECTOR 1
#define SHOW_ACCEL_VECTOR 2
typedef struct Material // A struct to save the material properties
{
float specular [4];
float diffuse [4];
float shininess[1];
} Material;
/* Auxiliar functions */
void displayAuxiliarData(float radius, double deltaX, double deltaY, double deltaZ);
/* The main class for a body */
class Body
{
public:
// Inherent properties
float mass; // Mass
float radius; // Radius of sphere
Material *material; // The material corresponding integer
// Temporary properties
double x, y, z; // Coordinates
double dx, dy, dz; // Speed components
double ax, ay, az; // Acceleration components
double fx, fy, fz; // Force components
Body(float, float, float);
// Auxiliar methods
void printData(); // Prints the data
inline void printCoord(); // Prints the coordinates
inline void printSpeed(); // Prints the speed components
inline void printAccel(); // Prints the acceleration components
void printForce(); // Prints the force components
void loadPropertiesFromFile(FILE *document); // loadPropertiesFromFile
// Physics methods
void updatePosition();
// Graphics methods
void setMaterial();
void display(int detailsOn, int projOn, int mode);
};
#endif // BODY_H