[852] | 1 | #pragma once
|
---|
| 2 | #include "Particle.h"
|
---|
| 3 | #include "ParticleEmitter.h"
|
---|
| 4 | #include "Camera.h"
|
---|
| 5 | #include <random.h>
|
---|
| 6 |
|
---|
| 7 | class ParticleSystem
|
---|
| 8 | {
|
---|
| 9 | public:
|
---|
| 10 | ParticleSystem(void);
|
---|
| 11 | ~ParticleSystem(void);
|
---|
| 12 |
|
---|
| 13 | double m_LittleSystemRadius;
|
---|
| 14 |
|
---|
| 15 | private:
|
---|
| 16 | Particle* m_ParticleList; //ez csak segédelem
|
---|
| 17 | Particle* m_LastParticle;
|
---|
| 18 |
|
---|
| 19 | Particle* m_ParticleArray;
|
---|
| 20 |
|
---|
| 21 | float* VertexBuffer;
|
---|
| 22 | float* TexcoordBuffer;
|
---|
| 23 | float* NormalBuffer;
|
---|
| 24 | float* ColorBuffer;
|
---|
| 25 | unsigned int* IndexBuffer;
|
---|
| 26 | unsigned int m_nVBOVertices; // Vertex VBO Name
|
---|
| 27 | unsigned int m_nVBOTexCoords; // Texture Coordinate VBO Name
|
---|
| 28 | unsigned int m_nVBOIndices;
|
---|
| 29 |
|
---|
| 30 | unsigned int m_Quota;
|
---|
| 31 | unsigned int m_Count;
|
---|
| 32 |
|
---|
| 33 | int m_Type; //0=point 1=billboard
|
---|
| 34 |
|
---|
| 35 | Vector m_UpVector;
|
---|
| 36 | Vector m_RightVector;
|
---|
| 37 | Vector m_CameraPosition;
|
---|
| 38 |
|
---|
| 39 | Vector m_Position;
|
---|
| 40 |
|
---|
| 41 | bool m_refreshed;
|
---|
| 42 |
|
---|
| 43 | double m_BoundingRadius;
|
---|
| 44 |
|
---|
| 45 | public:
|
---|
| 46 | ParticleEmitter m_Emitter;
|
---|
| 47 | bool m_refreshonce;
|
---|
| 48 |
|
---|
| 49 | void setQuota(unsigned int quota){m_Quota=quota;}
|
---|
| 50 | void setType(int type){m_Type=type;}
|
---|
| 51 | void setPosition(Vector pos){m_Position=pos;}
|
---|
| 52 | Vector getPosition(){return m_Position;}
|
---|
| 53 | double getBoundingRadius(){return m_BoundingRadius;}
|
---|
| 54 |
|
---|
| 55 | void RefreshParticles(unsigned int Dt,unsigned int TimefromSecond);
|
---|
| 56 | void RenderAsPoints(bool sprites=false);
|
---|
| 57 | void RenderAsBillboard();
|
---|
| 58 | void RenderAsSpheres();
|
---|
| 59 |
|
---|
| 60 | void RefreshCamera(Camera* cam)
|
---|
| 61 | {
|
---|
| 62 | m_CameraPosition=cam->getPosition();
|
---|
| 63 | m_UpVector=cam->getUpVector();
|
---|
| 64 | m_RightVector=cam->getRightVector();
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | void CreateSphere();
|
---|
| 68 | GLfloat *P, *N, *uv;
|
---|
| 69 | GLuint *indices;
|
---|
| 70 | int nTris;
|
---|
| 71 | int nVerts;
|
---|
| 72 |
|
---|
| 73 | void SortParticles(bool increment);
|
---|
| 74 | void RefreshBuffer(bool billboard=true);
|
---|
| 75 | void RefrBRadius_Dist(bool refresh_rad=true);//refresh bounding radius and distances
|
---|
| 76 |
|
---|
| 77 | void SortFromCamera(Camera* Camera,bool towardCamera,bool aspoints,bool refr_rad=false)
|
---|
| 78 | {
|
---|
| 79 | RefreshCamera(Camera);
|
---|
| 80 | RefrBRadius_Dist(refr_rad);
|
---|
| 81 | SortParticles(towardCamera);
|
---|
| 82 | RefreshBuffer(!aspoints);
|
---|
| 83 | };
|
---|
| 84 |
|
---|
| 85 | Particle* getParticleArray(){return m_ParticleArray;};
|
---|
| 86 | float* getVertexBuffer(){return VertexBuffer;}
|
---|
| 87 |
|
---|
| 88 | };
|
---|