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/>.
17 #ifndef CL_ATTACHED_FX_H
18 #define CL_ATTACHED_FX_H
20 #include "fx_manager.h"
21 #include "animation_fx.h"
22 #include "game_share/entity_types.h"
23 #include "client_sheets/fx_stick_mode.h"
24 #include "nel/misc/smart_ptr.h"
25 #include "nel/misc/vector.h"
26 #include "nel/3d/animation_time.h"
30 class UParticleSystemInstance
;
35 // max number of anim a fx animation can span over.
36 const uint MAX_FX_ANIM_COUNT
= 2;
39 /** An fx linked to a character using a stick mode (replacement to former class CCharacterCL::CAnimFX)
40 * \TODO nico The template sheet is named CAnimationFX. Maybe CAttachedFXTemplate would be a better name...
41 * \author Nicolas Vizerie
42 * \author Nevrax France
45 class CAttachedFX
: public NLMISC::CRefCount
48 friend class CCharacterCL
;
49 // FX targeter (could be the caster for a ray, or for range impact...)
54 CFXStickMode StickMode
;
55 NLMISC::CVector StickOffset
;
56 NLMISC::CVector DefaultPos
; // Default pos used if slot isn't available
59 Slot
= CLFECOMMON::INVALID_SLOT
;
60 StickOffset
= NLMISC::CVector::Null
;
61 DefaultPos
= NLMISC::CVector::Null
;
64 // Description of fx to build
68 const CAnimationFX
* Sheet
;
69 const CFXStickMode
* StickMode
; // NULL to use default stick mode of the sheet
70 NLMISC::CVector StickOffset
;
71 const NLMISC::CMatrix
* StaticMatrix
; // Useful if stick mode is "StaticMatrix"
72 uint MaxNumAnimCount
; // Number of frame on which the fx can overlap when it is being shutdown
75 float DelayBeforeStart
;
81 StickOffset
= NLMISC::CVector::Null
;
84 TimeOut
= FX_MANAGER_DEFAULT_TIMEOUT
;
86 DelayBeforeStart
= 0.f
;
91 // Creation from a sheet (sheet used in buildInfo)
92 void create(CCharacterCL
&parent
,
93 const CBuildInfo
&buildInfo
,
94 const CTargeterInfo
&targeterInfo
96 // Creation from an externally created FX (sheet is still used to specify track)
97 void create(CCharacterCL
&parent
,
98 NL3D::UParticleSystemInstance instance
,
99 const CBuildInfo
&buildInfo
,
100 const CTargeterInfo
&targeterInfo
107 NL3D::UParticleSystemInstance instance,
108 const CAnimationFX *sheet,
109 const CFXStickMode *stickMode,
110 float timeOut = FX_MANAGER_DEFAULT_TIMEOUT,
111 const NLMISC::CVector &stickOffset = NLMISC::CVector::Null,
112 uint maxNumAnimCount = 0,
113 uint8 targeterSlot = CLFECOMMON::INVALID_SLOT
118 void update(CCharacterCL
&parent
, const NLMISC::CMatrix
&alignMatrix
);
119 // a smart pointer to that object
120 typedef NLMISC::CSmartPtr
<CAttachedFX
> TSmartPtr
;
122 NL3D::UParticleSystemInstance FX
;
123 const CAnimationFX
*AniFX
;
125 NL3D::TGlobalAnimationTime SpawnTime
; // used for track evaluation
126 NLMISC::CVector SpawnPos
; // spawn pos is in world in 'spawn' mode, or local for 'sticked' and 'follow' modes
127 double TimeOutDate
; // timeOut date for FXs to be removed. If the fx is in the active list, then the date is relative and is added to current date when the fx is shutdown
128 uint MaxAnimCount
; // max number of anim changes during which the fx is still visible while being shutdown (0 if no limit)
130 CFXStickMode::TStickMode StickMode
; // The stick mode for that fx. If NULL, the default stickmode of the .animation_fx sheet is used instead
131 uint8 UserBoneID
; // filled only when fx is sticked
133 CTargeterInfo TargeterInfo
;
134 uint8 TargeterUserBoneID
; // filled at setup
135 // eval pos from slot & stick mode
136 void evalTargeterStickPos(NLMISC::CVector
&dest
) const;