-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParticleSystem.h
58 lines (52 loc) · 1.24 KB
/
ParticleSystem.h
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
#pragma once
#include "core.h"
#include "Particle.h"
class ParticleSystem
{
static const int MAX_P = 500;
static const float PI;
GLuint VAO;
GLuint VBO, EBO;
glm::vec3 lineColor;
float spawnPeriod;
glm::mat4 world;
glm::mat4 model;
glm::mat4 view;
float timeToSpawn;
void InitializeArrays();
float ParticleSystem::RandomOffset();
glm::vec3 RandomVec(glm::vec3 startVec, float variance);
glm::vec3 RandomDirVector();
public:
//std::vector<glm::vec3> vertices;
glm::vec3 vertices[MAX_P];
//std::vector<glm::uint> faces;
glm::uint faces[MAX_P];
Particle* particles[MAX_P];
glm::vec3 color;
glm::vec3 startPos;
glm::vec3 startVel;
float lifeSpan;
float posVar;
float velVar;
float lifeVar;
float pps;
float mass;
float radius;
int numParticles;
ParticleSystem();
~ParticleSystem();
void Draw(GLuint shader);
void Update(const glm::mat4& world, const glm::mat4& view);
void ApplyForces(glm::vec3 gravity, float density, float drag);
void Step(float delta);
void Spawn();
void IntegrateMotion(float delta);
void ApplyConstraints(float ground, float e, float mD);
void UpdateVertices();
void UpdateNormals();
void BindBuffers();
void PrintVec(glm::vec3 v) {
std::cout << v.x << " " << v.y << " " << v.z << std::endl;
}
};