diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcharacter/llmotioncontroller.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcharacter/llmotioncontroller.h')
-rw-r--r-- | linden/indra/llcharacter/llmotioncontroller.h | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/linden/indra/llcharacter/llmotioncontroller.h b/linden/indra/llcharacter/llmotioncontroller.h new file mode 100644 index 0000000..c9ee7c4 --- /dev/null +++ b/linden/indra/llcharacter/llmotioncontroller.h | |||
@@ -0,0 +1,226 @@ | |||
1 | /** | ||
2 | * @file llmotioncontroller.h | ||
3 | * @brief Implementation of LLMotionController class. | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLMOTIONCONTROLLER_H | ||
29 | #define LL_LLMOTIONCONTROLLER_H | ||
30 | |||
31 | //----------------------------------------------------------------------------- | ||
32 | // Header files | ||
33 | //----------------------------------------------------------------------------- | ||
34 | #include <string> | ||
35 | #include <map> | ||
36 | #include <deque> | ||
37 | |||
38 | #include "linked_lists.h" | ||
39 | #include "lluuidhashmap.h" | ||
40 | #include "llmotion.h" | ||
41 | #include "llpose.h" | ||
42 | #include "llframetimer.h" | ||
43 | #include "llstatemachine.h" | ||
44 | #include "llstring.h" | ||
45 | |||
46 | //----------------------------------------------------------------------------- | ||
47 | // Class predeclaration | ||
48 | // This is necessary because llcharacter.h includes this file. | ||
49 | //----------------------------------------------------------------------------- | ||
50 | class LLCharacter; | ||
51 | |||
52 | //----------------------------------------------------------------------------- | ||
53 | // LLMotionRegistry | ||
54 | //----------------------------------------------------------------------------- | ||
55 | typedef LLMotion*(*LLMotionConstructor)(const LLUUID &id); | ||
56 | |||
57 | class LLMotionTableEntry | ||
58 | { | ||
59 | public: | ||
60 | LLMotionTableEntry(); | ||
61 | LLMotionTableEntry(LLMotionConstructor constructor, const LLUUID& id); | ||
62 | ~LLMotionTableEntry(){}; | ||
63 | |||
64 | LLMotion* create(const LLUUID& id); | ||
65 | static BOOL uuidEq(const LLUUID &uuid, const LLMotionTableEntry &id_pair) | ||
66 | { | ||
67 | if (uuid == id_pair.mID) | ||
68 | { | ||
69 | return TRUE; | ||
70 | } | ||
71 | return FALSE; | ||
72 | } | ||
73 | |||
74 | const LLUUID& getID() { return mID; } | ||
75 | |||
76 | protected: | ||
77 | LLMotionConstructor mConstructor; | ||
78 | LLUUID mID; | ||
79 | }; | ||
80 | |||
81 | class LLMotionRegistry | ||
82 | { | ||
83 | public: | ||
84 | // Constructor | ||
85 | LLMotionRegistry(); | ||
86 | |||
87 | // Destructor | ||
88 | ~LLMotionRegistry(); | ||
89 | |||
90 | // adds motion classes to the registry | ||
91 | // returns true if successfull | ||
92 | BOOL addMotion( const LLUUID& id, LLMotionConstructor create); | ||
93 | |||
94 | // creates a new instance of a named motion | ||
95 | // returns NULL motion is not registered | ||
96 | LLMotion *createMotion( const LLUUID &id ); | ||
97 | |||
98 | // initialization of motion failed, don't try to create this motion again | ||
99 | void markBad( const LLUUID& id ); | ||
100 | |||
101 | |||
102 | protected: | ||
103 | LLUUIDHashMap<LLMotionTableEntry, 32> mMotionTable; | ||
104 | }; | ||
105 | |||
106 | //----------------------------------------------------------------------------- | ||
107 | // class LLMotionController | ||
108 | //----------------------------------------------------------------------------- | ||
109 | class LLMotionController | ||
110 | { | ||
111 | public: | ||
112 | // Constructor | ||
113 | LLMotionController(); | ||
114 | |||
115 | // Destructor | ||
116 | virtual ~LLMotionController(); | ||
117 | |||
118 | // set associated character | ||
119 | // this must be called exactly once by the containing character class. | ||
120 | // this is generally done in the Character constructor | ||
121 | void setCharacter( LLCharacter *character ); | ||
122 | |||
123 | // registers a motion with the controller | ||
124 | // (actually just forwards call to motion registry) | ||
125 | // returns true if successfull | ||
126 | BOOL addMotion( const LLUUID& id, LLMotionConstructor create ); | ||
127 | |||
128 | // creates a motion from the registry | ||
129 | LLMotion *createMotion( const LLUUID &id ); | ||
130 | |||
131 | // unregisters a motion with the controller | ||
132 | // (actually just forwards call to motion registry) | ||
133 | // returns true if successfull | ||
134 | void removeMotion( const LLUUID& id ); | ||
135 | |||
136 | // start motion | ||
137 | // begins playing the specified motion | ||
138 | // returns true if successful | ||
139 | BOOL startMotion( const LLUUID &id, F32 start_offset ); | ||
140 | |||
141 | // stop motion | ||
142 | // stops a playing motion | ||
143 | // in reality, it begins the ease out transition phase | ||
144 | // returns true if successful | ||
145 | BOOL stopMotionLocally( const LLUUID &id, BOOL stop_immediate ); | ||
146 | |||
147 | // update motions | ||
148 | // invokes the update handlers for each active motion | ||
149 | // activates sequenced motions | ||
150 | // deactivates terminated motions` | ||
151 | void updateMotion(); | ||
152 | |||
153 | // flush motions | ||
154 | // releases all motion instances | ||
155 | void flushAllMotions(); | ||
156 | |||
157 | // pause and continue all motions | ||
158 | void pause(); | ||
159 | void unpause(); | ||
160 | BOOL isPaused() { return mPaused; } | ||
161 | |||
162 | void setTimeStep(F32 step); | ||
163 | |||
164 | void setTimeFactor(F32 time_factor); | ||
165 | F32 getTimeFactor() { return mTimeFactor; } | ||
166 | |||
167 | LLMotion* getFirstActiveMotion(); | ||
168 | LLMotion* getNextActiveMotion(); | ||
169 | |||
170 | //protected: | ||
171 | BOOL isMotionActive( LLMotion *motion ); | ||
172 | BOOL isMotionLoading( LLMotion *motion ); | ||
173 | LLMotion *findMotion( const LLUUID& id ); | ||
174 | |||
175 | protected: | ||
176 | void deleteAllMotions(); | ||
177 | void addLoadedMotion(LLMotion *motion); | ||
178 | BOOL activateMotion(LLMotion *motion, F32 time); | ||
179 | BOOL deactivateMotion(LLMotion *motion); | ||
180 | void updateRegularMotions(); | ||
181 | void updateAdditiveMotions(); | ||
182 | void resetJointSignatures(); | ||
183 | void updateMotionsByType(LLMotion::LLMotionBlendType motion_type); | ||
184 | protected: | ||
185 | |||
186 | F32 mTimeFactor; | ||
187 | static LLMotionRegistry sRegistry; | ||
188 | LLPoseBlender mPoseBlender; | ||
189 | |||
190 | LLCharacter *mCharacter; | ||
191 | |||
192 | // Life cycle of an animation: | ||
193 | // | ||
194 | // Animations are instantiated and immediately put in the mAllMotions map for their entire lifetime. | ||
195 | // If the animations depend on any asset data, the appropriate data is fetched from the data server, | ||
196 | // and the animation is put on the mLoadingMotions list. | ||
197 | // Once an animations is loaded, it will be initialized and put on the mLoadedMotions deque. | ||
198 | // Any animation that is currently playing also sits in the mActiveMotions list. | ||
199 | |||
200 | std::map<LLUUID, LLMotion*> mAllMotions; | ||
201 | |||
202 | LLLinkedList<LLMotion> mLoadingMotions; | ||
203 | std::deque<LLMotion*> mLoadedMotions; | ||
204 | LLLinkedList<LLMotion> mActiveMotions; | ||
205 | |||
206 | LLFrameTimer mTimer; | ||
207 | F32 mTime; | ||
208 | F32 mTimeOffset; | ||
209 | F32 mLastTime; | ||
210 | BOOL mHasRunOnce; | ||
211 | BOOL mPaused; | ||
212 | F32 mTimeStep; | ||
213 | S32 mTimeStepCount; | ||
214 | F32 mLastInterp; | ||
215 | F32 mPauseTime; | ||
216 | |||
217 | U8 mJointSignature[2][LL_CHARACTER_MAX_JOINTS]; | ||
218 | }; | ||
219 | |||
220 | //----------------------------------------------------------------------------- | ||
221 | // Class declaractions | ||
222 | //----------------------------------------------------------------------------- | ||
223 | #include "llcharacter.h" | ||
224 | |||
225 | #endif // LL_LLMOTIONCONTROLLER_H | ||
226 | |||