aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llagent.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/newview/llagent.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 '')
-rw-r--r--linden/indra/newview/llagent.h915
1 files changed, 915 insertions, 0 deletions
diff --git a/linden/indra/newview/llagent.h b/linden/indra/newview/llagent.h
new file mode 100644
index 0000000..b86ab69
--- /dev/null
+++ b/linden/indra/newview/llagent.h
@@ -0,0 +1,915 @@
1/**
2 * @file llagent.h
3 * @brief LLAgent class header file
4 *
5 * Copyright (c) 2000-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_LLAGENT_H
29#define LL_LLAGENT_H
30
31#include <set>
32
33#include "indra_constants.h"
34#include "llmath.h"
35#include "llcoordframe.h"
36#include "llevent.h"
37#include "llagentconstants.h"
38#include "llanimationstates.h"
39#include "lldbstrings.h"
40#include "llhudeffectlookat.h"
41#include "llhudeffectpointat.h"
42#include "llmemory.h"
43#include "llstring.h"
44#include "lluuid.h"
45#include "m3math.h"
46#include "m4math.h"
47#include "llquaternion.h"
48#include "lltimer.h"
49#include "v3dmath.h"
50#include "v3math.h"
51#include "v4color.h"
52#include "v4math.h"
53//#include "vmath.h"
54#include "stdenums.h"
55#include "llwearable.h"
56#include "llcharacter.h"
57#include "llinventory.h"
58#include "llviewerinventory.h"
59#include "llagentdata.h"
60
61// Ventrella
62#include "llfollowcam.h"
63// end Ventrella
64
65const U8 AGENT_STATE_TYPING = 0x04; // Typing indication
66const U8 AGENT_STATE_EDITING = 0x10; // Set when agent has objects selected
67
68const BOOL ANIMATE = TRUE;
69
70typedef enum e_camera_modes
71{
72 CAMERA_MODE_THIRD_PERSON,
73 CAMERA_MODE_MOUSELOOK,
74 CAMERA_MODE_CUSTOMIZE_AVATAR,
75 CAMERA_MODE_FOLLOW
76} ECameraMode;
77
78typedef enum e_anim_request
79{
80 ANIM_REQUEST_START,
81 ANIM_REQUEST_STOP
82} EAnimRequest;
83
84class LLChat;
85class LLVOAvatar;
86class LLViewerRegion;
87class LLMotion;
88class LLToolset;
89class LLMessageSystem;
90class LLPermissions;
91class LLHost;
92class LLFriendObserver;
93
94struct LLGroupData
95{
96 LLUUID mID;
97 LLUUID mInsigniaID;
98 U64 mPowers;
99 BOOL mAcceptNotices;
100 S32 mContribution;
101 std::string mName;
102};
103
104inline bool operator==(const LLGroupData &a, const LLGroupData &b)
105{
106 return (a.mID == b.mID);
107}
108
109// forward declarations
110
111//
112
113class LLAgent : public LLObservable
114{
115public:
116 // When the agent hasn't typed anything for this duration, it leaves the
117 // typing state (for both chat and IM).
118 static const F32 TYPING_TIMEOUT_SECS;
119
120 LLAgent();
121 ~LLAgent();
122
123 void init();
124 void cleanup();
125
126 //
127 // MANIPULATORS
128 //
129 // TODO: Put all non-const functions here.
130
131 // Called whenever the agent moves. Puts camera back in default position,
132 // deselects items, etc.
133 void resetView(BOOL reset_camera = TRUE);
134
135 // Called on camera movement, to allow the camera to be unlocked from the
136 // default position behind the avatar.
137 void unlockView();
138
139 void sendMessage(); // Send message to this agent's region.
140 void sendReliableMessage();
141
142 LLVector3d calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
143 LLVector3d calcFocusPositionTargetGlobal(); // target for this mode
144 LLVector3d getCameraPositionGlobal() const;
145 const LLVector3 &getCameraPositionAgent() const;
146 F32 calcCameraFOVZoomFactor();
147 F32 getCameraMinOffGround(); // minimum height off ground for this mode, meters
148 void endAnimationUpdateUI();
149 void setKey(const S32 direction, S32 &key); // sets key to +1 for +direction, -1 for -direction
150 void handleScrollWheel(S32 clicks); // mousewheel driven zoom
151
152 void setAvatarObject(LLVOAvatar *avatar);
153
154 // rendering state bitmask helpers
155 void startTyping();
156 void stopTyping();
157 void setRenderState(U8 newstate);
158 void clearRenderState(U8 clearstate);
159 U8 getRenderState();
160
161 // Set the home data
162 void setRegion(LLViewerRegion *regionp);
163 LLViewerRegion *getRegion() const;
164 const LLHost& getRegionHost() const;
165
166 void updateAgentPosition(const F32 dt, const F32 yaw, const S32 mouse_x, const S32 mouse_y); // call once per frame to update position, angles radians
167 void updateLookAt(const S32 mouse_x, const S32 mouse_y);
168
169
170 void updateCamera(); // call once per frame to update camera location/orientation
171 void resetCamera(); // slam camera into its default position
172 void setupSitCamera();
173 void setCameraCollidePlane(LLVector4 &plane) { mCameraCollidePlane = plane; }
174
175 void changeCameraToDefault();
176 void changeCameraToMouselook(BOOL animate = TRUE);
177 void changeCameraToThirdPerson(BOOL animate = TRUE);
178 void changeCameraToCustomizeAvatar(BOOL animate = TRUE); // trigger transition animation
179 // Ventrella
180 void changeCameraToFollow(BOOL animate = TRUE);
181 //end Ventrella
182
183 void setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
184 void setFocusOnAvatar(BOOL focus, BOOL animate);
185 void setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
186 void setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
187 void clearFocusObject();
188 void setFocusObject(LLViewerObject* object);
189 void setObjectTracking(BOOL track) { mTrackFocusObject = track; }
190// void setLookingAtAvatar(BOOL looking);
191
192 void heardChat(const LLChat& chat);
193 void lookAtLastChat();
194 LLUUID getLastChatter() { return mLastChatterID; }
195 F32 getTypingTime() { return mTypingTimer.getElapsedTimeF32(); }
196
197 void setAFK();
198 void clearAFK();
199 BOOL getAFK() const;
200
201 void setAlwaysRun() { mbAlwaysRun = TRUE; }
202 void clearAlwaysRun() { mbAlwaysRun = FALSE; }
203 BOOL getAlwaysRun() const { return mbAlwaysRun; }
204
205 void setBusy();
206 void clearBusy();
207 BOOL getBusy() const;
208
209 void setAdminOverride(BOOL b) { mAdminOverride = b; }
210 void setGodLevel(U8 god_level) { mGodLevel = god_level; }
211 void setFirstLogin(BOOL b) { mFirstLogin = b; }
212 void setGenderChosen(BOOL b) { mGenderChosen = b; }
213
214 BOOL getAdminOverride() const { return mAdminOverride; }
215 // update internal datastructures and update the server with the
216 // new contribution level. Returns true if the group id was found
217 // and contribution could be set.
218 BOOL setGroupContribution(const LLUUID& group_id, S32 contribution);
219 BOOL setGroupAcceptNotices(const LLUUID& group_id, BOOL accept_notices);
220 void setHideGroupTitle(BOOL hide) { mHideGroupTitle = hide; }
221
222 //
223 // ACCESSORS
224 //
225 // TODO: Put all read functions here, make them const
226
227 const LLUUID& getID() const { return gAgentID; }
228 const LLUUID& getSessionID() const { return gAgentSessionID; }
229
230 const LLUUID& getSecureSessionID() const { return mSecureSessionID; }
231 // Note: NEVER send this value in the clear or over any weakly
232 // encrypted channel (such as simple XOR masking). If you are unsure
233 // ask Aaron or MarkL.
234
235 BOOL isGodlike() const;
236 U8 getGodLevel() const;
237 BOOL isGroupTitleHidden() const { return mHideGroupTitle; }
238 BOOL isGroupMember() const { return !mGroupID.isNull(); } // This is only used for building titles!
239 const LLUUID &getGroupID() const { return mGroupID; }
240 ECameraMode getCameraMode() const { return mCameraMode; }
241 BOOL getFocusOnAvatar() const { return mFocusOnAvatar; }
242 LLViewerObject* getFocusObject() const { return mFocusObject; }
243 F32 getFocusObjectDist() const { return mFocusObjectDist; }
244 BOOL inPrelude();
245 BOOL canManageEstate() const;
246
247 const LLUUID& getInventoryRootID() const { return mInventoryRootID; }
248
249 void buildFullname(std::string &name) const;
250 void buildFullnameAndTitle(std::string &name) const;
251
252 // Check against all groups in the entire agent group list.
253 BOOL isInGroup(const LLUUID& group_id) const;
254 BOOL hasPowerInGroup(const LLUUID& group_id, U64 power) const;
255 // Check for power in just the active group.
256 BOOL hasPowerInActiveGroup(const U64 power) const;
257 U64 getPowerInGroup(const LLUUID& group_id) const;
258
259 // Get group information by group_id. if not in group, data is
260 // left unchanged and method returns FALSE. otherwise, values are
261 // copied and returns TRUE.
262 BOOL getGroupData(const LLUUID& group_id, LLGroupData& data) const;
263 // Get just the agent's contribution to the given group.
264 S32 getGroupContribution(const LLUUID& group_id) const;
265
266 // return TRUE if the database reported this login as the first
267 // for this particular user.
268 BOOL isFirstLogin() const { return mFirstLogin; }
269
270 // On the very first login, gender isn't chosen until the user clicks
271 // in a dialog. We don't render the avatar until they choose.
272 BOOL isGenderChosen() const { return mGenderChosen; }
273
274 // utility to build a location string
275 void buildLocationString(std::string& str);
276
277 LLQuaternion getHeadRotation();
278 LLVOAvatar *getAvatarObject() const { return mAvatarObject; }
279
280 BOOL needsRenderAvatar(); // TRUE when camera mode is such that your own avatar should draw
281 // Not const because timers can't be accessed in const-fashion.
282 BOOL needsRenderHead();
283 BOOL cameraThirdPerson() const { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
284 BOOL cameraMouselook() const { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
285 BOOL cameraCustomizeAvatar() const { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
286 BOOL cameraFollow() const { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
287
288 LLVector3 getPosAgentFromGlobal(const LLVector3d &pos_global) const;
289 LLVector3d getPosGlobalFromAgent(const LLVector3 &pos_agent) const;
290
291 // Get the data members
292 const LLVector3& getAtAxis() const { return mFrameAgent.getAtAxis(); } // direction avatar is looking, not camera
293 const LLVector3& getUpAxis() const { return mFrameAgent.getUpAxis(); } // direction avatar is looking, not camera
294 const LLVector3& getLeftAxis() const { return mFrameAgent.getLeftAxis(); } // direction avatar is looking, not camera
295
296 LLCoordFrame getFrameAgent() const { return mFrameAgent; }
297 LLVector3 getVelocity() const;
298 F32 getVelocityZ() const { return getVelocity().mV[VZ]; } // a hack
299
300 const LLVector3d &getPositionGlobal();
301 const LLVector3 &getPositionAgent();
302 const S32 getRegionsVisited() const;
303 const F64 getDistanceTraveled() const;
304
305 const LLVector3d &getFocusGlobal() const { return mFocusGlobal; }
306 const LLVector3d &getFocusTargetGlobal() const { return mFocusTargetGlobal; }
307
308 BOOL getJump() const { return mbJump; }
309 BOOL getAutoPilot() const { return mAutoPilot; }
310 LLVector3d getAutoPilotTargetGlobal() const { return mAutoPilotTargetGlobal; }
311
312 LLQuaternion getQuat() const; // returns the quat that represents the rotation
313 // of the agent in the absolute frame
314// BOOL getLookingAtAvatar() const;
315
316 void getName(LLString& name);
317
318 const LLColor4 &getEffectColor();
319 void setEffectColor(const LLColor4 &color);
320 //
321 // UTILITIES
322 //
323
324 // Set the physics data
325 void slamLookAt(const LLVector3 &look_at);
326
327 void setPositionAgent(const LLVector3 &center);
328
329 void resetAxes();
330 void resetAxes(const LLVector3 &look_at); // makes reasonable left and up
331
332 // Move the avatar's frame
333 void rotate(F32 angle, const LLVector3 &axis);
334 void rotate(F32 angle, F32 x, F32 y, F32 z);
335 void rotate(const LLMatrix3 &matrix);
336 void rotate(const LLQuaternion &quaternion);
337 void pitch(F32 angle);
338 void roll(F32 angle);
339 void yaw(F32 angle);
340 LLVector3 getReferenceUpVector();
341
342 void setThirdPersonHeadOffset(LLVector3 offset) { mThirdPersonHeadOffset = offset; }
343 // Flight management
344 BOOL getFlying() const { return mControlFlags & AGENT_CONTROL_FLY; }
345 void setFlying(BOOL fly);
346 void toggleFlying();
347
348 // Does this parcel allow you to fly?
349 BOOL canFly();
350
351 // Animation functions
352 void requestStopMotion( LLMotion* motion );
353
354 void sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
355 void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
356
357 LLVector3d calcFocusOffset(LLViewerObject *object, S32 x, S32 y);
358 BOOL calcCameraMinDistance(F32 &obj_min_distance);
359
360 void startCameraAnimation();
361 void stopCameraAnimation();
362
363 void cameraZoomIn(const F32 factor); // zoom in by fraction of current distance
364 void cameraOrbitAround(const F32 radians); // rotate camera CCW radians about build focus point
365 void cameraOrbitOver(const F32 radians); // rotate camera forward radians over build focus point
366 void cameraOrbitIn(const F32 meters); // move camera in toward build focus point
367
368 F32 getCameraZoomFraction(); // get camera zoom as fraction of minimum and maximum zoom
369 void setCameraZoomFraction(F32 fraction); // set camera zoom as fraction of minimum and maximum zoom
370
371 void cameraPanIn(const F32 meters);
372 void cameraPanLeft(const F32 meters);
373 void cameraPanUp(const F32 meters);
374
375 void updateFocusOffset();
376 void validateFocusObject();
377
378 void setUsingFollowCam( bool using_follow_cam);
379
380 F32 calcCustomizeAvatarUIOffset( const LLVector3d& camera_pos_global );
381
382 // marks current location as start, sends information to servers
383 void setStartPosition(U32 location_id);
384
385 // Movement from user input. All set the appropriate animation flags.
386 // All turn off autopilot and make sure the camera is behind the avatar.
387 // direction is either positive, zero, or negative
388 void moveAt(S32 direction);
389 void moveAtNudge(S32 direction);
390 void moveLeft(S32 direction);
391 void moveLeftNudge(S32 direction);
392 void moveUp(S32 direction);
393 void moveYaw(F32 mag);
394 void movePitch(S32 direction);
395
396 void setOrbitLeftKey(F32 mag) { mOrbitLeftKey = mag; }
397 void setOrbitRightKey(F32 mag) { mOrbitRightKey = mag; }
398 void setOrbitUpKey(F32 mag) { mOrbitUpKey = mag; }
399 void setOrbitDownKey(F32 mag) { mOrbitDownKey = mag; }
400 void setOrbitInKey(F32 mag) { mOrbitInKey = mag; }
401 void setOrbitOutKey(F32 mag) { mOrbitOutKey = mag; }
402
403 void setPanLeftKey(F32 mag) { mPanLeftKey = mag; }
404 void setPanRightKey(F32 mag) { mPanRightKey = mag; }
405 void setPanUpKey(F32 mag) { mPanUpKey = mag; }
406 void setPanDownKey(F32 mag) { mPanDownKey = mag; }
407 void setPanInKey(F32 mag) { mPanInKey = mag; }
408 void setPanOutKey(F32 mag) { mPanOutKey = mag; }
409
410 U32 getControlFlags();
411 void setControlFlags(U32 mask); // performs bitwise mControlFlags |= mask
412 void clearControlFlags(U32 mask); // performs bitwise mControlFlags &= mask
413 BOOL controlFlagsDirty() const;
414 void enableControlFlagReset();
415 void resetControlFlags();
416
417 void propagate(const F32 dt); // BUG: should roll into updateAgentPosition
418
419 void updateWanderTarget(); // drones will pick points in the world to autopilot towards
420
421 void startAutoPilotGlobal(const LLVector3d &pos_global, const std::string& behavior_name = "", const LLQuaternion *target_rotation = NULL,
422 void (*finish_callback)(BOOL, void *) = NULL, void *callback_data = NULL, F32 stop_distance = 0.f, F32 rotation_threshold = 0.03f);
423
424 void startFollowPilot(const LLUUID &leader_id);
425 void stopAutoPilot(BOOL user_cancel = FALSE);
426 void setAutoPilotGlobal(const LLVector3d &pos_global);
427 void autoPilot(F32 *delta_yaw); // autopilot walking action, angles in radians
428 void renderAutoPilotTarget();
429
430 //
431 // teportation methods
432 //
433
434 // go to a named location home
435 void teleportRequest(
436 const U64& region_handle,
437 const LLVector3& pos_local);
438
439 // teleport to a landmark
440 void teleportViaLandmark(const LLUUID& landmark_id);
441
442 // go home
443 void teleportHome() { teleportViaLandmark(LLUUID::null); }
444
445 // to an invited location
446 void teleportViaLure(const LLUUID& lure_id, BOOL godlike);
447
448 // to a global location - this will probably need to be
449 // deprecated.
450 void teleportViaLocation(const LLVector3d& pos_global);
451
452 // cancel the teleport, may or may not be allowed by server
453 void teleportCancel();
454
455 void setTargetVelocity(const LLVector3 &vel);
456 const LLVector3 &getTargetVelocity() const;
457
458
459 // Setting the ability for this avatar to proxy for another avatar.
460 //static void processAddModifyAbility(LLMessageSystem* msg, void**);
461 //static void processGrantedProxies(LLMessageSystem* msg, void**);
462 //static void processRemoveModifyAbility(LLMessageSystem* msg, void**);
463 //BOOL isProxyFor(const LLUUID& agent_id);// *FIX should be const
464
465 static void processAgentDataUpdate(LLMessageSystem *msg, void **);
466 static void processAgentGroupDataUpdate(LLMessageSystem *msg, void **);
467 static void processAgentDropGroup(LLMessageSystem *msg, void **);
468 static void processScriptControlChange(LLMessageSystem *msg, void **);
469 static void processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void **user_data);
470 //static void processControlTake(LLMessageSystem *msg, void **);
471 //static void processControlRelease(LLMessageSystem *msg, void **);
472
473 // This method checks to see if this agent can modify an object
474 // based on the permissions and the agent's proxy status.
475 BOOL isGrantedProxy(const LLPermissions& perm);
476
477 BOOL allowOperation(PermissionBit op,
478 const LLPermissions& perm,
479 U64 group_proxy_power = 0,
480 U8 god_minimum = GOD_MAINTENANCE);
481
482 friend std::ostream& operator<<(std::ostream &s, const LLAgent &sphere);
483
484 void initOriginGlobal(const LLVector3d &origin_global); // Only to be used in ONE place! - djs 08/07/02
485
486 BOOL leftButtonGrabbed() const { return ( (!cameraMouselook() && mControlsTakenCount[CONTROL_LBUTTON_DOWN_INDEX] > 0)
487 ||(cameraMouselook() && mControlsTakenCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0)
488 ||(!cameraMouselook() && mControlsTakenPassedOnCount[CONTROL_LBUTTON_DOWN_INDEX] > 0)
489 ||(cameraMouselook() && mControlsTakenPassedOnCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0)); }
490 BOOL rotateGrabbed() const { return ( (mControlsTakenCount[CONTROL_YAW_POS_INDEX] > 0)
491 ||(mControlsTakenCount[CONTROL_YAW_NEG_INDEX] > 0)); }
492 BOOL forwardGrabbed() const { return ( (mControlsTakenCount[CONTROL_AT_POS_INDEX] > 0)); }
493 BOOL backwardGrabbed() const { return ( (mControlsTakenCount[CONTROL_AT_NEG_INDEX] > 0)); }
494 BOOL upGrabbed() const { return ( (mControlsTakenCount[CONTROL_UP_POS_INDEX] > 0)); }
495 BOOL downGrabbed() const { return ( (mControlsTakenCount[CONTROL_UP_NEG_INDEX] > 0)); }
496
497 // True iff a script has taken over a control.
498 BOOL anyControlGrabbed() const;
499
500 BOOL isControlGrabbed(S32 control_index) const;
501
502 // Send message to simulator to force grabbed controls to be
503 // released, in case of a poorly written script.
504 void forceReleaseControls();
505
506 BOOL sitCameraEnabled() { return mSitCameraEnabled; }
507
508 F32 getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.magVec(); }
509
510 // look at behavior
511 BOOL setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
512 ELookAtType getLookAtType();
513
514 // point at behavior
515 BOOL setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
516 EPointAtType getPointAtType();
517
518 void setHomePosRegion( const U64& region_handle, const LLVector3& pos_region );
519 BOOL getHomePosGlobal( LLVector3d* pos_global );
520 void setCameraAnimating( BOOL b ) { mCameraAnimating = b; }
521 void setAnimationDuration( F32 seconds ) { mAnimationDuration = seconds; }
522
523 F32 getNearChatRadius() { return mNearChatRadius; }
524
525 enum ETeleportState
526 {
527 TELEPORT_NONE = 0, // No teleport in progress
528 TELEPORT_START = 1, // Transition to REQUESTED. Viewer has sent a TeleportRequest to the source simulator
529 TELEPORT_REQUESTED = 2, // Waiting for source simulator to respond
530 TELEPORT_MOVING = 3, // Viewer has received destination location from source simulator
531 TELEPORT_START_ARRIVAL = 4, // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator
532 TELEPORT_ARRIVING = 5, // Make the user wait while content "pre-caches"
533 TELEPORT_CANCELLING = 6 // used only if user clicks "cancel" button
534 };
535
536 ETeleportState getTeleportState() const { return mTeleportState; }
537 void setTeleportState( ETeleportState state );
538 const LLString& getTeleportMessage() const { return mTeleportMessage; }
539 void setTeleportMessage(const LLString& message)
540 {
541 mTeleportMessage = message;
542 }
543
544 // trigger random fidget animations
545 void fidget();
546
547 void requestEnterGodMode();
548 void requestLeaveGodMode();
549
550 void sendAgentSetAppearance();
551
552 void sendAgentDataUpdateRequest();
553
554 // Ventrella
555 LLFollowCam mFollowCam;
556 // end Ventrella
557
558 //--------------------------------------------------------------------
559 // Wearables
560 //--------------------------------------------------------------------
561 BOOL getWearablesLoaded() const { return mWearablesLoaded; }
562
563 void setWearable( LLInventoryItem* new_item, LLWearable* wearable );
564 static void onSetWearableDialog( S32 option, void* userdata );
565 void setWearableFinal( LLInventoryItem* new_item, LLWearable* new_wearable );
566 void setWearableOutfit( const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove );
567 void queryWearableCache();
568
569 BOOL isWearableModifiable(EWearableType type);
570 BOOL isWearableCopyable(EWearableType type);
571 BOOL needsReplacement(EWearableType wearableType, S32 remove);
572 U32 getWearablePermMask(EWearableType type);
573
574 LLInventoryItem* getWearableInventoryItem(EWearableType type);
575
576 LLWearable* getWearable( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mWearable : NULL; }
577 BOOL isWearingItem( const LLUUID& item_id );
578 LLWearable* getWearableFromWearableItem( const LLUUID& item_id );
579 const LLUUID& getWearableItem( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mItemID : LLUUID::null; }
580
581 static EWearableType getTEWearableType( S32 te );
582 static LLUUID getDefaultTEImageID( S32 te );
583
584 void copyWearableToInventory( EWearableType type );
585
586 void makeNewOutfit(
587 const std::string& new_folder_name,
588 const LLDynamicArray<S32>& wearables_to_include,
589 const LLDynamicArray<S32>& attachments_to_include,
590 BOOL rename_clothing);
591 void makeNewOutfitDone(S32 index);
592
593 void removeWearable( EWearableType type );
594 static void onRemoveWearableDialog( S32 option, void* userdata );
595 void removeWearableFinal( EWearableType type );
596
597 void sendAgentWearablesUpdate();
598
599 /**
600 * @brief Only public because of addWearableToAgentInventoryCallback.
601 *
602 * NOTE: Do not call this method unless you are the inventory callback.
603 * NOTE: This can suffer from race conditions when working on the
604 * same values for index.
605 * @param index The index in mWearableEntry.
606 * @param item_id The inventory item id of the new wearable to wear.
607 * @param wearable The actual wearable data.
608 */
609 void addWearabletoAgentInventoryDone(
610 S32 index,
611 const LLUUID& item_id,
612 LLWearable* wearable);
613
614 void saveWearableAs( EWearableType type, const std::string& new_name, BOOL save_in_lost_and_found );
615 void saveWearable( EWearableType type, BOOL send_update = TRUE );
616 void saveAllWearables();
617
618 void revertWearable( EWearableType type );
619 void revertAllWearables();
620
621 void setWearableName( const LLUUID& item_id, const std::string& new_name );
622 void createStandardWearables(BOOL female);
623 void createStandardWearablesDone(S32 index);
624 void createStandardWearablesAllDone();
625
626 BOOL areWearablesLoaded() { return mWearablesLoaded; }
627
628 void observeFriends();
629 void friendsChanged();
630
631 // statics
632 static void stopFidget();
633 static void processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys, void** user_data);
634 static void userRemoveWearable( void* userdata ); // userdata is EWearableType
635 static void userRemoveAllClothes( void* userdata ); // userdata is NULL
636 static void userRemoveAllClothesStep2(BOOL proceed, void* userdata ); // userdata is NULL
637 static void userRemoveAllAttachments( void* userdata); // userdata is NULL
638 static BOOL selfHasWearable( void* userdata ); // userdata is EWearableType
639
640 //debug methods
641 static void clearVisualParams(void *);
642
643protected:
644 // stuff to do for any sort of teleport. Returns true if the
645 // teleport can proceed.
646 bool teleportCore(bool is_local = false);
647
648 // helper function to prematurely age chat when agent is moving
649 void ageChat();
650
651 // internal wearable functions
652 void sendAgentWearablesRequest();
653 static void onInitialWearableAssetArrived(LLWearable* wearable, void* userdata);
654 void recoverMissingWearable(EWearableType type);
655 void recoverMissingWearableDone();
656 void addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
657 LLWearable* wearable, const LLUUID& category_id = LLUUID::null,
658 BOOL notify = TRUE);
659public:
660 // TODO: Make these private!
661 U32 mViewerPort; // Port this agent transmits on.
662 LLUUID mSecureSessionID; // secure token for this login session
663
664 F32 mDrawDistance;
665
666 // Access or "maturity" level
667 U8 mAccess; // SIM_ACCESS_MATURE or SIM_ACCESS_PG
668 U64 mGroupPowers;
669 BOOL mHideGroupTitle;
670 char mGroupTitle[DB_GROUP_TITLE_BUF_SIZE]; // honorific, like "Sir"
671 char mGroupName[DB_GROUP_NAME_BUF_SIZE];
672 LLUUID mGroupID;
673 //LLUUID mGroupInsigniaID;
674 LLUUID mInventoryRootID;
675 LLUUID mMapID;
676 F64 mMapOriginX; // Global x coord of mMapID's bottom left corner.
677 F64 mMapOriginY; // Global y coord of mMapID's bottom left corner.
678 S32 mMapWidth; // Width of map in meters
679 S32 mMapHeight; // Height of map in meters
680 std::string mMOTD; // message of the day
681
682 LLPointer<LLHUDEffectLookAt> mLookAt;
683 LLPointer<LLHUDEffectPointAt> mPointAt;
684
685 LLDynamicArray<LLGroupData> mGroups;
686
687 BOOL mInitialized;
688
689 static BOOL sDebugDisplayTarget;
690 S32 mNumPendingQueries;
691 S32* mActiveCacheQueries;
692
693 BOOL mForceMouselook;
694
695private:
696 ETeleportState mTeleportState;
697 LLString mTeleportMessage;
698
699 S32 mControlsTakenCount[TOTAL_CONTROLS];
700 S32 mControlsTakenPassedOnCount[TOTAL_CONTROLS];
701
702 LLViewerRegion *mRegionp;
703 LLVector3d mAgentOriginGlobal; // Origin of agent coords from global coords
704 mutable LLVector3d mPositionGlobal;
705
706 std::set<U64> mRegionsVisited; // stat - what distinct regions has the avatar been to?
707 F64 mDistanceTraveled; // stat - how far has the avatar moved?
708 LLVector3d mLastPositionGlobal; // Used to calculate travel distance
709
710 LLPointer<LLVOAvatar> mAvatarObject; // NULL until avatar object sent down from simulator
711
712 U8 mRenderState; // Current behavior state of agent
713 LLFrameTimer mTypingTimer;
714
715 ECameraMode mCameraMode; // target mode after transition animation is done
716 ECameraMode mLastCameraMode;
717 BOOL mViewsPushed; // keep track of whether or not we have pushed views.
718
719 BOOL mbAlwaysRun; // should the avatar run rather than walk
720 BOOL mShowAvatar; // should we render the avatar?
721 BOOL mCameraAnimating; // camera is transitioning from one mode to another
722 LLVector3d mAnimationCameraStartGlobal; // camera start position, global coords
723 LLVector3d mAnimationFocusStartGlobal; // camera focus point, global coords
724 LLFrameTimer mAnimationTimer; // seconds that transition animation has been active
725 F32 mAnimationDuration; // seconds
726 F32 mCameraFOVZoomFactor; // amount of fov zoom applied to camera when zeroing in on an object
727 F32 mCameraCurrentFOVZoomFactor; // interpolated fov zoom
728 F32 mCameraFOVDefault; // default field of view that is basis for FOV zoom effect
729 LLVector3d mCameraFocusOffset; // offset from focus point in build mode
730 LLVector3d mCameraFocusOffsetTarget; // target towards which we are lerping the camera's focus offset
731 LLVector3 mCameraOffsetDefault; // default third-person camera offset
732 LLVector4 mCameraCollidePlane; // colliding plane for camera
733 F32 mCurrentCameraDistance; // current camera offset from avatar
734 F32 mTargetCameraDistance; // target camera offset from avatar
735 F32 mCameraZoomFraction; // mousewheel driven fraction of zoom
736 LLVector3 mCameraLag; // third person camera lag
737 LLVector3 mThirdPersonHeadOffset; // head offset for third person camera position
738 LLVector3 mCameraPositionAgent; // camera position in agent coordinates
739 LLVector3 mCameraVirtualPositionAgent; // camera virtual position (target) before performing FOV zoom
740 BOOL mSitCameraEnabled; // use provided camera information when sitting?
741 LLVector3 mSitCameraPos; // root relative camera pos when sitting
742 LLVector3 mSitCameraFocus; // root relative camera target when sitting
743
744 //Ventrella
745 LLVector3 mCameraUpVector; // camera's up direction in world coordinates (determines the 'roll' of the view)
746 //End Ventrella
747
748 LLPointer<LLViewerObject> mSitCameraReferenceObject; // object to which camera is related when sitting
749
750 BOOL mFocusOnAvatar;
751 LLVector3d mFocusGlobal;
752 LLVector3d mFocusTargetGlobal;
753 LLPointer<LLViewerObject> mFocusObject;
754 F32 mFocusObjectDist;
755 LLVector3 mFocusObjectOffset;
756 F32 mFocusDotRadius; // meters
757 BOOL mTrackFocusObject;
758 F32 mUIOffset;
759
760 LLCoordFrame mFrameAgent; // Agent position and view, agent-region coordinates
761
762 BOOL mCrouching;
763 BOOL mIsBusy;
764
765 S32 mAtKey; // Either 1, 0, or -1... indicates that movement-key is pressed
766 S32 mWalkKey; // like AtKey, but causes less forward thrust
767 S32 mLeftKey;
768 S32 mUpKey;
769 F32 mYawKey;
770 S32 mPitchKey;
771
772 F32 mOrbitLeftKey;
773 F32 mOrbitRightKey;
774 F32 mOrbitUpKey;
775 F32 mOrbitDownKey;
776 F32 mOrbitInKey;
777 F32 mOrbitOutKey;
778
779 F32 mPanUpKey;
780 F32 mPanDownKey;
781 F32 mPanLeftKey;
782 F32 mPanRightKey;
783 F32 mPanInKey;
784 F32 mPanOutKey;
785
786 U32 mControlFlags; // replacement for the mFooKey's
787 BOOL mbFlagsDirty;
788 BOOL mbFlagsNeedReset; // HACK for preventing incorrect flags sent when crossing region boundaries
789
790 BOOL mbJump;
791
792 LLFrameTimer mWanderTimer;
793 LLVector3d mWanderTargetGlobal;
794
795 BOOL mAutoPilot;
796 BOOL mAutoPilotFlyOnStop;
797 LLVector3d mAutoPilotTargetGlobal;
798 F32 mAutoPilotStopDistance;
799 BOOL mAutoPilotUseRotation;
800 LLVector3 mAutoPilotTargetFacing;
801 F32 mAutoPilotTargetDist;
802 S32 mAutoPilotNoProgressFrameCount;
803 F32 mAutoPilotRotationThreshold;
804 std::string mAutoPilotBehaviorName;
805 void (*mAutoPilotFinishedCallback)(BOOL, void *);
806 void* mAutoPilotCallbackData;
807 LLUUID mLeaderID;
808
809 std::set<LLUUID> mProxyForAgents;
810
811 LLColor4 mEffectColor;
812
813 BOOL mHaveHomePosition;
814 U64 mHomeRegionHandle;
815 LLVector3 mHomePosRegion;
816 LLFrameTimer mChatTimer;
817 LLUUID mLastChatterID;
818 F32 mNearChatRadius;
819 BOOL mAdminOverride;
820
821 // See indra_constants.h for values.
822 U8 mGodLevel;
823 LLFrameTimer mFidgetTimer;
824 LLFrameTimer mFocusObjectFadeTimer;
825 std::set<LLPointer <LLViewerObject> > mFadeObjects;
826 F32 mNextFidgetTime;
827 S32 mCurrentFidget;
828 BOOL mFirstLogin;
829 BOOL mGenderChosen;
830
831 //--------------------------------------------------------------------
832 // Wearables
833 //--------------------------------------------------------------------
834 struct LLWearableEntry
835 {
836 LLWearableEntry() : mItemID( LLUUID::null ), mWearable( NULL ) {}
837
838 LLUUID mItemID; // ID of the inventory item in the agent's inventory.
839 LLWearable* mWearable;
840 };
841 LLWearableEntry mWearableEntry[ WT_COUNT ];
842 U32 mAgentWearablesUpdateSerialNum;
843 BOOL mWearablesLoaded;
844 S32 mTextureCacheQueryID;
845 U32 mAppearanceSerialNum;
846 LLAnimPauseRequest mPauseRequest;
847
848 class createStandardWearablesAllDoneCallback : public LLRefCount
849 {
850 public:
851 ~createStandardWearablesAllDoneCallback();
852 };
853 class sendAgentWearablesUpdateCallback : public LLRefCount
854 {
855 public:
856 ~sendAgentWearablesUpdateCallback();
857 };
858
859 class addWearableToAgentInventoryCallback : public LLInventoryCallback
860 {
861 public:
862 enum {
863 CALL_NONE = 0,
864 CALL_UPDATE = 1,
865 CALL_RECOVERDONE = 2,
866 CALL_CREATESTANDARDDONE = 4,
867 CALL_MAKENEWOUTFITDONE = 8
868 } EType;
869
870 /**
871 * @brief Construct a callback for dealing with the wearables.
872 *
873 * Would like to pass the agent in here, but we can't safely
874 * count on it being around later. Just use gAgent directly.
875 * @param cb callback to execute on completion (??? unused ???)
876 * @param index Index for the wearable in the agent
877 * @param wearable The wearable data.
878 * @param todo Bitmask of actions to take on completion.
879 */
880 addWearableToAgentInventoryCallback(
881 LLPointer<LLRefCount> cb,
882 S32 index,
883 LLWearable* wearable,
884 U32 todo = CALL_NONE);
885 ~addWearableToAgentInventoryCallback() {};
886 virtual void fire(const LLUUID& inv_item);
887
888 private:
889 S32 mIndex;
890 LLWearable* mWearable;
891 U32 mTodo;
892 LLPointer<LLRefCount> mCB;
893 };
894
895 //control listeners
896 class LLHideGroupTitleListener: public LLSimpleListener
897 {
898 public:
899 bool handleEvent(LLPointer<LLEvent> event, const LLSD &userdata);
900 };
901
902 class LLEffectColorListener: public LLSimpleListener
903 {
904 public:
905 bool handleEvent(LLPointer<LLEvent> event, const LLSD &userdata);
906 };
907
908 LLHideGroupTitleListener mHideGroupTitleListener;
909 LLEffectColorListener mEffectColorListener;
910 LLFriendObserver* mFriendObserver;
911};
912
913extern LLAgent gAgent;
914
915#endif