aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcharacter/llcharacter.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcharacter/llcharacter.h
parentREADME.txt (diff)
downloadmeta-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/llcharacter.h')
-rw-r--r--linden/indra/llcharacter/llcharacter.h271
1 files changed, 271 insertions, 0 deletions
diff --git a/linden/indra/llcharacter/llcharacter.h b/linden/indra/llcharacter/llcharacter.h
new file mode 100644
index 0000000..bfe3ffa
--- /dev/null
+++ b/linden/indra/llcharacter/llcharacter.h
@@ -0,0 +1,271 @@
1/**
2 * @file llcharacter.h
3 * @brief Implementation of LLCharacter 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_LLCHARACTER_H
29#define LL_LLCHARACTER_H
30
31//-----------------------------------------------------------------------------
32// Header Files
33//-----------------------------------------------------------------------------
34#include <string>
35
36#include "lljoint.h"
37#include "llmotioncontroller.h"
38#include "llassoclist.h"
39#include "llvisualparam.h"
40#include "linked_lists.h"
41#include "string_table.h"
42#include "llmemory.h"
43
44class LLPolyMesh;
45
46class LLPauseRequestHandle : public LLThreadSafeRefCount
47{
48public:
49 LLPauseRequestHandle() {};
50};
51
52typedef LLPointer<LLPauseRequestHandle> LLAnimPauseRequest;
53
54//-----------------------------------------------------------------------------
55// class LLCharacter
56//-----------------------------------------------------------------------------
57class LLCharacter
58{
59public:
60 // Constructor
61 LLCharacter();
62
63 // Destructor
64 virtual ~LLCharacter();
65
66 //-------------------------------------------------------------------------
67 // LLCharacter Interface
68 // These functions must be implemented by subclasses.
69 //-------------------------------------------------------------------------
70
71 // get the prefix to be used to lookup motion data files
72 // from the viewer data directory
73 virtual const char *getAnimationPrefix() = 0;
74
75 // get the root joint of the character
76 virtual LLJoint *getRootJoint() = 0;
77
78 // get the specified joint
79 // default implementation does recursive search,
80 // subclasses may optimize/cache results.
81 virtual LLJoint *getJoint( const std::string &name );
82
83 // get the position of the character
84 virtual LLVector3 getCharacterPosition() = 0;
85
86 // get the rotation of the character
87 virtual LLQuaternion getCharacterRotation() = 0;
88
89 // get the velocity of the character
90 virtual LLVector3 getCharacterVelocity() = 0;
91
92 // get the angular velocity of the character
93 virtual LLVector3 getCharacterAngularVelocity() = 0;
94
95 // get the height & normal of the ground under a point
96 virtual void getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm) = 0;
97
98 // allocate an array of joints for the character skeleton
99 // this must be overloaded to support joint subclasses,
100 // and is called implicitly from buildSkeleton().
101 // Note this must handle reallocation as it will be called
102 // each time buildSkeleton() is called.
103 virtual BOOL allocateCharacterJoints( U32 num ) = 0;
104
105 // skeleton joint accessor to support joint subclasses
106 virtual LLJoint *getCharacterJoint( U32 i ) = 0;
107
108 // get the physics time dilation for the simulator
109 virtual F32 getTimeDilation() = 0;
110
111 // gets current pixel area of this character
112 virtual F32 getPixelArea() = 0;
113
114 // gets the head mesh of the character
115 virtual LLPolyMesh* getHeadMesh() = 0;
116
117 // gets the upper body mesh of the character
118 virtual LLPolyMesh* getUpperBodyMesh() = 0;
119
120 // gets global coordinates from agent local coordinates
121 virtual LLVector3d getPosGlobalFromAgent(const LLVector3 &position) = 0;
122
123 // gets agent local coordinates from global coordinates
124 virtual LLVector3 getPosAgentFromGlobal(const LLVector3d &position) = 0;
125
126 // updates all visual parameters for this character
127 virtual void updateVisualParams();
128
129 virtual void addDebugText( const char* text ) = 0;
130
131 virtual const LLUUID& getID() = 0;
132 //-------------------------------------------------------------------------
133 // End Interface
134 //-------------------------------------------------------------------------
135 // registers a motion with the character
136 // returns true if successfull
137 BOOL addMotion( const LLUUID& id, LLMotionConstructor create );
138
139 void removeMotion( const LLUUID& id );
140
141 // returns an instance of a registered motion
142 LLMotion* createMotion( const LLUUID &id );
143
144 // start a motion
145 // returns true if successful, false if an error occurred
146 virtual BOOL startMotion( const LLUUID& id, F32 start_offset = 0.f);
147
148 // stop a motion
149 virtual BOOL stopMotion( const LLUUID& id, BOOL stop_immediate = FALSE );
150
151 // is this motion active?
152 BOOL isMotionActive( const LLUUID& id );
153
154 // Event handler for motion deactivation.
155 // Called when a motion has completely stopped and has been deactivated.
156 // Subclasses may optionally override this.
157 // The default implementation does nothing.
158 virtual void requestStopMotion( LLMotion* motion );
159
160 // periodic update function, steps the motion controller
161 void updateMotion(BOOL force_update = FALSE);
162
163 LLAnimPauseRequest requestPause();
164 BOOL areAnimationsPaused() { return mMotionController.isPaused(); }
165 void setAnimTimeFactor(F32 factor) { mMotionController.setTimeFactor(factor); }
166 void setTimeStep(F32 time_step) { mMotionController.setTimeStep(time_step); }
167 // Releases all motion instances which should result in
168 // no cached references to character joint data. This is
169 // useful if a character wants to rebuild it's skeleton.
170 virtual void flushAllMotions();
171
172 // dumps information for debugging
173 virtual void dumpCharacter( LLJoint *joint = NULL );
174
175 virtual F32 getPreferredPelvisHeight() { return mPreferredPelvisHeight; }
176
177 virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset) { return LLVector3::zero; }
178
179 virtual LLJoint* findCollisionVolume(U32 volume_id) { return NULL; }
180
181 virtual S32 getCollisionVolumeID(std::string &name) { return -1; }
182
183 void setAnimationData(std::string name, void *data);
184
185 void *getAnimationData(std::string name);
186
187 void removeAnimationData(std::string name);
188
189 void addVisualParam(LLVisualParam *param);
190 void addSharedVisualParam(LLVisualParam *param);
191
192 BOOL setVisualParamWeight(LLVisualParam *which_param, F32 weight, BOOL set_by_user = FALSE );
193 BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL set_by_user = FALSE );
194 BOOL setVisualParamWeight(S32 index, F32 weight, BOOL set_by_user = FALSE );
195
196 // get visual param weight by param or name
197 F32 getVisualParamWeight(LLVisualParam *distortion);
198 F32 getVisualParamWeight(const char* param_name);
199 F32 getVisualParamWeight(S32 index);
200
201 // set all morph weights to 0
202 void clearVisualParamWeights();
203
204 // visual parameter accessors
205 LLVisualParam* getFirstVisualParam()
206 {
207 mCurIterator = mVisualParamIndexMap.begin();
208 return getNextVisualParam();
209 }
210 LLVisualParam* getNextVisualParam()
211 {
212 if (mCurIterator == mVisualParamIndexMap.end())
213 return 0;
214 return (mCurIterator++)->second;
215 }
216
217 LLVisualParam* getVisualParam(S32 id)
218 {
219 VisualParamIndexMap_t::iterator iter = mVisualParamIndexMap.find(id);
220 return (iter == mVisualParamIndexMap.end()) ? 0 : iter->second;
221 }
222 S32 getVisualParamID(LLVisualParam *id)
223 {
224 VisualParamIndexMap_t::iterator iter;
225 for (iter = mVisualParamIndexMap.begin(); iter != mVisualParamIndexMap.end(); iter++)
226 {
227 if (iter->second == id)
228 return iter->first;
229 }
230 return 0;
231 }
232 S32 getVisualParamCount() { return (S32)mVisualParamIndexMap.size(); }
233 LLVisualParam* getVisualParam(const char *name);
234
235
236 ESex getSex() { return mSex; }
237 void setSex( ESex sex ) { mSex = sex; }
238
239 U32 getAppearanceSerialNum() const { return mAppearanceSerialNum; }
240 void setAppearanceSerialNum( U32 num ) { mAppearanceSerialNum = num; }
241
242 U32 getSkeletonSerialNum() const { return mSkeletonSerialNum; }
243 void setSkeletonSerialNum( U32 num ) { mSkeletonSerialNum = num; }
244
245 static LLLinkedList< LLCharacter > sInstances;
246
247protected:
248 LLMotionController mMotionController;
249
250 LLAssocList<std::string, void *> mAnimationData;
251
252 F32 mPreferredPelvisHeight;
253 ESex mSex;
254 U32 mAppearanceSerialNum;
255 U32 mSkeletonSerialNum;
256 LLAnimPauseRequest mPauseRequest;
257
258
259private:
260 // visual parameter stuff
261 typedef std::map<S32, LLVisualParam *> VisualParamIndexMap_t;
262 VisualParamIndexMap_t mVisualParamIndexMap;
263 VisualParamIndexMap_t::iterator mCurIterator;
264 typedef std::map<char *, LLVisualParam *> VisualParamNameMap_t;
265 VisualParamNameMap_t mVisualParamNameMap;
266
267 static LLStringTable sVisualParamNames;
268};
269
270#endif // LL_LLCHARACTER_H
271