llagent.h
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:43k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llagent.h
  3.  * @brief LLAgent class header file
  4.  *
  5.  * $LicenseInfo:firstyear=2000&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2000-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. #ifndef LL_LLAGENT_H
  33. #define LL_LLAGENT_H
  34. #include "indra_constants.h"
  35. #include "llevent.h"  // LLObservable base class
  36. #include "llagentaccess.h"
  37. #include "llagentconstants.h"
  38. #include "llagentdata.h"  // gAgentID, gAgentSessionID
  39. #include "llcharacter.h"  // LLAnimPauseRequest
  40. #include "llfollowcam.h"  // Ventrella
  41. #include "llhudeffectlookat.h"  // EPointAtType
  42. #include "llhudeffectpointat.h"  // ELookAtType
  43. #include "llpointer.h"
  44. #include "lluicolor.h"
  45. #include "llvoavatardefines.h"
  46. extern const BOOL  ANIMATE;
  47. extern const U8  AGENT_STATE_TYPING;  // Typing indication
  48. extern const U8  AGENT_STATE_EDITING; // Set when agent has objects selected
  49. class LLChat;
  50. class LLVOAvatarSelf;
  51. class LLViewerRegion;
  52. class LLMotion;
  53. class LLToolset;
  54. class LLMessageSystem;
  55. class LLPermissions;
  56. class LLHost;
  57. class LLFriendObserver;
  58. class LLPickInfo;
  59. class LLViewerObject;
  60. class LLAgentDropGroupViewerNode;
  61. //--------------------------------------------------------------------
  62. // Types
  63. //--------------------------------------------------------------------
  64. enum ECameraMode
  65. {
  66. CAMERA_MODE_THIRD_PERSON,
  67. CAMERA_MODE_MOUSELOOK,
  68. CAMERA_MODE_CUSTOMIZE_AVATAR,
  69. CAMERA_MODE_FOLLOW
  70. };
  71. /** Camera Presets for CAMERA_MODE_THIRD_PERSON */
  72. enum ECameraPreset 
  73. {
  74. /** Default preset, what the Third Person Mode actually was */
  75. CAMERA_PRESET_REAR_VIEW,
  76. /** "Looking at the Avatar from the front" */
  77. CAMERA_PRESET_FRONT_VIEW, 
  78. /** "Above and to the left, over the shoulder, pulled back a little on the zoom" */
  79. CAMERA_PRESET_GROUP_VIEW
  80. };
  81. enum EAnimRequest
  82. {
  83. ANIM_REQUEST_START,
  84. ANIM_REQUEST_STOP
  85. };
  86. struct LLGroupData
  87. {
  88. LLUUID mID;
  89. LLUUID mInsigniaID;
  90. U64 mPowers;
  91. BOOL mAcceptNotices;
  92. BOOL mListInProfile;
  93. S32 mContribution;
  94. std::string mName;
  95. };
  96. class LLAgentListener;
  97. //------------------------------------------------------------------------
  98. // LLAgent
  99. //------------------------------------------------------------------------
  100. class LLAgent : public LLOldEvents::LLObservable
  101. {
  102. LOG_CLASS(LLAgent);
  103. public:
  104. friend class LLAgentDropGroupViewerNode;
  105. /********************************************************************************
  106.  **                                                                            **
  107.  **                    INITIALIZATION
  108.  **/
  109. //--------------------------------------------------------------------
  110. // Constructors / Destructors
  111. //--------------------------------------------------------------------
  112. public:
  113. LLAgent();
  114. virtual  ~LLAgent();
  115. void init();
  116. void cleanup();
  117. void setAvatarObject(LLVOAvatarSelf *avatar);
  118. //--------------------------------------------------------------------
  119. // Login
  120. //--------------------------------------------------------------------
  121. public:
  122. void onAppFocusGained();
  123. void setFirstLogin(BOOL b)  { mFirstLogin = b; }
  124. // Return TRUE if the database reported this login as the first for this particular user.
  125. BOOL  isFirstLogin() const  { return mFirstLogin; }
  126. public:
  127. BOOL mInitialized;
  128. BOOL mFirstLogin;
  129. std::string mMOTD;  // Message of the day
  130. private:
  131. boost::shared_ptr<LLAgentListener> mListener;
  132. //--------------------------------------------------------------------
  133. // Session
  134. //--------------------------------------------------------------------
  135. public:
  136. const LLUUID& getID() const { return gAgentID; }
  137. const LLUUID& getSessionID() const { return gAgentSessionID; }
  138. // Note: NEVER send this value in the clear or over any weakly
  139. // encrypted channel (such as simple XOR masking).  If you are unsure
  140. // ask Aaron or MarkL.
  141. const LLUUID& getSecureSessionID() const { return mSecureSessionID; }
  142. public:
  143. LLUUID mSecureSessionID;  // Secure token for this login session
  144. /**                    Initialization
  145.  **                                                                            **
  146.  *******************************************************************************/
  147. /********************************************************************************
  148.  **                                                                            **
  149.  **                    IDENTITY
  150.  **/
  151. //--------------------------------------------------------------------
  152. // Name
  153. //--------------------------------------------------------------------
  154. public:
  155. //*TODO remove, is not used as of August 20, 2009
  156. void buildFullnameAndTitle(std::string &name) const;
  157. //--------------------------------------------------------------------
  158. // Gender
  159. //--------------------------------------------------------------------
  160. public:
  161. // On the very first login, gender isn't chosen until the user clicks
  162. // in a dialog.  We don't render the avatar until they choose.
  163. BOOL  isGenderChosen() const  { return mGenderChosen; }
  164. void setGenderChosen(BOOL b) { mGenderChosen = b; }
  165. private:
  166. BOOL mGenderChosen;
  167. /**                    Identity
  168.  **                                                                            **
  169.  *******************************************************************************/
  170. /********************************************************************************
  171.  **                                                                            **
  172.  **                    GENERAL ACCESSORS
  173.  **/
  174. public:
  175.   LLVOAvatarSelf* getAvatarObject() const { return mAvatarObject; }
  176. private:
  177. LLPointer<LLVOAvatarSelf> mAvatarObject;  // NULL until avatar object sent down from simulator
  178. /**                    General Accessors
  179.  **                                                                            **
  180.  *******************************************************************************/
  181. /********************************************************************************
  182.  **                                                                            **
  183.  **                    POSITION
  184.  **/
  185.    //--------------------------------------------------------------------
  186.   // Position
  187. //--------------------------------------------------------------------
  188. public:
  189. LLVector3 getPosAgentFromGlobal(const LLVector3d &pos_global) const;
  190. LLVector3d getPosGlobalFromAgent(const LLVector3 &pos_agent) const;
  191. const LLVector3d &getPositionGlobal() const;
  192. const LLVector3 &getPositionAgent();
  193. // Call once per frame to update position, angles (radians).
  194. void updateAgentPosition(const F32 dt, const F32 yaw, const S32 mouse_x, const S32 mouse_y);
  195. void setPositionAgent(const LLVector3 &center);
  196. protected:
  197. void propagate(const F32 dt); // ! BUG ! Should roll into updateAgentPosition
  198. private:
  199. mutable LLVector3d mPositionGlobal;
  200.    //--------------------------------------------------------------------
  201.   // Velocity
  202. //--------------------------------------------------------------------
  203. public:
  204. LLVector3 getVelocity() const;
  205. F32 getVelocityZ() const  { return getVelocity().mV[VZ]; } // ! HACK !
  206.    //--------------------------------------------------------------------
  207. // Coordinate System
  208. //--------------------------------------------------------------------
  209. public:
  210. LLCoordFrame getFrameAgent() const { return mFrameAgent; }
  211. void  initOriginGlobal(const LLVector3d &origin_global); // Only to be used in ONE place
  212. void resetAxes();
  213. void resetAxes(const LLVector3 &look_at); // Makes reasonable left and up
  214. // The following three get*Axis functions return direction avatar is looking, not camera.
  215. const LLVector3& getAtAxis() const { return mFrameAgent.getAtAxis(); }
  216. const LLVector3& getUpAxis() const { return mFrameAgent.getUpAxis(); }
  217. const LLVector3& getLeftAxis() const { return mFrameAgent.getLeftAxis(); }
  218. LLQuaternion getQuat() const;  // Returns the quat that represents the rotation of the agent in the absolute frame
  219. private:
  220. LLVector3d mAgentOriginGlobal; // Origin of agent coords from global coords
  221. LLCoordFrame mFrameAgent;  // Agent position and view, agent-region coordinates
  222. //--------------------------------------------------------------------
  223. // Home
  224. //--------------------------------------------------------------------
  225. public:
  226. void setStartPosition(U32 location_id); // Marks current location as start, sends information to servers
  227. void setHomePosRegion(const U64& region_handle, const LLVector3& pos_region);
  228. BOOL getHomePosGlobal(LLVector3d* pos_global);
  229. private:
  230. BOOL  mHaveHomePosition;
  231. U64 mHomeRegionHandle;
  232. LLVector3 mHomePosRegion;
  233. //--------------------------------------------------------------------
  234. // Region
  235. //--------------------------------------------------------------------
  236. public:
  237. void setRegion(LLViewerRegion *regionp);
  238. LLViewerRegion *getRegion() const;
  239. LLHost getRegionHost() const;
  240. BOOL inPrelude();
  241. private:
  242. LLViewerRegion *mRegionp;
  243. //--------------------------------------------------------------------
  244. // History
  245. //--------------------------------------------------------------------
  246. public:
  247. S32 getRegionsVisited() const;
  248. F64 getDistanceTraveled() const;
  249. private:
  250. std::set<U64> mRegionsVisited; // Stat - what distinct regions has the avatar been to?
  251. F64 mDistanceTraveled; // Stat - how far has the avatar moved?
  252. LLVector3d mLastPositionGlobal; // Used to calculate travel distance
  253. /**                    Position
  254.  **                                                                            **
  255.  *******************************************************************************/
  256. /********************************************************************************
  257.  **                                                                            **
  258.  **                    ACTIONS
  259.  **/
  260. //--------------------------------------------------------------------
  261. // Fidget
  262. //--------------------------------------------------------------------
  263. // Trigger random fidget animations
  264. public:
  265. void fidget();
  266. static void stopFidget();
  267. private:
  268. LLFrameTimer mFidgetTimer;
  269. LLFrameTimer mFocusObjectFadeTimer;
  270. F32 mNextFidgetTime;
  271. S32 mCurrentFidget;
  272. //--------------------------------------------------------------------
  273. // Fly
  274. //--------------------------------------------------------------------
  275. public:
  276. BOOL getFlying() const;
  277. void setFlying(BOOL fly);
  278. static void toggleFlying();
  279. static bool enableFlying();
  280. BOOL canFly();  // Does this parcel allow you to fly?
  281. //--------------------------------------------------------------------
  282. // Chat
  283. //--------------------------------------------------------------------
  284. public:
  285. void heardChat(const LLUUID& id);
  286. void lookAtLastChat();
  287. F32 getTypingTime()  { return mTypingTimer.getElapsedTimeF32(); }
  288. LLUUID getLastChatter() const  { return mLastChatterID; }
  289. F32 getNearChatRadius()  { return mNearChatRadius; }
  290. protected:
  291. void  ageChat();  // Helper function to prematurely age chat when agent is moving
  292. private:
  293. LLFrameTimer mChatTimer;
  294. LLUUID mLastChatterID;
  295. F32 mNearChatRadius;
  296. //--------------------------------------------------------------------
  297. // Typing
  298. //--------------------------------------------------------------------
  299. public:
  300. void startTyping();
  301. void stopTyping();
  302. public:
  303. // When the agent hasn't typed anything for this duration, it leaves the 
  304. // typing state (for both chat and IM).
  305. static const F32 TYPING_TIMEOUT_SECS;
  306. private:
  307. LLFrameTimer mTypingTimer;
  308. //--------------------------------------------------------------------
  309. // AFK
  310. //--------------------------------------------------------------------
  311. public:
  312. void setAFK();
  313. void clearAFK();
  314. BOOL getAFK() const;
  315. //--------------------------------------------------------------------
  316. // Run
  317. //--------------------------------------------------------------------
  318. public:
  319. enum EDoubleTapRunMode
  320. {
  321. DOUBLETAP_NONE,
  322. DOUBLETAP_FORWARD,
  323. DOUBLETAP_BACKWARD,
  324. DOUBLETAP_SLIDELEFT,
  325. DOUBLETAP_SLIDERIGHT
  326. };
  327. void setAlwaysRun()  { mbAlwaysRun = true; }
  328. void clearAlwaysRun()  { mbAlwaysRun = false; }
  329. void setRunning()  { mbRunning = true; }
  330. void clearRunning()  { mbRunning = false; }
  331. void  sendWalkRun(bool running);
  332. bool getAlwaysRun() const  { return mbAlwaysRun; }
  333. bool getRunning() const  { return mbRunning; }
  334. public:
  335. LLFrameTimer  mDoubleTapRunTimer;
  336. EDoubleTapRunMode mDoubleTapRunMode;
  337. private:
  338. bool  mbAlwaysRun;  // Should the avatar run by default rather than walk?
  339. bool  mbRunning; // Is the avatar trying to run right now?
  340. //--------------------------------------------------------------------
  341. // Sit and stand
  342. //--------------------------------------------------------------------
  343. public:
  344. void standUp();
  345. //--------------------------------------------------------------------
  346. // Busy
  347. //--------------------------------------------------------------------
  348. public:
  349. void setBusy();
  350. void clearBusy();
  351. BOOL getBusy() const;
  352. private:
  353. BOOL mIsBusy;
  354. //--------------------------------------------------------------------
  355. // Jump
  356. //--------------------------------------------------------------------
  357. public:
  358. BOOL getJump() const { return mbJump; }
  359. private:
  360. BOOL  mbJump;
  361. //--------------------------------------------------------------------
  362. // Grab
  363. //--------------------------------------------------------------------
  364. public:
  365. BOOL  leftButtonGrabbed() const;
  366. BOOL  rotateGrabbed() const;
  367. BOOL  forwardGrabbed() const;
  368. BOOL  backwardGrabbed() const;
  369. BOOL  upGrabbed() const;
  370. BOOL  downGrabbed() const;
  371. //--------------------------------------------------------------------
  372. // Controls
  373. //--------------------------------------------------------------------
  374. public:
  375. U32  getControlFlags(); 
  376. void  setControlFlags(U32 mask);  // Performs bitwise mControlFlags |= mask
  377. void  clearControlFlags(U32 mask);  // Performs bitwise mControlFlags &= ~mask
  378. BOOL controlFlagsDirty() const;
  379. void enableControlFlagReset();
  380. void  resetControlFlags();
  381. BOOL anyControlGrabbed() const;  // True iff a script has taken over a control
  382. BOOL isControlGrabbed(S32 control_index) const;
  383. // Send message to simulator to force grabbed controls to be
  384. // released, in case of a poorly written script.
  385. void forceReleaseControls();
  386. private:
  387. S32 mControlsTakenCount[TOTAL_CONTROLS];
  388. S32 mControlsTakenPassedOnCount[TOTAL_CONTROLS];
  389. U32 mControlFlags; // Replacement for the mFooKey's
  390. BOOL  mbFlagsDirty;
  391. BOOL  mbFlagsNeedReset; // ! HACK ! For preventing incorrect flags sent when crossing region boundaries
  392. //--------------------------------------------------------------------
  393. // Animations
  394. //--------------------------------------------------------------------
  395. public:
  396. void            stopCurrentAnimations();
  397. void requestStopMotion(LLMotion* motion);
  398. void onAnimStop(const LLUUID& id);
  399. void sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
  400. void sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
  401. void endAnimationUpdateUI();
  402. private:
  403. LLFrameTimer mAnimationTimer;  // Seconds that transition animation has been active
  404. F32 mAnimationDuration; // In seconds
  405. BOOL            mCustomAnim;  // Current animation is ANIM_AGENT_CUSTOMIZE ?
  406. LLAnimPauseRequest mPauseRequest;
  407. BOOL mViewsPushed;  // Keep track of whether or not we have pushed views
  408. /**                    Animation
  409.  **                                                                            **
  410.  *******************************************************************************/
  411. /********************************************************************************
  412.  **                                                                            **
  413.  **                    MOVEMENT
  414.  **/
  415. //--------------------------------------------------------------------
  416. // Keys
  417. //--------------------------------------------------------------------
  418. public:
  419. void setKey(const S32 direction, S32 &key); // Sets key to +1 for +direction, -1 for -direction
  420. private:
  421. S32  mAtKey; // Either 1, 0, or -1. Indicates that movement key is pressed
  422. S32 mWalkKey;  // Like AtKey, but causes less forward thrust
  423. S32  mLeftKey;
  424. S32 mUpKey;
  425. F32 mYawKey;
  426. F32 mPitchKey;
  427. //--------------------------------------------------------------------
  428. // Movement from user input
  429. //--------------------------------------------------------------------
  430. // All set the appropriate animation flags.
  431. // All turn off autopilot and make sure the camera is behind the avatar.
  432. // Direction is either positive, zero, or negative
  433. public:
  434. void moveAt(S32 direction, bool reset_view = true);
  435. void moveAtNudge(S32 direction);
  436. void moveLeft(S32 direction);
  437. void moveLeftNudge(S32 direction);
  438. void moveUp(S32 direction);
  439. void moveYaw(F32 mag, bool reset_view = true);
  440. void movePitch(F32 mag);
  441. //--------------------------------------------------------------------
  442. // Orbit
  443. //--------------------------------------------------------------------
  444. public:
  445. void setOrbitLeftKey(F32 mag) { mOrbitLeftKey = mag; }
  446. void setOrbitRightKey(F32 mag) { mOrbitRightKey = mag; }
  447. void setOrbitUpKey(F32 mag) { mOrbitUpKey = mag; }
  448. void setOrbitDownKey(F32 mag) { mOrbitDownKey = mag; }
  449. void setOrbitInKey(F32 mag) { mOrbitInKey = mag; }
  450. void setOrbitOutKey(F32 mag) { mOrbitOutKey = mag; }
  451. private:
  452. F32 mOrbitLeftKey;
  453. F32 mOrbitRightKey;
  454. F32 mOrbitUpKey;
  455. F32 mOrbitDownKey;
  456. F32 mOrbitInKey;
  457. F32 mOrbitOutKey;
  458. //--------------------------------------------------------------------
  459. // Pan
  460. //--------------------------------------------------------------------
  461. public:
  462. void setPanLeftKey(F32 mag) { mPanLeftKey = mag; }
  463. void setPanRightKey(F32 mag) { mPanRightKey = mag; }
  464. void setPanUpKey(F32 mag) { mPanUpKey = mag; }
  465. void setPanDownKey(F32 mag) { mPanDownKey = mag; }
  466. void setPanInKey(F32 mag) { mPanInKey = mag; }
  467. void setPanOutKey(F32 mag) { mPanOutKey = mag; }
  468. private:
  469. F32 mPanUpKey;
  470. F32 mPanDownKey;
  471. F32 mPanLeftKey;
  472. F32 mPanRightKey;
  473. F32 mPanInKey;
  474. F32 mPanOutKey;
  475. //--------------------------------------------------------------------
  476.   // Move the avatar's frame
  477. //--------------------------------------------------------------------
  478. public:
  479. void rotate(F32 angle, const LLVector3 &axis);
  480. void rotate(F32 angle, F32 x, F32 y, F32 z);
  481. void rotate(const LLMatrix3 &matrix);
  482. void rotate(const LLQuaternion &quaternion);
  483. void pitch(F32 angle);
  484. void roll(F32 angle);
  485. void yaw(F32 angle);
  486. LLVector3 getReferenceUpVector();
  487.     F32             clampPitchToLimits(F32 angle);
  488. //--------------------------------------------------------------------
  489. // Autopilot
  490. //--------------------------------------------------------------------
  491. public:
  492. BOOL getAutoPilot() const { return mAutoPilot; }
  493. LLVector3d getAutoPilotTargetGlobal() const  { return mAutoPilotTargetGlobal; }
  494. void startAutoPilotGlobal(const LLVector3d &pos_global, 
  495.  const std::string& behavior_name = std::string(), 
  496.  const LLQuaternion *target_rotation = NULL, 
  497.  void (*finish_callback)(BOOL, void *) = NULL, void *callback_data = NULL, 
  498.  F32 stop_distance = 0.f, F32 rotation_threshold = 0.03f);
  499. void  startFollowPilot(const LLUUID &leader_id);
  500. void stopAutoPilot(BOOL user_cancel = FALSE);
  501. void  setAutoPilotGlobal(const LLVector3d &pos_global);
  502. void autoPilot(F32 *delta_yaw);  // Autopilot walking action, angles in radians
  503. void renderAutoPilotTarget();
  504. private:
  505. BOOL mAutoPilot;
  506. BOOL mAutoPilotFlyOnStop;
  507. LLVector3d mAutoPilotTargetGlobal;
  508. F32 mAutoPilotStopDistance;
  509. BOOL mAutoPilotUseRotation;
  510. LLVector3 mAutoPilotTargetFacing;
  511. F32 mAutoPilotTargetDist;
  512. S32 mAutoPilotNoProgressFrameCount;
  513. F32 mAutoPilotRotationThreshold;
  514. std::string mAutoPilotBehaviorName;
  515. void (*mAutoPilotFinishedCallback)(BOOL, void *);
  516. void* mAutoPilotCallbackData;
  517. LLUUID mLeaderID;
  518. /**                    Movement
  519.  **                                                                            **
  520.  *******************************************************************************/
  521. /********************************************************************************
  522.  **                                                                            **
  523.  **                    TELEPORT
  524.  **/
  525. public:
  526. enum ETeleportState
  527. {
  528. TELEPORT_NONE = 0, // No teleport in progress
  529. TELEPORT_START = 1, // Transition to REQUESTED.  Viewer has sent a TeleportRequest to the source simulator
  530. TELEPORT_REQUESTED = 2, // Waiting for source simulator to respond
  531. TELEPORT_MOVING = 3, // Viewer has received destination location from source simulator
  532. TELEPORT_START_ARRIVAL = 4, // Transition to ARRIVING.  Viewer has received avatar update, etc., from destination simulator
  533. TELEPORT_ARRIVING = 5 // Make the user wait while content "pre-caches"
  534. };
  535. public:
  536. static void  parseTeleportMessages(const std::string& xml_filename);
  537. const std::string getTeleportSourceSLURL() const { return mTeleportSourceSLURL; }
  538. public:
  539. // ! TODO ! Define ERROR and PROGRESS enums here instead of exposing the mappings.
  540. static std::map<std::string, std::string> sTeleportErrorMessages;
  541. static std::map<std::string, std::string> sTeleportProgressMessages;
  542. private:
  543. std::string mTeleportSourceSLURL;  // SLURL where last TP began
  544. //--------------------------------------------------------------------
  545. // Teleport Actions
  546. //--------------------------------------------------------------------
  547. public:
  548. void  teleportRequest(const U64& region_handle,
  549. const LLVector3& pos_local); // Go to a named location home
  550. void  teleportViaLandmark(const LLUUID& landmark_id); // Teleport to a landmark
  551. void  teleportHome() { teleportViaLandmark(LLUUID::null); } // Go home
  552. void  teleportViaLure(const LLUUID& lure_id, BOOL godlike); // To an invited location
  553. void  teleportViaLocation(const LLVector3d& pos_global); // To a global location - this will probably need to be deprecated
  554. void  teleportCancel(); // May or may not be allowed by server
  555. protected:
  556. bool  teleportCore(bool is_local = false);  // Stuff for all teleports; returns true if the teleport can proceed
  557. //--------------------------------------------------------------------
  558. // Teleport State
  559. //--------------------------------------------------------------------
  560. public:
  561. ETeleportState getTeleportState() const  { return mTeleportState; }
  562. void setTeleportState(ETeleportState state);
  563. private:
  564. ETeleportState mTeleportState;
  565. //--------------------------------------------------------------------
  566. // Teleport Message
  567. //--------------------------------------------------------------------
  568. public:
  569. const std::string& getTeleportMessage() const  { return mTeleportMessage; }
  570. void  setTeleportMessage(const std::string& message)  { mTeleportMessage = message; }
  571. private:
  572. std::string mTeleportMessage;
  573. /**                    Teleport
  574.  **                                                                            **
  575.  *******************************************************************************/
  576. /********************************************************************************
  577.  **                                                                            **
  578.  **                    CAMERA
  579.  **/
  580. //--------------------------------------------------------------------
  581. // Mode
  582. //--------------------------------------------------------------------
  583. public:
  584. void changeCameraToDefault();
  585. void changeCameraToMouselook(BOOL animate = TRUE);
  586. void changeCameraToThirdPerson(BOOL animate = TRUE);
  587. void changeCameraToCustomizeAvatar(BOOL avatar_animate = TRUE, BOOL camera_animate = TRUE); // Trigger transition animation
  588. void changeCameraToFollow(BOOL animate = TRUE);  // Ventrella
  589. BOOL cameraThirdPerson() const { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
  590. BOOL cameraMouselook() const { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
  591. BOOL cameraCustomizeAvatar() const { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
  592. BOOL cameraFollow() const { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
  593. ECameraMode getCameraMode() const  { return mCameraMode; }
  594. void updateCamera(); // Call once per frame to update camera location/orientation
  595. void resetCamera();  // Slam camera into its default position
  596. private:
  597. ECameraMode mCameraMode; // Target mode after transition animation is done
  598. ECameraMode mLastCameraMode;
  599. //--------------------------------------------------------------------
  600. // Preset
  601. //--------------------------------------------------------------------
  602. public:
  603. void switchCameraPreset(ECameraPreset preset);
  604. private:
  605. /** Determines default camera offset depending on the current camera preset */
  606. LLVector3 getCameraOffsetInitial();
  607. /** Camera preset in Third Person Mode */
  608. ECameraPreset mCameraPreset; 
  609. /** Initial camera offsets */
  610. std::map<ECameraPreset, LLVector3> mCameraOffsetInitial;
  611. /** Initial focus offsets */
  612. std::map<ECameraPreset, LLVector3d> mFocusOffsetInitial;
  613. //--------------------------------------------------------------------
  614. // Position
  615. //--------------------------------------------------------------------
  616. public:
  617. LLVector3d getCameraPositionGlobal() const;
  618. const LLVector3 &getCameraPositionAgent() const;
  619. LLVector3d calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
  620. F32 getCameraMinOffGround();  // Minimum height off ground for this mode, meters
  621. void setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; }
  622. BOOL calcCameraMinDistance(F32 &obj_min_distance);
  623. F32 calcCustomizeAvatarUIOffset(const LLVector3d& camera_pos_global);
  624. F32 getCurrentCameraBuildOffset()  { return (F32)mCameraFocusOffset.length(); }
  625. private:
  626. F32 mCurrentCameraDistance;   // Current camera offset from avatar
  627. F32 mTargetCameraDistance; // Target camera offset from avatar
  628. F32 mCameraFOVZoomFactor; // Amount of fov zoom applied to camera when zeroing in on an object
  629. F32 mCameraCurrentFOVZoomFactor; // Interpolated fov zoom
  630. F32 mCameraFOVDefault; // Default field of view that is basis for FOV zoom effect
  631. LLVector4 mCameraCollidePlane; // Colliding plane for camera
  632. F32 mCameraZoomFraction; // Mousewheel driven fraction of zoom
  633. LLVector3 mCameraPositionAgent; // Camera position in agent coordinates
  634. LLVector3 mCameraVirtualPositionAgent; // Camera virtual position (target) before performing FOV zoom
  635. LLVector3d      mCameraSmoothingLastPositionGlobal;    
  636. LLVector3d      mCameraSmoothingLastPositionAgent;
  637. BOOL            mCameraSmoothingStop;
  638. LLVector3 mCameraLag; // Third person camera lag
  639. LLVector3 mCameraUpVector; // Camera's up direction in world coordinates (determines the 'roll' of the view)
  640. //--------------------------------------------------------------------
  641. // Follow
  642. //--------------------------------------------------------------------
  643. public:
  644. void setUsingFollowCam(bool using_follow_cam);
  645. private:
  646. LLFollowCam  mFollowCam;  // Ventrella
  647. //--------------------------------------------------------------------
  648. // Sit
  649. //--------------------------------------------------------------------
  650. public:
  651. void setupSitCamera();
  652. BOOL sitCameraEnabled()  { return mSitCameraEnabled; }
  653. void setSitCamera(const LLUUID &object_id, 
  654.  const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
  655. private:
  656. LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting
  657. BOOL mSitCameraEnabled; // Use provided camera information when sitting?
  658. LLVector3 mSitCameraPos; // Root relative camera pos when sitting
  659. LLVector3 mSitCameraFocus; // Root relative camera target when sitting
  660. //--------------------------------------------------------------------
  661. // Animation
  662. //--------------------------------------------------------------------
  663. public:
  664. void setCameraAnimating(BOOL b) { mCameraAnimating = b; }
  665. BOOL getCameraAnimating() { return mCameraAnimating; }
  666. void setAnimationDuration(F32 seconds)  { mAnimationDuration = seconds; }
  667. void startCameraAnimation();
  668. void stopCameraAnimation();
  669. private:
  670. BOOL mCameraAnimating; // Camera is transitioning from one mode to another
  671. LLVector3d mAnimationCameraStartGlobal; // Camera start position, global coords
  672. LLVector3d mAnimationFocusStartGlobal; // Camera focus point, global coords
  673. //--------------------------------------------------------------------
  674. // Focus
  675. //--------------------------------------------------------------------
  676. public:
  677. LLVector3d calcFocusPositionTargetGlobal();
  678. LLVector3 calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y);
  679. BOOL getFocusOnAvatar() const { return mFocusOnAvatar; }
  680. LLPointer<LLViewerObject>& getFocusObject()  { return mFocusObject; }
  681. F32 getFocusObjectDist() const { return mFocusObjectDist; }
  682. void updateFocusOffset();
  683. void validateFocusObject();
  684. void setFocusGlobal(const LLPickInfo& pick);
  685. void setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
  686. void setFocusOnAvatar(BOOL focus, BOOL animate);
  687. void setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
  688. void clearFocusObject();
  689. void setFocusObject(LLViewerObject* object);
  690. void setObjectTracking(BOOL track)  { mTrackFocusObject = track; }
  691. const LLVector3d &getFocusGlobal() const { return mFocusGlobal; }
  692. const LLVector3d &getFocusTargetGlobal() const { return mFocusTargetGlobal; }
  693. private:
  694. LLVector3d mCameraFocusOffset; // Offset from focus point in build mode
  695. LLVector3d mCameraFocusOffsetTarget; // Target towards which we are lerping the camera's focus offset
  696. BOOL mFocusOnAvatar;
  697. LLVector3d mFocusGlobal;
  698. LLVector3d mFocusTargetGlobal;
  699. LLPointer<LLViewerObject> mFocusObject;
  700. F32 mFocusObjectDist;
  701. LLVector3 mFocusObjectOffset;
  702. F32 mFocusDotRadius;  // Meters
  703. BOOL mTrackFocusObject;
  704. F32 mUIOffset;
  705. //--------------------------------------------------------------------
  706. // Lookat / Pointat
  707. //--------------------------------------------------------------------
  708. public:
  709. void updateLookAt(const S32 mouse_x, const S32 mouse_y);
  710. BOOL setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
  711. ELookAtType getLookAtType();
  712. void  slamLookAt(const LLVector3 &look_at); // Set the physics data
  713. BOOL setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
  714. EPointAtType getPointAtType();
  715. public:
  716. LLPointer<LLHUDEffectLookAt> mLookAt;
  717. LLPointer<LLHUDEffectPointAt> mPointAt;
  718. //--------------------------------------------------------------------
  719. // Third person
  720. //--------------------------------------------------------------------
  721. public:
  722. LLVector3d calcThirdPersonFocusOffset();
  723. void setThirdPersonHeadOffset(LLVector3 offset)  { mThirdPersonHeadOffset = offset; }
  724. private:
  725. LLVector3 mThirdPersonHeadOffset; // Head offset for third person camera position
  726. //--------------------------------------------------------------------
  727. // Orbit
  728. //--------------------------------------------------------------------
  729. public:
  730. void cameraOrbitAround(const F32 radians); // Rotate camera CCW radians about build focus point
  731. void cameraOrbitOver(const F32 radians); // Rotate camera forward radians over build focus point
  732. void cameraOrbitIn(const F32 meters); // Move camera in toward build focus point
  733. //--------------------------------------------------------------------
  734. // Zoom
  735. //--------------------------------------------------------------------
  736. public:
  737. void handleScrollWheel(S32 clicks);  // Mousewheel driven zoom
  738. void cameraZoomIn(const F32 factor); // Zoom in by fraction of current distance
  739. F32 getCameraZoomFraction(); // Get camera zoom as fraction of minimum and maximum zoom
  740. void setCameraZoomFraction(F32 fraction); // Set camera zoom as fraction of minimum and maximum zoom
  741. F32 calcCameraFOVZoomFactor();
  742. //--------------------------------------------------------------------
  743. // Pan
  744. //--------------------------------------------------------------------
  745. public:
  746. void cameraPanIn(const F32 meters);
  747. void cameraPanLeft(const F32 meters);
  748. void cameraPanUp(const F32 meters);
  749. //--------------------------------------------------------------------
  750. // View
  751. //--------------------------------------------------------------------
  752. public:
  753. // Called whenever the agent moves.  Puts camera back in default position, deselects items, etc.
  754. void resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE);
  755. // Called on camera movement.  Unlocks camera from the default position behind the avatar.
  756. void unlockView();
  757. //--------------------------------------------------------------------
  758. // Mouselook
  759. //--------------------------------------------------------------------
  760. public:
  761. BOOL getForceMouselook() const  { return mForceMouselook; }
  762. void setForceMouselook(BOOL mouselook)  { mForceMouselook = mouselook; }
  763. private:
  764. BOOL mForceMouselook;
  765. //--------------------------------------------------------------------
  766. // HUD
  767. //--------------------------------------------------------------------
  768. public:
  769. const LLColor4 &getEffectColor();
  770. void setEffectColor(const LLColor4 &color);
  771. public:
  772. F32 mHUDTargetZoom; // Target zoom level for HUD objects (used when editing)
  773. F32 mHUDCurZoom;  // Current animated zoom level for HUD objects
  774. private:
  775. LLUIColor  mEffectColor;
  776. /**                    Camera
  777.  **                                                                            **
  778.  *******************************************************************************/
  779. /********************************************************************************
  780.  **                                                                            **
  781.  **                    ACCESS
  782.  **/
  783. public:
  784. // Checks if agent can modify an object based on the permissions and the agent's proxy status.
  785. BOOL isGrantedProxy(const LLPermissions& perm);
  786. BOOL allowOperation(PermissionBit op,
  787.    const LLPermissions& perm,
  788.    U64 group_proxy_power = 0,
  789.    U8 god_minimum = GOD_MAINTENANCE);
  790. const LLAgentAccess& getAgentAccess();
  791. BOOL canManageEstate() const;
  792. BOOL getAdminOverride() const;
  793. // ! BACKWARDS COMPATIBILITY ! This function can go away after the AO transition (see llstartup.cpp).
  794. void  setAOTransition();
  795. private:
  796. LLAgentAccess  mAgentAccess;
  797. //--------------------------------------------------------------------
  798. // God
  799. //--------------------------------------------------------------------
  800. public:
  801. BOOL isGodlike() const;
  802. U8 getGodLevel() const;
  803. void setAdminOverride(BOOL b);
  804. void setGodLevel(U8 god_level);
  805. void requestEnterGodMode();
  806. void requestLeaveGodMode();
  807. //--------------------------------------------------------------------
  808. // Maturity
  809. //--------------------------------------------------------------------
  810. public:
  811. // Note: this is a prime candidate for pulling out into a Maturity class.
  812. // Rather than just expose the preference setting, we're going to actually
  813. // expose what the client code cares about -- what the user should see
  814. // based on a combination of the is* and prefers* flags, combined with god bit.
  815. bool  wantsPGOnly() const;
  816. bool  canAccessMature() const;
  817. bool  canAccessAdult() const;
  818. bool  canAccessMaturityInRegion( U64 region_handle ) const;
  819. bool  canAccessMaturityAtGlobal( LLVector3d pos_global ) const;
  820. bool  prefersPG() const;
  821. bool  prefersMature() const;
  822. bool  prefersAdult() const;
  823. bool  isTeen() const;
  824. bool  isMature() const;
  825. bool  isAdult() const;
  826. void  setTeen(bool teen);
  827. void  setMaturity(char text);
  828. static int  convertTextToMaturity(char text); 
  829. bool  sendMaturityPreferenceToServer(int preferredMaturity); // ! "U8" instead of "int"?
  830. // Maturity callbacks for PreferredMaturity control variable
  831. void  handleMaturity(const LLSD& newvalue);
  832. bool  validateMaturity(const LLSD& newvalue);
  833. /**                    Access
  834.  **                                                                            **
  835.  *******************************************************************************/
  836. /********************************************************************************
  837.  **                                                                            **
  838.  **                    RENDERING
  839.  **/
  840. public:
  841. LLQuaternion getHeadRotation();
  842. BOOL needsRenderAvatar(); // TRUE when camera mode is such that your own avatar should draw
  843. BOOL needsRenderHead();
  844. public:
  845. F32 mDrawDistance;
  846. private:
  847. BOOL mShowAvatar;  // Should we render the avatar?
  848. U32 mAppearanceSerialNum;
  849. //--------------------------------------------------------------------
  850. // Rendering state bitmap helpers
  851. //--------------------------------------------------------------------
  852. public:
  853. void setRenderState(U8 newstate);
  854. void clearRenderState(U8 clearstate);
  855. U8 getRenderState();
  856. private:
  857. U8 mRenderState; // Current behavior state of agent
  858. /**                    Rendering
  859.  **                                                                            **
  860.  *******************************************************************************/
  861. /********************************************************************************
  862.  **                                                                            **
  863.  **                    GROUPS
  864.  **/
  865. public:
  866. const LLUUID &getGroupID() const { return mGroupID; }
  867. // Get group information by group_id, or FALSE if not in group.
  868. BOOL  getGroupData(const LLUUID& group_id, LLGroupData& data) const;
  869. // Get just the agent's contribution to the given group.
  870. S32  getGroupContribution(const LLUUID& group_id) const;
  871. // Update internal datastructures and update the server.
  872. BOOL  setGroupContribution(const LLUUID& group_id, S32 contribution);
  873. BOOL  setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile);
  874. const std::string &getGroupName() const  { return mGroupName; }
  875. BOOL canJoinGroups() const;
  876. private:
  877. std::string mGroupName;
  878. LLUUID mGroupID;
  879. //--------------------------------------------------------------------
  880. // Group Membership
  881. //--------------------------------------------------------------------
  882. public:
  883. // Checks against all groups in the entire agent group list.
  884. BOOL  isInGroup(const LLUUID& group_id, BOOL ingnore_God_mod = FALSE) const;
  885. protected:
  886. // Only used for building titles.
  887. BOOL isGroupMember() const  { return !mGroupID.isNull(); } 
  888. public:
  889. LLDynamicArray<LLGroupData> mGroups;
  890. //--------------------------------------------------------------------
  891. // Group Title
  892. //--------------------------------------------------------------------
  893. public:
  894. void setHideGroupTitle(BOOL hide) { mHideGroupTitle = hide; }
  895. BOOL isGroupTitleHidden() const  { return mHideGroupTitle; }
  896. private:
  897. std::string mGroupTitle;  // Honorific, like "Sir"
  898. BOOL mHideGroupTitle;
  899. //--------------------------------------------------------------------
  900. // Group Powers
  901. //--------------------------------------------------------------------
  902. public:
  903. BOOL  hasPowerInGroup(const LLUUID& group_id, U64 power) const;
  904. BOOL  hasPowerInActiveGroup(const U64 power) const;
  905. U64   getPowerInGroup(const LLUUID& group_id) const;
  906.   U64 mGroupPowers;
  907. //--------------------------------------------------------------------
  908. // Friends
  909. //--------------------------------------------------------------------
  910. public:
  911. void  observeFriends();
  912. void  friendsChanged();
  913. private:
  914. LLFriendObserver* mFriendObserver;
  915. std::set<LLUUID> mProxyForAgents;
  916. /**                    Groups
  917.  **                                                                            **
  918.  *******************************************************************************/
  919. /********************************************************************************
  920.  **                                                                            **
  921.  **                    MESSAGING
  922.  **/
  923. //--------------------------------------------------------------------
  924. // Send
  925. //--------------------------------------------------------------------
  926. public:
  927. void sendMessage(); // Send message to this agent's region
  928. void sendReliableMessage();
  929. void sendAgentSetAppearance();
  930. void  sendAgentDataUpdateRequest();
  931. void  sendAgentUserInfoRequest();
  932. // IM to Email and Online visibility
  933. void sendAgentUpdateUserInfo(bool im_to_email, const std::string& directory_visibility);
  934. //--------------------------------------------------------------------
  935. // Receive
  936. //--------------------------------------------------------------------
  937. public:
  938. static void processAgentDataUpdate(LLMessageSystem *msg, void **);
  939. static void processAgentGroupDataUpdate(LLMessageSystem *msg, void **);
  940. static void processAgentDropGroup(LLMessageSystem *msg, void **);
  941. static void processScriptControlChange(LLMessageSystem *msg, void **);
  942. static void processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void **user_data);
  943. /**                    Messaging
  944.  **                                                                            **
  945.  *******************************************************************************/
  946. /********************************************************************************
  947.  **                                                                            **
  948.  **                    DEBUGGING
  949.  **/
  950. public:
  951. static void dumpGroupInfo();
  952. static void clearVisualParams(void *);
  953. friend std::ostream& operator<<(std::ostream &s, const LLAgent &sphere);
  954. /**                    Debugging
  955.  **                                                                            **
  956.  *******************************************************************************/
  957. };
  958. extern LLAgent gAgent;
  959. inline bool operator==(const LLGroupData &a, const LLGroupData &b)
  960. {
  961. return (a.mID == b.mID);
  962. }
  963. class LLAgentQueryManager
  964. {
  965. friend class LLAgent;
  966. friend class LLAgentWearables;
  967. public:
  968. LLAgentQueryManager();
  969. virtual ~LLAgentQueryManager();
  970. BOOL  hasNoPendingQueries() const  { return getNumPendingQueries() == 0; }
  971. S32  getNumPendingQueries() const  { return mNumPendingQueries; }
  972. private:
  973. S32 mNumPendingQueries;
  974. S32 mWearablesCacheQueryID;
  975. U32 mUpdateSerialNum;
  976. S32      mActiveCacheQueries[LLVOAvatarDefines::BAKED_NUM_INDICES];
  977. };
  978. extern LLAgentQueryManager gAgentQueryManager;
  979. #endif