VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
ParticleLayer.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef PARTICLELAYER_H
18 #define PARTICLELAYER_H
19 
20 #include <QObject>
21 
22 class b2ParticleSystem;
23 
32 class ParticleLayer : public QObject {
33  Q_OBJECT
34 
38  Q_PROPERTY(float radius READ getRadius WRITE setRadius NOTIFY radiusChanged)
43  Q_PROPERTY(float density READ getDensity WRITE setDensity NOTIFY densityChanged)
48  Q_PROPERTY(float gravityScale READ getGravityScale WRITE setGravityScale
50 
51 public:
56  explicit ParticleLayer(QObject* parent = nullptr);
57  virtual ~ParticleLayer();
58 
62  float getRadius() const;
67  void setRadius(float value);
71  float getDensity() const;
76  void setDensity(float value);
80  float getGravityScale() const;
85  void setGravityScale(float value);
86 
90  b2ParticleSystem* getParticleSystem() const { return mParticleSystem; }
91 
92 signals:
96  void radiusChanged();
100  void densityChanged();
104  void gravityScaleChanged();
105 
106 private:
107  b2ParticleSystem* mParticleSystem = nullptr;
108 };
109 Q_DECLARE_METATYPE(ParticleLayer*)
110 
111 #endif // PARTICLELAYER_H
float getGravityScale() const
Returns gravityScale.
void radiusChanged()
Emitted when radius changes.
void densityChanged()
Emitted when density changes.
float getRadius() const
Returns radius.
void setRadius(float value)
Sets radius.
float getDensity() const
Returns density.
float radius
Radius of particles in this layer, corresponding to b2ParticleSystem::SetRadius().
Definition: ParticleLayer.h:38
float gravityScale
Scaling factor on gravity affecting particles in this layer, corresponding to b2ParticleSystem::SetGr...
Definition: ParticleLayer.h:49
void setGravityScale(float value)
Sets gravityScale.
b2ParticleSystem * getParticleSystem() const
Returns the underlying b2ParticleSystem.
Definition: ParticleLayer.h:90
Wrapper around a b2ParticleSystem, which represents an independent layer of particles.
Definition: ParticleLayer.h:32
float density
Density of particles in this layer, corresponding to b2ParticleSystem::SetDensity().
Definition: ParticleLayer.h:43
void gravityScaleChanged()
Emitted when gravityScale changes.
QObject * parent() const
void setDensity(float value)
Sets density.