code format
This commit is contained in:
@@ -19,13 +19,16 @@
|
||||
#ifndef GLPARTICLES_SYSTEM_H
|
||||
#define GLPARTICLES_SYSTEM_H
|
||||
|
||||
#include <QMutex>
|
||||
#include "gltexture_manager.h"
|
||||
#include "globject.h"
|
||||
#include "glcamera.h"
|
||||
#include "globject.h"
|
||||
#include "gltexture_manager.h"
|
||||
|
||||
class GLParticlesSystem: public QObject, public GLObjectBase, protected QOpenGLFunctions
|
||||
{
|
||||
#include <QMutex>
|
||||
|
||||
class GLParticlesSystem
|
||||
: public QObject
|
||||
, public GLObjectBase
|
||||
, protected QOpenGLFunctions {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float birthRate READ birthRate WRITE setBirthRate)
|
||||
Q_PROPERTY(float lifeDuration READ lifeDuration WRITE setLifeDuration)
|
||||
@@ -47,11 +50,16 @@ class GLParticlesSystem: public QObject, public GLObjectBase, protected QOpenGLF
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(bool birthEnabled READ isBirthEnabled WRITE setBirthEnabled)
|
||||
Q_PROPERTY(float fadeTime READ fadeTime WRITE setFadeTime)
|
||||
|
||||
public:
|
||||
GLParticlesSystem(const QVector3D & pos = QVector3D());
|
||||
~GLParticlesSystem() {;}
|
||||
~GLParticlesSystem() { ; }
|
||||
|
||||
enum Type {Cone, Omni, Box};
|
||||
enum Type {
|
||||
Cone,
|
||||
Omni,
|
||||
Box
|
||||
};
|
||||
|
||||
struct Particle {
|
||||
Particle(float life_dur = 40.);
|
||||
@@ -71,62 +79,65 @@ public:
|
||||
void update();
|
||||
void draw(QOpenGLShaderProgram * prog, bool);
|
||||
|
||||
float birthRate() const {return birthRate_;}
|
||||
float lifeDuration() const {return lifeDuration_;}
|
||||
float size() const {return size_;}
|
||||
float enlargeSpeed() const {return enlargeSpeed_;}
|
||||
float initialAngle() const {return initialAngle_;}
|
||||
float initialSpeed() const {return initialSpeed_;}
|
||||
float speedDecay() const {return speedDecay_;}
|
||||
float baseAngle() const {return baseAngle_;}
|
||||
QVector3D speedDirection() const {return speedDirection_;}
|
||||
QVector3D emitterPosition() const {return emitterPosition_;}
|
||||
QVector3D emitterDirection() const {return emitterDirection_;}
|
||||
Box3D emitterRect() const {return emitterRect_;}
|
||||
float lifeDurationJitter() const {return lifeDurationJitter_;}
|
||||
float speedJitter() const {return speedJitter_;}
|
||||
float speedDirectionJitter() const {return speedDirectionJitter_;}
|
||||
float sizeJitter() const {return sizeJitter_;}
|
||||
float enlargeSpeedJitter() const {return enlargeSpeedJitter_;}
|
||||
float angleJitter() const {return angleJitter_;}
|
||||
bool isActive() const {return active_;}
|
||||
bool isBirthEnabled() const {return birthEnabled_;}
|
||||
GLParticlesSystem::Type emitterType() const {return emitterType_;}
|
||||
float fadeTime() const {return fade_time;}
|
||||
bool isAddVerticalFaceEnabled() const {return add_vert_face;}
|
||||
float birthRate() const { return birthRate_; }
|
||||
float lifeDuration() const { return lifeDuration_; }
|
||||
float size() const { return size_; }
|
||||
float enlargeSpeed() const { return enlargeSpeed_; }
|
||||
float initialAngle() const { return initialAngle_; }
|
||||
float initialSpeed() const { return initialSpeed_; }
|
||||
float speedDecay() const { return speedDecay_; }
|
||||
float baseAngle() const { return baseAngle_; }
|
||||
QVector3D speedDirection() const { return speedDirection_; }
|
||||
QVector3D emitterPosition() const { return emitterPosition_; }
|
||||
QVector3D emitterDirection() const { return emitterDirection_; }
|
||||
Box3D emitterRect() const { return emitterRect_; }
|
||||
float lifeDurationJitter() const { return lifeDurationJitter_; }
|
||||
float speedJitter() const { return speedJitter_; }
|
||||
float speedDirectionJitter() const { return speedDirectionJitter_; }
|
||||
float sizeJitter() const { return sizeJitter_; }
|
||||
float enlargeSpeedJitter() const { return enlargeSpeedJitter_; }
|
||||
float angleJitter() const { return angleJitter_; }
|
||||
bool isActive() const { return active_; }
|
||||
bool isBirthEnabled() const { return birthEnabled_; }
|
||||
GLParticlesSystem::Type emitterType() const { return emitterType_; }
|
||||
float fadeTime() const { return fade_time; }
|
||||
bool isAddVerticalFaceEnabled() const { return add_vert_face; }
|
||||
|
||||
void setBirthRate(const float & arg) {birthRate_ = arg; tick_birth = birthRate_ / freq;}
|
||||
void setLifeDuration(const float & arg) {lifeDuration_ = arg;}
|
||||
void setSize(const float & arg) {size_ = arg;}
|
||||
void setEnlargeSpeed(const float & arg) {enlargeSpeed_ = arg;}
|
||||
void setInitialAngle(const float & arg) {initialAngle_ = arg;}
|
||||
void setInitialSpeed(const float & arg) {initialSpeed_ = arg;}
|
||||
void setBaseAngle(const float & arg) {baseAngle_ = arg;}
|
||||
void setSpeedDecay(const float & arg) {speedDecay_ = arg;}
|
||||
void setSpeedDirection(const QVector3D & arg) {speedDirection_ = arg;}
|
||||
void setEmitterPosition(const QVector3D & arg) {emitterPosition_ = arg;}
|
||||
void setEmitterDirection(const QVector3D & arg) {emitterDirection_ = arg.normalized();}
|
||||
void setEmitterRect(const Box3D & arg) {emitterRect_ = arg;}
|
||||
void setLifeDurationJitter(const float & arg) {lifeDurationJitter_ = arg;}
|
||||
void setSpeedJitter(const float & arg) {speedJitter_ = arg;}
|
||||
void setSpeedDirectionJitter(const float & arg) {speedDirectionJitter_ = arg;}
|
||||
void setSizeJitter(const float & arg) {sizeJitter_ = arg;}
|
||||
void setEnlargeSpeedJitter(const float & arg) {enlargeSpeedJitter_ = arg;}
|
||||
void setActive(const bool & arg) {active_ = arg;}
|
||||
void setAngleJitter(const float & arg) {angleJitter_ = arg;}
|
||||
void setBirthEnabled(const bool & arg) {birthEnabled_ = arg;}
|
||||
void setEmitterType(const GLParticlesSystem::Type & arg) {emitterType_ = arg;}
|
||||
void setFadeTime(const float & arg) {fade_time = arg;}
|
||||
void setAddVerticalFaceEnabled(const bool & arg) {add_vert_face = arg;}
|
||||
void setTextureRect(const QRectF & arg) {tex_rect = arg;}
|
||||
void setTextureScale(const float & x, const float & y) {tex_scale = QSizeF(x, y);}
|
||||
void setTextureScale(const QSizeF & arg) {tex_scale = arg;}
|
||||
void setBirthRate(const float & arg) {
|
||||
birthRate_ = arg;
|
||||
tick_birth = birthRate_ / freq;
|
||||
}
|
||||
void setLifeDuration(const float & arg) { lifeDuration_ = arg; }
|
||||
void setSize(const float & arg) { size_ = arg; }
|
||||
void setEnlargeSpeed(const float & arg) { enlargeSpeed_ = arg; }
|
||||
void setInitialAngle(const float & arg) { initialAngle_ = arg; }
|
||||
void setInitialSpeed(const float & arg) { initialSpeed_ = arg; }
|
||||
void setBaseAngle(const float & arg) { baseAngle_ = arg; }
|
||||
void setSpeedDecay(const float & arg) { speedDecay_ = arg; }
|
||||
void setSpeedDirection(const QVector3D & arg) { speedDirection_ = arg; }
|
||||
void setEmitterPosition(const QVector3D & arg) { emitterPosition_ = arg; }
|
||||
void setEmitterDirection(const QVector3D & arg) { emitterDirection_ = arg.normalized(); }
|
||||
void setEmitterRect(const Box3D & arg) { emitterRect_ = arg; }
|
||||
void setLifeDurationJitter(const float & arg) { lifeDurationJitter_ = arg; }
|
||||
void setSpeedJitter(const float & arg) { speedJitter_ = arg; }
|
||||
void setSpeedDirectionJitter(const float & arg) { speedDirectionJitter_ = arg; }
|
||||
void setSizeJitter(const float & arg) { sizeJitter_ = arg; }
|
||||
void setEnlargeSpeedJitter(const float & arg) { enlargeSpeedJitter_ = arg; }
|
||||
void setActive(const bool & arg) { active_ = arg; }
|
||||
void setAngleJitter(const float & arg) { angleJitter_ = arg; }
|
||||
void setBirthEnabled(const bool & arg) { birthEnabled_ = arg; }
|
||||
void setEmitterType(const GLParticlesSystem::Type & arg) { emitterType_ = arg; }
|
||||
void setFadeTime(const float & arg) { fade_time = arg; }
|
||||
void setAddVerticalFaceEnabled(const bool & arg) { add_vert_face = arg; }
|
||||
void setTextureRect(const QRectF & arg) { tex_rect = arg; }
|
||||
void setTextureScale(const float & x, const float & y) { tex_scale = QSizeF(x, y); }
|
||||
void setTextureScale(const QSizeF & arg) { tex_scale = arg; }
|
||||
|
||||
void addForce(const QVector3D & f) {forces << f;}
|
||||
void birthParticles(int count) {need_birth += count;}
|
||||
void addForce(const QVector3D & f) { forces << f; }
|
||||
void birthParticles(int count) { need_birth += count; }
|
||||
|
||||
float frequency() const {return freq;}
|
||||
void setFrequency(const float & f) {freq = f;}
|
||||
float frequency() const { return freq; }
|
||||
void setFrequency(const float & f) { freq = f; }
|
||||
|
||||
float additionalSpeed;
|
||||
|
||||
@@ -145,9 +156,10 @@ private:
|
||||
float lifeDurationJitter_, speedJitter_, speedDirectionJitter_, sizeJitter_, angleJitter_, initialAngle_;
|
||||
float enlargeSpeed_, enlargeSpeedJitter_, baseAngle_;
|
||||
bool active_, birthEnabled_, is_diffuse_anim, add_vert_face;
|
||||
|
||||
};
|
||||
|
||||
inline bool operator <(const GLParticlesSystem::Particle & f, const GLParticlesSystem::Particle & s) {return f.pos_h.z() > s.pos_h.z();}
|
||||
inline bool operator<(const GLParticlesSystem::Particle & f, const GLParticlesSystem::Particle & s) {
|
||||
return f.pos_h.z() > s.pos_h.z();
|
||||
}
|
||||
|
||||
#endif // GLPARTICLES_SYSTEM_H
|
||||
|
||||
Reference in New Issue
Block a user