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/llmotion.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/llmotion.h')
-rw-r--r-- | linden/indra/llcharacter/llmotion.h | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/linden/indra/llcharacter/llmotion.h b/linden/indra/llcharacter/llmotion.h new file mode 100644 index 0000000..2e302cf --- /dev/null +++ b/linden/indra/llcharacter/llmotion.h | |||
@@ -0,0 +1,256 @@ | |||
1 | /** | ||
2 | * @file llmotion.h | ||
3 | * @brief Implementation of LLMotion 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_LLMOTION_H | ||
29 | #define LL_LLMOTION_H | ||
30 | |||
31 | //----------------------------------------------------------------------------- | ||
32 | // Header files | ||
33 | //----------------------------------------------------------------------------- | ||
34 | #include <string> | ||
35 | |||
36 | #include "llerror.h" | ||
37 | #include "llpose.h" | ||
38 | #include "lluuid.h" | ||
39 | |||
40 | class LLCharacter; | ||
41 | |||
42 | //----------------------------------------------------------------------------- | ||
43 | // class LLMotion | ||
44 | //----------------------------------------------------------------------------- | ||
45 | class LLMotion | ||
46 | { | ||
47 | public: | ||
48 | enum LLMotionBlendType | ||
49 | { | ||
50 | NORMAL_BLEND, | ||
51 | ADDITIVE_BLEND | ||
52 | }; | ||
53 | |||
54 | enum LLMotionInitStatus | ||
55 | { | ||
56 | STATUS_FAILURE, | ||
57 | STATUS_SUCCESS, | ||
58 | STATUS_HOLD | ||
59 | }; | ||
60 | |||
61 | // Constructor | ||
62 | LLMotion(const LLUUID &id); | ||
63 | |||
64 | // Destructor | ||
65 | virtual ~LLMotion(); | ||
66 | |||
67 | public: | ||
68 | //------------------------------------------------------------------------- | ||
69 | // functions to support MotionController and MotionRegistry | ||
70 | //------------------------------------------------------------------------- | ||
71 | |||
72 | // static constructor | ||
73 | // all subclasses must implement such a function and register it | ||
74 | static LLMotion *create(const LLUUID &id) { return NULL; } | ||
75 | |||
76 | // get the name of this instance | ||
77 | const std::string &getName() const { return mName; } | ||
78 | |||
79 | // set the name of this instance | ||
80 | void setName(const std::string &name) { mName = name; } | ||
81 | |||
82 | const LLUUID& getID() const { return mID; } | ||
83 | |||
84 | // returns the pose associated with the current state of this motion | ||
85 | virtual LLPose* getPose() { return &mPose;} | ||
86 | |||
87 | void fadeOut(); | ||
88 | |||
89 | void fadeIn(); | ||
90 | |||
91 | F32 getFadeWeight() const { return mFadeWeight; } | ||
92 | |||
93 | F32 getStopTime() const { return mStopTimestamp; } | ||
94 | |||
95 | virtual void setStopTime(F32 time) { mStopTimestamp = time; mStopped = TRUE; } | ||
96 | |||
97 | BOOL isStopped() const { return mStopped; } | ||
98 | |||
99 | void setStopped(BOOL stopped) { mStopped = stopped; } | ||
100 | |||
101 | void activate(); | ||
102 | |||
103 | void deactivate(); | ||
104 | |||
105 | BOOL isActive() { return mActive; } | ||
106 | |||
107 | |||
108 | public: | ||
109 | //------------------------------------------------------------------------- | ||
110 | // animation callbacks to be implemented by subclasses | ||
111 | //------------------------------------------------------------------------- | ||
112 | |||
113 | // motions must specify whether or not they loop | ||
114 | virtual BOOL getLoop() = 0; | ||
115 | |||
116 | // motions must report their total duration | ||
117 | virtual F32 getDuration() = 0; | ||
118 | |||
119 | // motions must report their "ease in" duration | ||
120 | virtual F32 getEaseInDuration() = 0; | ||
121 | |||
122 | // motions must report their "ease out" duration. | ||
123 | virtual F32 getEaseOutDuration() = 0; | ||
124 | |||
125 | // motions must report their priority level | ||
126 | virtual LLJoint::JointPriority getPriority() = 0; | ||
127 | |||
128 | // motions must report their blend type | ||
129 | virtual LLMotionBlendType getBlendType() = 0; | ||
130 | |||
131 | // called to determine when a motion should be activated/deactivated based on avatar pixel coverage | ||
132 | virtual F32 getMinPixelArea() = 0; | ||
133 | |||
134 | // run-time (post constructor) initialization, | ||
135 | // called after parameters have been set | ||
136 | // must return true to indicate success and be available for activation | ||
137 | virtual LLMotionInitStatus onInitialize(LLCharacter *character) = 0; | ||
138 | |||
139 | // called per time step | ||
140 | // must return TRUE while it is active, and | ||
141 | // must return FALSE when the motion is completed. | ||
142 | virtual BOOL onUpdate(F32 activeTime, U8* joint_mask) = 0; | ||
143 | |||
144 | // called when a motion is deactivated | ||
145 | virtual void onDeactivate() = 0; | ||
146 | |||
147 | // optional callback routine called when animation deactivated. | ||
148 | void setDeactivateCallback( void (*cb)(void *), void* userdata ); | ||
149 | |||
150 | protected: | ||
151 | // called when a motion is activated | ||
152 | // must return TRUE to indicate success, or else | ||
153 | // it will be deactivated | ||
154 | virtual BOOL onActivate() = 0; | ||
155 | |||
156 | void addJointState(LLJointState* jointState); | ||
157 | |||
158 | protected: | ||
159 | LLPose mPose; | ||
160 | BOOL mStopped; // motion has been stopped; | ||
161 | BOOL mActive; // motion is on active list (can be stopped or not stopped) | ||
162 | |||
163 | public: | ||
164 | //------------------------------------------------------------------------- | ||
165 | // these are set implicitly by the motion controller and | ||
166 | // may be referenced (read only) in the above handlers. | ||
167 | //------------------------------------------------------------------------- | ||
168 | std::string mName; // instance name assigned by motion controller | ||
169 | LLUUID mID; | ||
170 | |||
171 | F32 mActivationTimestamp; // time when motion was activated | ||
172 | F32 mStopTimestamp; // time when motion was told to stop | ||
173 | F32 mSendStopTimestamp; // time when simulator should be told to stop this motion | ||
174 | F32 mResidualWeight; // blend weight at beginning of stop motion phase | ||
175 | F32 mFadeWeight; // for fading in and out based on LOD | ||
176 | U8 mJointSignature[3][LL_CHARACTER_MAX_JOINTS]; // signature of which joints are animated at what priority | ||
177 | void (*mDeactivateCallback)(void* data); | ||
178 | void* mDeactivateCallbackUserData; | ||
179 | }; | ||
180 | |||
181 | |||
182 | //----------------------------------------------------------------------------- | ||
183 | // LLTestMotion | ||
184 | //----------------------------------------------------------------------------- | ||
185 | class LLTestMotion : public LLMotion | ||
186 | { | ||
187 | public: | ||
188 | LLTestMotion(const LLUUID &id) : LLMotion(id){} | ||
189 | ~LLTestMotion() {} | ||
190 | static LLMotion *create(const LLUUID& id) { return new LLTestMotion(id); } | ||
191 | BOOL getLoop() { return FALSE; } | ||
192 | F32 getDuration() { return 0.0f; } | ||
193 | F32 getEaseInDuration() { return 0.0f; } | ||
194 | F32 getEaseOutDuration() { return 0.0f; } | ||
195 | LLJoint::JointPriority getPriority() { return LLJoint::HIGH_PRIORITY; } | ||
196 | LLMotionBlendType getBlendType() { return NORMAL_BLEND; } | ||
197 | F32 getMinPixelArea() { return 0.f; } | ||
198 | |||
199 | LLMotionInitStatus onInitialize(LLCharacter*) { llinfos << "LLTestMotion::onInitialize()" << llendl; return STATUS_SUCCESS; } | ||
200 | BOOL onActivate() { llinfos << "LLTestMotion::onActivate()" << llendl; return TRUE; } | ||
201 | BOOL onUpdate(F32 time, U8* joint_mask) { llinfos << "LLTestMotion::onUpdate(" << time << ")" << llendl; return TRUE; } | ||
202 | void onDeactivate() { llinfos << "LLTestMotion::onDeactivate()" << llendl; } | ||
203 | }; | ||
204 | |||
205 | |||
206 | //----------------------------------------------------------------------------- | ||
207 | // LLNullMotion | ||
208 | //----------------------------------------------------------------------------- | ||
209 | class LLNullMotion : public LLMotion | ||
210 | { | ||
211 | public: | ||
212 | LLNullMotion(const LLUUID &id) : LLMotion(id) {} | ||
213 | ~LLNullMotion() {} | ||
214 | static LLMotion *create(const LLUUID &id) { return new LLNullMotion(id); } | ||
215 | |||
216 | // motions must specify whether or not they loop | ||
217 | /*virtual*/ BOOL getLoop() { return TRUE; } | ||
218 | |||
219 | // motions must report their total duration | ||
220 | /*virtual*/ F32 getDuration() { return 1.f; } | ||
221 | |||
222 | // motions must report their "ease in" duration | ||
223 | /*virtual*/ F32 getEaseInDuration() { return 0.f; } | ||
224 | |||
225 | // motions must report their "ease out" duration. | ||
226 | /*virtual*/ F32 getEaseOutDuration() { return 0.f; } | ||
227 | |||
228 | // motions must report their priority level | ||
229 | /*virtual*/ LLJoint::JointPriority getPriority() { return LLJoint::HIGH_PRIORITY; } | ||
230 | |||
231 | // motions must report their blend type | ||
232 | /*virtual*/ LLMotionBlendType getBlendType() { return NORMAL_BLEND; } | ||
233 | |||
234 | // called to determine when a motion should be activated/deactivated based on avatar pixel coverage | ||
235 | /*virtual*/ F32 getMinPixelArea() { return 0.f; } | ||
236 | |||
237 | // run-time (post constructor) initialization, | ||
238 | // called after parameters have been set | ||
239 | // must return true to indicate success and be available for activation | ||
240 | /*virtual*/ LLMotionInitStatus onInitialize(LLCharacter *character) { return STATUS_SUCCESS; } | ||
241 | |||
242 | // called when a motion is activated | ||
243 | // must return TRUE to indicate success, or else | ||
244 | // it will be deactivated | ||
245 | /*virtual*/ BOOL onActivate() { return TRUE; } | ||
246 | |||
247 | // called per time step | ||
248 | // must return TRUE while it is active, and | ||
249 | // must return FALSE when the motion is completed. | ||
250 | /*virtual*/ BOOL onUpdate(F32 activeTime, U8* joint_mask) { return TRUE; } | ||
251 | |||
252 | // called when a motion is deactivated | ||
253 | /*virtual*/ void onDeactivate() {} | ||
254 | }; | ||
255 | #endif // LL_LLMOTION_H | ||
256 | |||