Fillwave  10.0.0
EmiterPointCPU.h
1 #pragma once
2 
3 /*
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2018 Filip Wasil and Fillwave community members
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
12  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 #include <flw/flf/models/base/IEmiterPoint.h>
25 
26 #include <flw/flc/buffers/mVertexBufferFloat.h>
27 #include <flw/flc/operations/TQuery.h>
28 
29 namespace flw {
30 class ICamera;
31 
32 namespace flf {
33 
40 class EmiterPointCPU : public IReloadable, public Entity, public IEmiterPoint {
41 public:
43  Engine *engine
44  , GLfloat emitingSourceRate
45  , GLuint howMany
46  , glm::vec4 color
47  , glm::vec3 acceleration = glm::vec3(0.0)
48  , glm::vec3 startVelocity = glm::vec3(0.0)
49  , glm::vec3 robustnessVelocity = glm::vec3(0.0)
50  , glm::vec3 startPosition = glm::vec3(0.0)
51  , glm::vec3 robustnessPosition = glm::vec3(0.0)
52  , GLfloat startSize = 1.0
53  , GLfloat lifetime = 6.0
54  , flc::Texture2D* texture = nullptr
55  , GLenum blendingSource = GL_SRC_ALPHA
56  , GLenum blendingDestination = GL_ONE_MINUS_SRC_ALPHA
57  , GLboolean depthTesting = GL_TRUE
58  , GLfloat alphaCutOffLevel = 0.0f);
59 
60  ~EmiterPointCPU() override = default;
61 
62  /* IEmiterPoint */
63  void update(GLfloat timeElapsedSec) override;
64 
65  /* IRenderable */
66  void drawFR(ICamera& camera) override;
67  void drawPBRP(ICamera& camera) override;
68  bool getRenderItem(flc::RenderItem &item) override;
69 
70  /* IRenderable */
71  void updateRenderer(flc::IRenderer &renderer) override;
72 
73  private:
74  glm::vec3 mAcceleration;
75  glm::vec3 mStartVelocity;
76  glm::vec3 mStartPosition;
77  glm::vec3 mCameraPosition;
78 
79  /* ULC - Uniform location cache */
81  GLint mULCModelMatrix;
82  GLint mULCTextureUnit;
83  GLint mULCViewProjectionMatrix;
84  GLint mULCCameraPosition;
85  GLint mULCPointSize;
86  GLint mULCColor;
87  GLint mULCAcceleration;
88  GLint mULCLifeTime;
89  GLint mULCAlphaCutOff;
90  GLint mULCTimeElapsed;
91 
92  void initBuffers() override;
93  void initPipeline() override;
94  void initUniformsCache() override;
95  void initVAO() override;
96  void initVBO() override;
97  void coreDraw();
98 };
99 
100 } /* flf */
101 } /* flw */
Definition: Aliases.h:30
Encapsulates reloadable objects.
Definition: IReloadable.h:35
Drawable Entity which emits particles.
Definition: IEmiterPoint.h:40
Base for all renderers.
Definition: IRenderer.h:42
Single GLSL 2D Texture object.
Definition: Texture2D.h:36
Vertex buffer specialized with VertexParticle data structure.
Definition: mVertexBufferParticles.h:43
Fillwave engine core.
Definition: Engine.h:85
Base for all Scene nodes.
Definition: Entity.h:48
Polynomial particle Emiter. Can generate a particles with velocity, direction, and acceleration defin...
Definition: EmiterPointCPU.h:40
Single draw item structure.
Definition: RenderItem.h:33
Stores camera view parameters.
Definition: ICamera.h:32