ComputerGraphik TU WIEN
particleSystemCPU.hpp
Go to the documentation of this file.
1 #ifndef PARTICLESYSTEMCPU_HPP
2 #define PARTICLESYSTEMCPU_HPP
3 
4 #include "sceneObject.hpp"
5 
7 
23 
24  struct ParticleGPU { //keep it POD
25  float xyz[3];
26  float alpha; // 0-dead, 1-newly created
27  };
28 
29  struct ParticleCPU : public ParticleGPU {
31 
32  ParticleCPU();
33 
34  bool operator>(const ParticleCPU& other) const {
35  return cameraDistance > other.cameraDistance;
36  }
37  };
38 
39 public:
40  ParticleSystemCPU(size_t particleCount, const std::string& name, Scene* scene = 0, Model* model = 0, const glm::mat4& modelMatrix = glm::mat4(1.0f));
41  virtual ~ParticleSystemCPU();
42 
43  void push(const glm::vec3& pos);
44 
45  void draw() const;
46  bool animate(double time);
47  void update(double deltaT);
48  void setShader(Shader* val);
49 
50 private:
51  double lastAnimate;
52  GLuint particlesVBO;
54  std::vector<ParticleCPU> particlesNew;
55  std::vector<ParticleCPU> particlesCPU;
56  std::vector<ParticleGPU> particlesGPU;
57 };
58 
59 #endif //PARTICLESYSTEMCPU_HPP
Definition: particleSystemCPU.hpp:24
std::vector< ParticleCPU > particlesCPU
Definition: particleSystemCPU.hpp:55
virtual ~ParticleSystemCPU()
Definition: particleSystemCPU.cpp:37
bool operator>(const ParticleCPU &other) const
Definition: particleSystemCPU.hpp:34
Encapsulates a graphical object model in the GPU.
Definition: model.hpp:14
Model * model
Definition: sceneObject.hpp:69
void setShader(Shader *val)
Definition: particleSystemCPU.cpp:154
ParticleSystemCPU(size_t particleCount, const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1.0f))
Definition: particleSystemCPU.cpp:20
void draw() const
Definition: particleSystemCPU.cpp:42
float xyz[3]
Definition: particleSystemCPU.hpp:25
int activeParticleCount
Definition: particleSystemCPU.hpp:53
Encapsulates the Rendering Engine, holds a complete scene and it's assets.
Definition: scene.hpp:71
Scene * scene
Definition: sceneObject.hpp:68
float alpha
Definition: particleSystemCPU.hpp:26
double lastAnimate
Definition: particleSystemCPU.hpp:51
ParticleCPU()
Definition: particleSystemCPU.cpp:13
bool animate(double time)
Definition: particleSystemCPU.cpp:90
Definition: particleSystemCPU.hpp:29
std::string name
Definition: sceneObject.hpp:73
void update(double deltaT)
Definition: particleSystemCPU.cpp:99
glm::mat4 modelMatrix
Definition: sceneObject.hpp:71
Implementation of CPU particle system.
Definition: particleSystemCPU.hpp:22
Encapsulates a shader program.
Definition: shader.hpp:9
std::vector< ParticleGPU > particlesGPU
Definition: particleSystemCPU.hpp:56
The base class of the objects which are rendered.
Definition: sceneObject.hpp:30
float cameraDistance
Definition: particleSystemCPU.hpp:30
std::vector< ParticleCPU > particlesNew
Definition: particleSystemCPU.hpp:54
void push(const glm::vec3 &pos)
Definition: particleSystemCPU.cpp:80
GLuint particlesVBO
Definition: particleSystemCPU.hpp:52