Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / animation_state.h
blobaa443b4153180a7a4ee19f920540dd09e4fc2857
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_STATE_H
20 #define CL_ANIMATION_STATE_H
22 /////////////
23 // INCLUDE //
24 /////////////
25 // Misc
26 #include "nel/misc/types_nl.h"
27 #include "nel/misc/string_mapper.h"
28 // GameShare
29 #include "game_share/gender.h"
30 // Client sheets
31 #include "client_sheets/animation_set_list_sheet.h"
32 // Client
33 #include "animation.h"
34 // std
35 #include <map>
38 ///////////
39 // CLASS //
40 ///////////
41 namespace NLGEORGES
43 class UFormElm;
47 * Documentation
49 * TAnimStateId : there is one TAnimStateId assciated with one string.
52 /**
53 * <Class description>
54 * \author Guillaume PUZIN (GUIGUI)
55 * \author Nevrax France
56 * \date 2002
58 class CAnimationState
60 friend class CAnimationSet;
62 private:
63 /// Vector of animation.
64 std::vector<CAnimation> _Animations;
66 /** Root Animations (index point to _Animations).
67 * A Root animation is an animation that is not referenced in the "Graph of Next Anim"
69 std::vector<uint> _RootAnimations;
71 // State Sheet
72 CAnimationStateSheet *_Sheet;
74 /// mark each animation of traversed state
75 void recursMarkTraverseNext(sint idAnim, std::vector<bool> &traversedAnims, bool rootCall);
77 // Build list of possible animations, according to job specialisation and race
78 void buildAnimFilter(std::vector<uint> &filteredRootAnimList, std::vector<bool> &animFilterStates, uint32 jobSpecialisation, EGSPD::CPeople::TPeople race, GSGENDER::EGender gender) const;
80 // Choose a valid animation index in state.
81 // (there are more chances for the first animation)
82 // \warning This method does not check if _Animations is empty.
83 uint chooseAnimationIndex(const std::vector<uint> &filteredRootAnimList) const;
85 /** Backward compatibility. FallBack to old animations if EnableRacialAnimation==false
86 * The fallbakc depends on the StateId (run, sit...) and on sex of player:
87 * 0 male
88 * 1 female
90 static EGSPD::CPeople::TPeople _FallBackToDefaultRace[2][CAnimationStateSheet::StaticStateCount];
91 static bool _FallBackToDefaultRaceInited;
92 static void initFallBackToDefaultRace();
93 bool isOldRaceAnimationForced(EGSPD::CPeople::TPeople race, GSGENDER::EGender gender) const;
95 public:
96 /// Constructor
97 CAnimationState();
99 void init(CAnimationStateSheet *sheet, NL3D::UAnimationSet *animationSet);
101 /// Return the ID for the State.
102 TAnimStateId state() const
104 return (TAnimStateId)_Sheet->State;
108 * Choose an animation in the list.
109 * \return TAnimId : Id of the animation.
110 * \param jobSpecialisation. 0 if none, else an index of a job specialisation of the character (eg: CraftRolemaster)
111 * \param race. unknown => all selected
112 * \param gender. Special Hack for EnableRacialAnimation==false....
114 CAnimation::TAnimId chooseAnim(uint32 jobSpecialisation, EGSPD::CPeople::TPeople race, GSGENDER::EGender gender, double angToDest=0.0, CAnimation::TAnimId currentAnimIndex=CAnimation::UnknownAnim) const;
115 /// Should the objects in hands be displayed ?
116 bool areObjectsVisible() const {return _Sheet->DisplayObjects;}
118 /// return the name of the LodCharacter animation. Only one by AnimationState.
119 std::string getLodCharacterAnimation() const
121 return _Sheet->LodCharAnim.get(_Sheet->IdLodCharacterAnimation);
124 /// return mean MeleeImpactDelay (relevant only for melee attack states)
125 float getMeleeImpactDelay() const {return _Sheet->MeleeImpactDelay;}
127 /// Return a pointer on the animation according to the animId.
128 const CAnimation *getAnimation(CAnimation::TAnimId animId) const
130 if((uint)animId >= _Animations.size())
132 nlwarning("CAnimationState:getAnimation: animId '%d' is invalid, state animation count = %d", animId,_Animations.size());
133 if( _Sheet )
135 nlinfo("CAnimationState:getAnimation: animation sheet count = %d, State = %d, display objects : %d", _Sheet->Animations.size(), _Sheet->State, _Sheet->DisplayObjects?1:0);
137 #if !FINAL_VERSION
138 nlstop;
139 #endif // !FINAL_VERSION
140 return 0;
142 return &(_Animations[animId]);
145 /** \name DEBUG
146 * Methods only here for the debug.
148 //@{
149 /// Method only Used for debug
150 void check(CAnimation::TAnimId animId) const
152 if(animId != CAnimation::UnknownAnim)
153 nlassertex(((uint)animId<_Animations.size()), ("CAnimationState:check: animId '%d' is invalid.", animId));
155 //@}
158 uint getNumAnimation() const { return (uint)_Animations.size(); }
159 CAnimation *getAnimationByIndex(uint index);
161 // Transform a string in state id
162 static TAnimStateId getAnimationStateId (const std::string &stateName)
164 return CAnimationStateSheet::getAnimationStateId(stateName);
167 // Transform a state id in string (for debug output)
168 static const std::string &getAnimationStateName (TAnimStateId id)
170 return CAnimationStateSheet::getAnimationStateName(id);
173 // static void memoryCompress() { _LodCharAnim.memoryCompress(); }
174 // static void memoryRelease() { _LodCharAnim.clear(); }
178 #endif // CL_ANIMATION_STATE_H
180 /* End of animation_state.h */