1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
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"
29 TMapEntityFx EntityFx
;
32 using namespace NLMISC
;
40 H_AUTO_DECL ( RZ_Client_FX_Entities
)
47 CEntityFx::CEntityFx( const std::string
& FxName
, const std::string
& InstanceName
, const CVector
& Position
, const CQuat
& Rotation
)
50 _InstanceName
= InstanceName
;
51 _InstanceName
= _InstanceName
+ ".ps";
54 _StatusFx
= SStatusFx();
57 CEntityFx::~CEntityFx()
63 void CEntityFx::startFx( void )
65 UInstance instance
= Scene
->createInstance( _InstanceName
);
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())
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() );
97 void CEntityFx::deleteInstance( void)
99 if(!_FxInstance
.empty())
102 Scene
->deleteInstance( _FxInstance
);
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() );
117 CEntityFx
*pEntityFx
= new CEntityFx( FxName
, InstanceName
, Position
, Rotation
);
118 EntityFx
.insert( make_pair( FxName
, pEntityFx
) );
123 void deleteFx(const std::string
& FxName
)
125 TMapEntityFx::iterator it
= EntityFx
.find( FxName
);
127 if( it
!= EntityFx
.end() )
130 EntityFx
.erase( it
);
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();