-
Notifications
You must be signed in to change notification settings - Fork 2
/
Particle.cpp
137 lines (110 loc) · 2.65 KB
/
Particle.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Particle with mass
*
* Written by: Sean Brown
*
*/
#define _GLFW_X11
#define _GLFW_GLX
#define _GLFW_USE_OPENGL
#define _GLFW_HAS_GLXGETPROCADDRESS
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include "Particle.h"
Particle::Particle() {// defaults: color = white, mass = 1.0f, pos = (0, 0, 0)
this->stationary = false;
this->pos = Vector(0.0f, 0.0f, 0.0f);
this->velocity = Vector(0.0f, 0.0f, 0.0f);
this->color = Vector(1.0f, 1.0f, 1.0f);
this->force = Vector(0.0f, 0.0f, 0.0f);
this->mass = 1.0f;
}
Particle::Particle(Vector p) {
this->stationary = false;
this->pos = p;
this->velocity = Vector(0.0f, 0.0f, 0.0f);
this->color = Vector(1.0f, 1.0f, 1.0f);
this->force = Vector(0.0f, 0.0f, 0.0f);
this->mass = 1.0f;
}
Particle::Particle(Vector p, Vector c){
this->stationary = false;
this->pos = p;
this->velocity = Vector(0.0f, 0.0f, 0.0f);
this->force = Vector(0.0f, 0.0f, 0.0f);
this->mass = 1.0f;
this->color = c;
}
Particle::Particle(Vector p, double m) {
this->stationary = false;
this->pos = p;
this->velocity = Vector(0.0f, 0.0f, 0.0f);
this->color = Vector(1.0f, 1.0f, 1.0f);
this->force = Vector(0.0f, 0.0f, 0.0f);
this->mass = m;
}
Particle::Particle(Vector p, Vector c, double m) {
this->stationary = false;
this->pos = p;
this->velocity = Vector(0.0f, 0.0f, 0.0f);
this->force = Vector(0.0f, 0.0f, 0.0f);
this->mass = m;
this->color = c;
}
void Particle::render() {
glBegin(GL_POINTS);
glColor3f(color.getX(), color.getY(), color.getZ());
glVertex3f(pos.getX(), pos.getY(), pos.getZ());
glEnd();
}
void Particle::toggleMovement() {
this->stationary = !stationary;
}
bool Particle::isStationary() {
return this->stationary;
}
Vector Particle::getPosition() {
return this->pos;
}
Vector Particle::getVelocity() {
return this->velocity;
}
Vector Particle::getColor() {
return this->color;
}
Vector Particle::getForce() {
return this->force;
}
double Particle::getMass() {
return this->mass;
}
void Particle::setStationary(bool s) {
this->stationary = s;
}
void Particle::setPosition(Vector p) {
this->pos = p;
}
void Particle::setPosition(double x, double y, double z) {
this->pos = Vector(x, y, z);
}
void Particle::setVelocity(Vector v) {
this->velocity = v;
}
void Particle::setVelocity(double x, double y, double z) {
this->velocity = Vector(x, y, z);
}
void Particle::setColor(Vector c) {
this->color = c;
}
void Particle::setColor(double r, double g, double b) {
this->color = Vector(r, g, b);
}
void Particle::setForce(Vector f) {
this->force = f;
}
void Particle::setForce(double x, double y, double z) {
this->force = Vector(x, y, z);
}
void Particle::setMass(double m) {
this->mass = m;
}