Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParticleSource.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_PARTICLE_SOURCE_H_
34#define DVD_PARTICLE_SOURCE_H_
35
36#include "ParticleGenerator.h"
37
38namespace Divide {
39
41 public:
42 explicit ParticleSource(GFXDevice& context) noexcept;
43 explicit ParticleSource(GFXDevice& context, F32 emitRate) noexcept;
44 virtual ~ParticleSource() = default;
45
46 virtual void emit(U64 deltaTimeUS, const std::shared_ptr<ParticleData>& p);
47
48 void addGenerator(const std::shared_ptr<ParticleGenerator>& generator) {
49 _particleGenerators.push_back(generator);
50 }
51
52 void updateEmitRate(const F32 emitRate) noexcept { _emitRate = emitRate; }
53
54 [[nodiscard]] F32 emitRate() const noexcept { return _emitRate; }
55
56 void updateTransform(const vec3<F32>& position, const Quaternion<F32>& orientation) noexcept {
57 for (const auto& generator : _particleGenerators) {
58 generator->updateTransform(position, orientation);
59 }
60 }
61
62 protected:
66};
67}
68
69#endif //DVD_PARTICLE_SOURCE_H_
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
void updateTransform(const vec3< F32 > &position, const Quaternion< F32 > &orientation) noexcept
virtual ~ParticleSource()=default
void addGenerator(const std::shared_ptr< ParticleGenerator > &generator)
F32 emitRate() const noexcept
virtual void emit(U64 deltaTimeUS, const std::shared_ptr< ParticleData > &p)
vector< std::shared_ptr< ParticleGenerator > > _particleGenerators
void updateEmitRate(const F32 emitRate) noexcept
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
eastl::vector< Type > vector
Definition: Vector.h:42
uint64_t U64