SO3Engine
src
SO3SceneGraph
SO3ParticleSystem.cpp
Go to the documentation of this file.
1
7
#include "
SO3SceneGraph/SO3ParticleSystem.h
"
8
#include "
SO3SceneGraph/SO3Scene.h
"
9
10
namespace
SO3
11
{
12
13
void
SParticleSystem::ClearParticleTemplates
()
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
28
ogreMovableObject
=
O3ParticleSystem
;
29
}
30
31
SParticleSystem::SParticleSystem() :
SNode
(0,
""
,
SNode
::PARTICLE_SYSTEM_TYPE_ID)
32
{
33
// Forbiden (private)
34
}
35
36
SParticleSystem::~SParticleSystem
()
37
{
38
O3SceneNode
->detachObject(
O3ParticleSystem
);
39
currentScene
->
GetOgreScenePointer
()->destroyParticleSystem(
O3ParticleSystem
);
40
O3ParticleSystem
= 0;
41
ogreMovableObject
= 0;
42
43
/*TODO
44
Ogre::MaterialManager::getSingleton().unloadUnreferencedResources(false);
45
Ogre::TextureManager::getSingleton().unloadUnreferencedResources(false);*/
46
}
47
48
Ogre::ParticleSystem*
SParticleSystem::GetOgreParticleSystem
()
49
{
50
return
O3ParticleSystem
;
51
}
52
53
void
SParticleSystem::SetRenderingDistance
(
const
float
& distance)
54
{
55
return
O3ParticleSystem
->setRenderingDistance(distance);
56
}
57
58
float
SParticleSystem::GetRenderingDistance
()
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
69
std::string
SParticleSystem::GetParticleTemplateName
()
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
81
float
SParticleSystem::GetSpeed
()
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
104
bool
SParticleSystem::GetEnable
()
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
123
bool
SParticleSystem::GetPaused
()
124
{
125
return
isPaused
;
126
}
127
128
void
SParticleSystem::ClearParticles
()
129
{
130
O3ParticleSystem
->clear();
131
}
132
133
}
SO3ParticleSystem.h
SO3Scene.h
SO3::SNode
Definition
SO3NodeScol.h:43
SO3::SNode::currentScene
SScene * currentScene
Definition
SO3NodeScol.h:68
SO3::SNode::O3SceneNode
Ogre::SceneNode * O3SceneNode
Definition
SO3NodeScol.h:69
SO3::SNode::ogreMovableObject
Ogre::MovableObject * ogreMovableObject
Definition
SO3NodeScol.h:70
SO3::SParticleSystem::ClearParticles
void ClearParticles()
Definition
SO3ParticleSystem.cpp:128
SO3::SParticleSystem::isPaused
bool isPaused
Definition
SO3ParticleSystem.h:51
SO3::SParticleSystem::ClearParticleTemplates
static void ClearParticleTemplates()
Definition
SO3ParticleSystem.cpp:13
SO3::SParticleSystem::GetEnable
bool GetEnable()
Definition
SO3ParticleSystem.cpp:104
SO3::SParticleSystem::GetSpeed
float GetSpeed()
Definition
SO3ParticleSystem.cpp:81
SO3::SParticleSystem::GetPaused
bool GetPaused()
Definition
SO3ParticleSystem.cpp:123
SO3::SParticleSystem::SetScale
virtual void SetScale(const Ogre::Vector3 &scale)
Definition
SO3ParticleSystem.cpp:63
SO3::SParticleSystem::speedFactor
float speedFactor
Definition
SO3ParticleSystem.h:49
SO3::SParticleSystem::SetRenderingDistance
virtual void SetRenderingDistance(const float &distance)
Definition
SO3ParticleSystem.cpp:53
SO3::SParticleSystem::templateName
string templateName
Definition
SO3ParticleSystem.h:48
SO3::SParticleSystem::SetPaused
void SetPaused(const bool &pause)
Definition
SO3ParticleSystem.cpp:109
SO3::SParticleSystem::GetRenderingDistance
virtual float GetRenderingDistance()
Definition
SO3ParticleSystem.cpp:58
SO3::SParticleSystem::isEnable
bool isEnable
Definition
SO3ParticleSystem.h:50
SO3::SParticleSystem::GetOgreParticleSystem
Ogre::ParticleSystem * GetOgreParticleSystem()
Definition
SO3ParticleSystem.cpp:48
SO3::SParticleSystem::~SParticleSystem
~SParticleSystem()
Definition
SO3ParticleSystem.cpp:36
SO3::SParticleSystem::O3ParticleSystem
Ogre::ParticleSystem * O3ParticleSystem
Definition
SO3ParticleSystem.h:47
SO3::SParticleSystem::GetParticleTemplateName
std::string GetParticleTemplateName()
Definition
SO3ParticleSystem.cpp:69
SO3::SParticleSystem::SetEnable
void SetEnable(const bool &enable)
Definition
SO3ParticleSystem.cpp:86
SO3::SParticleSystem::SetSpeed
void SetSpeed(const float &speed)
Definition
SO3ParticleSystem.cpp:74
SO3::SScene
Definition
SO3Scene.h:125
SO3::SScene::GetOgreScenePointer
Ogre::SceneManager * GetOgreScenePointer()
Definition
SO3Scene.cpp:449
SO3
Definition
SO3DataScol.h:38
Generated by
1.9.8