Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / entity_fx.cpp
blob8b407b989a4a694d9ebff693a2e06c64d33dc030
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
21 #include "nel/3d/u_scene.h"
22 #include "nel/3d/u_instance_group.h"
24 #include "entity_fx.h"
25 #include "ig_client.h"
28 // map of Fx entities
29 TMapEntityFx EntityFx;
31 using namespace std;
32 using namespace NLMISC;
33 using namespace NL3D;
35 ////////////
36 // GLOBAL //
37 ////////////
39 // Hierarchical timer
40 H_AUTO_DECL ( RZ_Client_FX_Entities )
42 extern UScene *Scene;
45 * Constructor
47 CEntityFx::CEntityFx( const std::string& FxName, const std::string& InstanceName, const CVector& Position, const CQuat& Rotation )
49 _FxName = FxName;
50 _InstanceName = InstanceName;
51 _InstanceName = _InstanceName + ".ps";
52 _Position = Position;
53 _Rotation = Rotation;
54 _StatusFx = SStatusFx();
57 CEntityFx::~CEntityFx()
59 deleteInstance();
62 // startFx
63 void CEntityFx::startFx( void )
65 UInstance instance = Scene->createInstance( _InstanceName );
67 if(!instance.empty())
69 instance.setTransformMode( UTransformable::RotQuat );
70 instance.setPos( _Position );
71 instance.setRotQuat( _Rotation );
73 instance.setClusterSystem(NULL);
75 _FxInstance.cast (instance);
76 if (_FxInstance.empty())
78 deleteInstance();
83 /// isTerminated return true if fx is finish
84 bool CEntityFx::isTerminated( void )
86 if(!_FxInstance.empty())
88 if( _FxInstance.isSystemPresent() )
90 return (! _FxInstance.isValid() );
93 return false;
96 /// deleteInstance
97 void CEntityFx::deleteInstance( void)
99 if(!_FxInstance.empty())
101 if(Scene)
102 Scene->deleteInstance( _FxInstance );
103 _FxInstance = NULL;
108 // create new Fx entity
109 void newFx(const string& FxName, const string& InstanceName, const CVector& Position, const CQuat& Rotation )
111 if ( EntityFx.find( FxName ) != EntityFx.end() )
113 nlerror( "Fx %s already exist", FxName.c_str() );
115 else
117 CEntityFx *pEntityFx = new CEntityFx( FxName, InstanceName, Position, Rotation );
118 EntityFx.insert( make_pair( FxName, pEntityFx) );
122 // delete Fx entity
123 void deleteFx(const std::string& FxName)
125 TMapEntityFx::iterator it = EntityFx.find( FxName );
127 if( it != EntityFx.end() )
129 delete (*it).second;
130 EntityFx.erase( it );
134 // Start Fx entity
135 void startFx(const std::string& FxName)
137 TMapEntityFx::iterator it = EntityFx.find( FxName );
139 if( it != EntityFx.end() )
141 (*it).second->startFx();
145 // managed Fx entities
146 void manageFxEntities(void)
148 H_AUTO_USE ( RZ_Client_FX_Entities )
149 for( TMapEntityFx::iterator it = EntityFx.begin(); it != EntityFx.end(); ++it )
151 if( (*it).second->isTerminated() )
153 (*it).second->deleteInstance();