Use configured resolution for login/outgame/ingame
[ryzomcore.git] / ryzom / client / src / animated_scene_object.h
blob6c9136a8125c1d656504795b91efe26294b695af
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_ANIMATED_SCENE_OBJECT_H
20 #define CL_ANIMATED_SCENE_OBJECT_H
22 #include <string>
23 #include <map>
24 #include <list>
25 #include <vector>
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/vector.h"
29 #include "nel/misc/vectord.h"
30 #include "nel/misc/quat.h"
31 #include "nel/misc/time_nl.h"
32 #include "nel/3d/u_scene.h"
33 #include "nel/3d/u_animation_set.h"
34 #include "nel/3d/u_play_list_manager.h"
35 #include "nel/3d/u_play_list.h"
36 #include "nel/3d/u_animation.h"
37 #include "nel/net/unitime.h"
38 #include "ig_client.h"
40 //#include "game_share/cst_loader.h"
42 /**
43 * CAnimatedSceneObject manage no move animated scene object
44 * \author Alain Saffray
45 * \author Nevrax France
46 * \date 2001
48 class CAnimatedSceneObject
50 public:
52 struct SAnimationStatus
54 uint32 LoopAnim : 1;
55 uint32 CodeAnim : 1;
56 uint32 RandomAnim : 1;
57 uint32 SequenceAnim : 1;
59 uint32 ApplyDisplacement : 1;
60 uint32 AnimPlayed : 1;
62 SAnimationStatus( void )
64 LoopAnim = false;
65 CodeAnim = false;
66 RandomAnim = false;
67 SequenceAnim = false;
69 AnimPlayed = false;
70 ApplyDisplacement = false;
74 /// Constructor for random anim
75 CAnimatedSceneObject( const std::string& ObjectName, const string& ClusterIG, const std::string& MeshName, const std::string& SkeletonName, const std::list < std::string >& Animations, const NLMISC::CVector& Position, const NLMISC::CQuat& Rotation, float Distance );
77 /// Constructor for moving object, it not create entity (mesh, skeleton) but build animation on pre-exist entity
78 CAnimatedSceneObject( const NLMISC::CEntityId& Id, const std::list < std::string >& Animations );
80 // Constructor for moving object, init by UTransform
81 CAnimatedSceneObject( const NLMISC::CEntityId& Id, NL3D::UTransform *Transform, const std::list < std::string >& Animations, bool displacement = true );
83 /// Destructor
84 ~CAnimatedSceneObject();
86 // Start animation
87 void InitApplyDisplacement ( void );
88 void EndApplyDisplacement ( void );
90 void StartRandomAnimation( double time, float speedFactor = 1.0f );
91 void StartNextAnimation( double time, float speedFactor = 1.0f );
92 void StartAnimation( string& nameAnim, double time, float speedFactor = 1.0f );
93 void removeOffsetAnimation ();
95 // Add an animation to sequence
96 void AddAnimationToSequence( const std::string& AnimName );
98 // Process logic and displacement and setup visual animation
99 void applyObjectAnimationTimeslice( double time );
101 // manage animation start, if they are many animation, we choose one randomly (TODO: add control to animation launched and manage some mode (loop, repeat number, sequences..)
102 void manageObjectAnimation( double Time, NLMISC::CVector userPos );
104 // update (add to end list) Animation sequence with sequence
105 void updateAnimationSequence( const std::list< std::string >& sequence );
107 // return Id of object
108 inline const NLMISC::CEntityId& getId( void ) { return _Id; }
110 // Return or Set Id of animation sequence
111 inline void idSequence( uint32 id) { _IdSequence = id; }
112 inline uint32 idSequence( void ) { return _IdSequence; }
114 inline void idAnimation( sint32 i ) { _IdAnimationPlayed = i; }
116 // return a reference on status
117 inline SAnimationStatus& getStatus( void) { return _Status; }
119 // Apply rotation with compute delta rotion since last call
120 void applyDeltaRotationAndPosition( NLMISC::CQuat& rot, NLMISC::CVector& trans );
122 // Reset list animation
123 inline void resetSequence( void ) { _SequenceAnimation.clear(); }
125 // break current animation
126 inline void breakCurrentAnimation ( void ) { _IdAnimationPlayed = -1; }
128 // Reset intial pos and rot matrix
129 void resetInitialPos( void );
131 // Process sound logic temporary
132 void processLogicTemp( double startOffset, double endOffset );
134 private:
135 NLMISC::CEntityId _Id;
136 uint32 _IdSequence;
137 std::string _ObjectName;
138 std::string _ClusterIG;
139 std::string _MeshName;
140 std::string _SkeletonName;
141 std::map< std::string, uint > _MapAnimation;
142 std::list< std::string > _SequenceAnimation;
143 NLMISC::CVectorD _Position;
144 NLMISC::CQuat _Rotation;
145 float _Distance;
146 SAnimationStatus _Status;
147 double _StartAnimationTime;
148 sint _IdAnimationPlayed;
149 NLMISC::CVector _PreviousTranslation;
150 NLMISC::CQuat _PreviousRotation;
151 double _OldAnimationTime;
152 // Only used in applydisplacement mode
153 NLMISC::CMatrix _AnimTransformation; // Only used in applydisplacement mode
156 NL3D::UPlayListManager *_PlayListManager;
157 NL3D::UAnimationSet *_AnimationSet;
158 NL3D::UPlayList *_PlayList;
159 NL3D::UInstance _Instance;
160 NL3D::USkeleton _Skeleton;
161 NL3D::UTransform _Transform;
164 typedef std::map< std::string, CAnimatedSceneObject * > TMapCAnimatedSceneObject;
165 extern TMapCAnimatedSceneObject AnimatedSceneObject;
167 void addAnimatedSceneObject( const std::string& AnimatedSceneObjectName, const string& ClusterIG, const std::string& MeshName, const std::string& SkeletonName, const std::list <std::string>& Animations, const NLMISC::CVector& Position, const NLMISC::CQuat& Rotation, float Distance );
168 void addEntityClAnimatedSceneObject( const NLMISC::CEntityId& Id, const std::list < std::string >& Animations );
169 void addUknowTypeSceneObject( const NLMISC::CEntityId& id, NL3D::UTransform *Transform, const std::list < std::string >& Animations, bool displacement = true );
170 void updateAnimationSequence( const NLMISC::CEntityId& id, const std::list< std::string >& sequence, uint32 idSequence );
171 void deleteAnimatedSceneObject( const std::string& AnimatedSceneObjectName );
172 void manageAnimatedSceneObject( double Time );
173 void sendEndSequenceMessage( const NLMISC::CEntityId& id, uint32 idSequence );
174 // Reset animation for the entity and break the current one.
175 void resetAnimatedSceneObject(const NLMISC::CEntityId& id);
177 #endif // CL_ANIMATED_SCENE_OBJECT_H
179 /* End of animated_scene_object.h */