SO3Engine
SO3ParticleSystem.cpp
Go to the documentation of this file.
1
9
10namespace SO3
11{
12
14 {
15 Ogre::ParticleSystemManager::getSingletonPtr()->removeAllTemplates(true);
16 }
17
18 SParticleSystem::SParticleSystem(SScene* parent, const std::string& particleSystemName, const std::string& particleTemplateName) : SNode(parent, particleSystemName, SNode::PARTICLE_SYSTEM_TYPE_ID)
19 {
20 O3ParticleSystem = currentScene->GetOgreScenePointer()->createParticleSystem(particleSystemName, particleTemplateName);
21 O3SceneNode->attachObject(O3ParticleSystem);
22
23 templateName = particleTemplateName;
24 speedFactor = O3ParticleSystem->getSpeedFactor();
25 isEnable = true;
26 isPaused = false;
27
29 }
30
31 SParticleSystem::SParticleSystem() : SNode(0, "", SNode::PARTICLE_SYSTEM_TYPE_ID)
32 {
33 // Forbiden (private)
34 }
35
37 {
38 O3SceneNode->detachObject(O3ParticleSystem);
39 currentScene->GetOgreScenePointer()->destroyParticleSystem(O3ParticleSystem);
42
43 /*TODO
44 Ogre::MaterialManager::getSingleton().unloadUnreferencedResources(false);
45 Ogre::TextureManager::getSingleton().unloadUnreferencedResources(false);*/
46 }
47
49 {
50 return O3ParticleSystem;
51 }
52
53 void SParticleSystem::SetRenderingDistance(const float& distance)
54 {
55 return O3ParticleSystem->setRenderingDistance(distance);
56 }
57
59 {
60 return O3ParticleSystem->getRenderingDistance();
61 }
62
63 void SParticleSystem::SetScale(const Ogre::Vector3& scale)
64 {
65 if (O3ParticleSystem->getKeepParticlesInLocalSpace())
66 O3SceneNode->setScale(scale);
67 }
68
70 {
71 return templateName;
72 }
73
74 void SParticleSystem::SetSpeed(const float& speed)
75 {
76 speedFactor = speed;
77 if (!isPaused && isEnable)
78 O3ParticleSystem->setSpeedFactor(speedFactor);
79 }
80
82 {
83 return speedFactor;
84 }
85
86 void SParticleSystem::SetEnable(const bool& enable)
87 {
88 int numEmitters = O3ParticleSystem->getNumEmitters();
89 if (!enable)
90 {
91 O3ParticleSystem->setEmitting(false);
92 }
93 else
94 {
95 isPaused = false;
96 O3ParticleSystem->setSpeedFactor(speedFactor);
97 O3ParticleSystem->setEmitting(true);
98 for (int i = 0; i < numEmitters; i++)
99 O3ParticleSystem->getEmitter(i)->setEnabled(true);
100 }
101 isEnable = enable;
102 }
103
105 {
106 return isEnable;
107 }
108
109 void SParticleSystem::SetPaused(const bool& pause)
110 {
111 if (!pause && isEnable)
112 {
113 O3ParticleSystem->setSpeedFactor(speedFactor);
114 }
115 else if (pause)
116 {
117 speedFactor = O3ParticleSystem->getSpeedFactor();
118 O3ParticleSystem->setSpeedFactor(0.0f);
119 }
120 isPaused = pause;
121 }
122
124 {
125 return isPaused;
126 }
127
129 {
130 O3ParticleSystem->clear();
131 }
132
133}
SScene * currentScene
Definition SO3NodeScol.h:68
Ogre::SceneNode * O3SceneNode
Definition SO3NodeScol.h:69
Ogre::MovableObject * ogreMovableObject
Definition SO3NodeScol.h:70
static void ClearParticleTemplates()
virtual void SetScale(const Ogre::Vector3 &scale)
virtual void SetRenderingDistance(const float &distance)
void SetPaused(const bool &pause)
virtual float GetRenderingDistance()
Ogre::ParticleSystem * GetOgreParticleSystem()
Ogre::ParticleSystem * O3ParticleSystem
std::string GetParticleTemplateName()
void SetEnable(const bool &enable)
void SetSpeed(const float &speed)
Ogre::SceneManager * GetOgreScenePointer()
Definition SO3Scene.cpp:449