Merge branch '164-crash-on-patching-and-possibly-right-after-login' into main/gingo...
[ryzomcore.git] / ryzom / client / src / animation.h
blob04c9301bc607a1b62067398b3b2f06977d33d3f6
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 #ifndef CL_ANIMATION_H
20 #define CL_ANIMATION_H
22 /////////////
23 // INCLUDE //
24 /////////////
27 #include "game_share/magic_fx.h"
28 #include "client_sheets/animation_set_list_sheet.h"
30 #include "animation_fx.h"
33 ///////////
34 // CLASS //
35 ///////////
36 namespace NLGEORGES
38 class UFormElm;
41 namespace NL3D
43 class UTrack;
46 class CAnimationFXSet;
49 /**
50 * Class to describe an animation.
51 * \author Guillaume PUZIN (GUIGUI)
52 * \author Nevrax France
53 * \date 2002
54 * \todo GUIGUI : change the animation name to remove ".anim".
56 class CAnimation
58 public:
59 /// Type of an animation.
60 enum TAnimId
62 UnknownAnim = 0xffffffff
64 public:
65 /// Constructor
66 CAnimation();
68 // dtor
69 ~CAnimation();
71 /// Build the structure from the georges file read in sheet manager
72 void init(CAnimationSheet *sheet, NL3D::UAnimationSet *animationSet);
74 /// Return the Animation Id or UnknownAnim.
75 uint id() const {return _Animation;}
76 /// Return the Animation Id or UnknownAnim.
77 const NLSOUND::TSoundAnimId &soundId() const {return _SoundAnim;}
78 /// Must apply the Character scale Pos factor to the "pos" channel" of this animation.
79 bool applyCharacterScalePosFactor() const {return _Sheet->ApplyCharacterScalePosFactor;}
80 /// Return the fx associated with the animation.
81 std::string fx() const { return _Sheet->FxNames.get(_Sheet->IdFX); }
82 /// Is the head controlable by the code.
83 bool headControlable() const {return _Sheet->HeadControlable;}
85 /// Is the head controlable by the code.
86 bool isReverse() const {return _Sheet->Reverse;}
88 /// Is the head controlable by the code.
89 bool hideAtEndAnim() const {return _Sheet->HideAtEndAnim;}
91 double getRot() const {return _Rot;}
92 double virtualRot() const {return _Sheet->VirtualRot;}
94 // get fx set
95 CAnimationFXSet &getFXSet() { return _FXSet; }
96 const CAnimationFXSet &getFXSet() const { return _FXSet; }
98 /** Return the next animation to play or -1.
99 * only filtered anim (in animFilterStates) are used. if none, return -1
101 sint8 getNextAnim(const std::vector<bool> &animFilterStates) const;
103 static std::set<std::string> MissingAnim;
105 // static void memoryCompress() { _FxNames.memoryCompress(); }
106 // static void memoryRelease() { _FxNames.clear(); }
108 void resetSoundAnim();
109 void reloadSoundAnim();
111 // true if this animation can be played according to the character job/race
112 bool filterOk(uint32 jobSpecialisation, EGSPD::CPeople::TPeople race) const
114 if(!_Sheet)
115 return true;
116 // Common case: No job restriction and no race restriction? => always ok
117 if(_Sheet->JobRestriction==0 && _Sheet->RaceRestriction==EGSPD::CPeople::Unknown)
118 return true;
119 // if job restriction don't match
120 if(_Sheet->JobRestriction!=0 && _Sheet->JobRestriction!=jobSpecialisation)
121 return false;
122 // if race restriction don't match
123 if(_Sheet->RaceRestriction!=EGSPD::CPeople::Unknown && _Sheet->RaceRestriction!=race)
124 return false;
125 // else filter ok
126 return true;
129 // return the list of Next Anim
130 const std::vector<sint8> &getNextAnimList() const;
132 private:
133 /// Id of the sound animation.
134 NLSOUND::TSoundAnimId _SoundAnim;
136 /// Name of the sound animation, for SoundAnimManager Reload
137 std::string _SoundAnimName;
139 /// Animation Id
140 uint _Animation;
142 /// Rotation in the animation.
143 double _Rot;
145 // FX set to launch with the animation
146 CAnimationFXSet _FXSet;
149 CAnimationSheet *_Sheet;
151 private:
152 void computeAnimation(NL3D::UAnimationSet *animationSet, const std::string &animName);
156 #endif // CL_ANIMATION_H
158 /* End of animation.h */