llagent.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLAGENT_H
00033 #define LL_LLAGENT_H
00034 
00035 #include <set>
00036 
00037 #include "indra_constants.h"
00038 #include "llmath.h"
00039 #include "llchat.h"
00040 #include "llcoordframe.h"
00041 #include "llevent.h"
00042 #include "llagentconstants.h"
00043 #include "llanimationstates.h"
00044 #include "lldbstrings.h"
00045 #include "llhudeffectlookat.h"
00046 #include "llhudeffectpointat.h"
00047 #include "llmemory.h"
00048 #include "llstring.h"
00049 #include "lluuid.h"
00050 #include "m3math.h"
00051 #include "m4math.h"
00052 #include "llquaternion.h"
00053 #include "lltimer.h"
00054 #include "v3dmath.h"
00055 #include "v3math.h"
00056 #include "v4color.h"
00057 #include "v4math.h"
00058 //#include "vmath.h"
00059 #include "stdenums.h"
00060 #include "llwearable.h"
00061 #include "llcharacter.h"
00062 #include "llinventory.h"
00063 #include "llviewerinventory.h"
00064 #include "llagentdata.h"
00065 
00066 // Ventrella
00067 #include "llfollowcam.h"
00068 // end Ventrella
00069 
00070 const U8 AGENT_STATE_TYPING =   0x04;                   //  Typing indication
00071 const U8 AGENT_STATE_EDITING =  0x10;                   //  Set when agent has objects selected
00072 
00073 const BOOL ANIMATE = TRUE;
00074 
00075 typedef enum e_camera_modes
00076 {
00077         CAMERA_MODE_THIRD_PERSON,
00078         CAMERA_MODE_MOUSELOOK,
00079         CAMERA_MODE_CUSTOMIZE_AVATAR,
00080         CAMERA_MODE_FOLLOW
00081 } ECameraMode;
00082 
00086 typedef enum e_camera_position
00087 {
00088         CAMERA_POSITION_SELF, 
00089         CAMERA_POSITION_OBJECT 
00090 } ECameraPosition;
00091 
00092 typedef enum e_anim_request
00093 {
00094         ANIM_REQUEST_START,
00095         ANIM_REQUEST_STOP
00096 } EAnimRequest;
00097 
00098 class LLChat;
00099 class LLVOAvatar;
00100 class LLViewerRegion;
00101 class LLMotion;
00102 class LLToolset;
00103 class LLMessageSystem;
00104 class LLPermissions;
00105 class LLHost;
00106 class LLFriendObserver;
00107 
00108 struct LLGroupData
00109 {
00110         LLUUID mID;
00111         LLUUID mInsigniaID;
00112         U64 mPowers;
00113         BOOL mAcceptNotices;
00114         BOOL mListInProfile;
00115         S32 mContribution;
00116         std::string mName;
00117 };
00118 
00119 inline bool operator==(const LLGroupData &a, const LLGroupData &b)
00120 {
00121         return (a.mID == b.mID);
00122 }
00123 
00124 // forward declarations
00125 
00126 //
00127 
00128 class LLAgent : public LLObservable
00129 {
00130 public:
00131         // When the agent hasn't typed anything for this duration, it leaves the 
00132         // typing state (for both chat and IM).
00133         static const F32 TYPING_TIMEOUT_SECS;
00134 
00135         LLAgent();
00136         ~LLAgent();
00137 
00138         void                    init();
00139         void                    cleanup();
00140 
00141         //
00142         // MANIPULATORS
00143         //
00144         // TODO: Put all non-const functions here.
00145 
00146         // Called whenever the agent moves.  Puts camera back in default position,
00147         // deselects items, etc.
00148         void                    resetView(BOOL reset_camera = TRUE);
00149 
00150         // Called on camera movement, to allow the camera to be unlocked from the 
00151         // default position behind the avatar.
00152         void                    unlockView();
00153 
00154         void                    sendMessage();                                          // Send message to this agent's region.
00155         void                    sendReliableMessage();
00156 
00157         LLVector3d              calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
00158         LLVector3d              calcFocusPositionTargetGlobal();                        // target for this mode
00159         LLVector3d              getCameraPositionGlobal() const;
00160         const LLVector3 &getCameraPositionAgent() const;
00161         F32                             calcCameraFOVZoomFactor();
00162         F32                             getCameraMinOffGround();                        // minimum height off ground for this mode, meters
00163         void                    endAnimationUpdateUI();
00164         void                    setKey(const S32 direction, S32 &key);          // sets key to +1 for +direction, -1 for -direction
00165         void                    handleScrollWheel(S32 clicks);                          // mousewheel driven zoom
00166         
00167         void                    setAvatarObject(LLVOAvatar *avatar);
00168 
00169         // rendering state bitmask helpers
00170         void                    startTyping();
00171         void                    stopTyping();
00172         void                    setRenderState(U8 newstate);
00173         void                    clearRenderState(U8 clearstate);
00174         U8                              getRenderState();
00175 
00176         // Set the home data
00177         void                    setRegion(LLViewerRegion *regionp);
00178         LLViewerRegion  *getRegion() const;
00179         const LLHost&   getRegionHost() const;
00180 
00181         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
00182         void                    updateLookAt(const S32 mouse_x, const S32 mouse_y);
00183 
00184 
00185         void                    updateCamera();                 // call once per frame to update camera location/orientation
00186         void                    resetCamera();                                          // slam camera into its default position
00187         void                    setupSitCamera();
00188         void                    setCameraCollidePlane(LLVector4 &plane) { mCameraCollidePlane = plane; }
00189 
00190         void                    changeCameraToDefault();
00191         void                    changeCameraToMouselook(BOOL animate = TRUE);
00192         void                    changeCameraToThirdPerson(BOOL animate = TRUE);
00193         void                    changeCameraToCustomizeAvatar(BOOL animate = TRUE);                     // trigger transition animation
00194         // Ventrella
00195         void                    changeCameraToFollow(BOOL animate = TRUE);
00196         //end Ventrella
00197 
00198         void                    setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
00199         void                    setFocusOnAvatar(BOOL focus, BOOL animate);
00200         void                    setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
00201         void                    setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
00202         void                    clearFocusObject();
00203         void                    setFocusObject(LLViewerObject* object);
00204         void                    setObjectTracking(BOOL track) { mTrackFocusObject = track; }
00205 //      void                    setLookingAtAvatar(BOOL looking);
00206 
00207         void                    heardChat(const LLUUID& id);
00208         void                    lookAtLastChat();
00209         void                    lookAtObject(LLUUID avatar_id, ECameraPosition camera_pos);
00210         LLUUID                  getLastChatter() { return mLastChatterID; }
00211         F32                             getTypingTime() { return mTypingTimer.getElapsedTimeF32(); }
00212 
00213         void                    setAFK();
00214         void                    clearAFK();
00215         BOOL                    getAFK() const;
00216 
00217         void                    setAlwaysRun()  { mbAlwaysRun = TRUE; }
00218         void                    clearAlwaysRun() { mbAlwaysRun = FALSE; }
00219         BOOL                    getAlwaysRun() const { return mbAlwaysRun; }
00220 
00221         void                    setBusy();
00222         void                    clearBusy();
00223         BOOL                    getBusy() const;
00224 
00225         void                    setAdminOverride(BOOL b)        { mAdminOverride = b; }
00226         void                    setGodLevel(U8 god_level)       { mGodLevel = god_level; }
00227         void                    setFirstLogin(BOOL b)           { mFirstLogin = b; }
00228         void                    setGenderChosen(BOOL b)         { mGenderChosen = b; }
00229                 
00230         BOOL                    getAdminOverride() const        { return mAdminOverride; }
00231         // update internal datastructures and update the server with the
00232         // new contribution level. Returns true if the group id was found
00233         // and contribution could be set.
00234         BOOL setGroupContribution(const LLUUID& group_id, S32 contribution);
00235         BOOL setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile);
00236         void                    setHideGroupTitle(BOOL hide)    { mHideGroupTitle = hide; }
00237 
00238         //
00239         // ACCESSORS
00240         //
00241         // TODO: Put all read functions here, make them const
00242 
00243         const LLUUID&   getID() const                           { return gAgentID; }
00244         const LLUUID&   getSessionID() const            { return gAgentSessionID; }
00245         
00246         const LLUUID&   getSecureSessionID() const      { return mSecureSessionID; }
00247                 // Note: NEVER send this value in the clear or over any weakly
00248                 // encrypted channel (such as simple XOR masking).  If you are unsure
00249                 // ask Aaron or MarkL.
00250                 
00251         BOOL                    isGodlike() const;
00252         U8                              getGodLevel() const;
00253         bool isTeen() const;
00254         void setTeen(bool teen);
00255         BOOL                    isGroupTitleHidden() const              { return mHideGroupTitle; }
00256         BOOL                    isGroupMember() const           { return !mGroupID.isNull(); }          // This is only used for building titles!
00257         const LLUUID    &getGroupID() const                     { return mGroupID; }
00258         ECameraMode             getCameraMode() const           { return mCameraMode; }
00259         BOOL                    getFocusOnAvatar() const        { return mFocusOnAvatar; }
00260         LLPointer<LLViewerObject>&      getFocusObject()                { return mFocusObject; }
00261         F32                             getFocusObjectDist() const      { return mFocusObjectDist; }
00262         BOOL                    inPrelude();
00263         BOOL                    canManageEstate() const;
00264 
00265         const LLUUID&   getInventoryRootID() const      { return mInventoryRootID; }
00266 
00267         void                    buildFullname(std::string &name) const;
00268         void                    buildFullnameAndTitle(std::string &name) const;
00269 
00270         // Check against all groups in the entire agent group list.
00271         BOOL isInGroup(const LLUUID& group_id) const;
00272         BOOL hasPowerInGroup(const LLUUID& group_id, U64 power) const;
00273         // Check for power in just the active group.
00274         BOOL hasPowerInActiveGroup(const U64 power) const;
00275         U64  getPowerInGroup(const LLUUID& group_id) const;
00276 
00277         // Get group information by group_id. if not in group, data is
00278         // left unchanged and method returns FALSE. otherwise, values are
00279         // copied and returns TRUE.
00280         BOOL getGroupData(const LLUUID& group_id, LLGroupData& data) const;
00281         // Get just the agent's contribution to the given group.
00282         S32 getGroupContribution(const LLUUID& group_id) const;
00283 
00284         // return TRUE if the database reported this login as the first
00285         // for this particular user.
00286         BOOL isFirstLogin() const { return mFirstLogin; }
00287 
00288         // On the very first login, gender isn't chosen until the user clicks
00289         // in a dialog.  We don't render the avatar until they choose.
00290         BOOL isGenderChosen() const { return mGenderChosen; }
00291 
00292         // utility to build a location string
00293         void buildLocationString(std::string& str);
00294 
00295         LLQuaternion    getHeadRotation();
00296         LLVOAvatar         *getAvatarObject() const                     { return mAvatarObject; }
00297 
00298         BOOL                    needsRenderAvatar();            // TRUE when camera mode is such that your own avatar should draw
00299                                                                                                 // Not const because timers can't be accessed in const-fashion.
00300         BOOL                    needsRenderHead();
00301         BOOL                    cameraThirdPerson() const               { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
00302         BOOL                    cameraMouselook() const                 { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
00303         BOOL                    cameraCustomizeAvatar() const   { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
00304         BOOL                    cameraFollow() const                    { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
00305 
00306         LLVector3               getPosAgentFromGlobal(const LLVector3d &pos_global) const;
00307         LLVector3d              getPosGlobalFromAgent(const LLVector3 &pos_agent)       const;
00308 
00309         // Get the data members
00310         const LLVector3&        getAtAxis()             const   { return mFrameAgent.getAtAxis(); }             // direction avatar is looking, not camera
00311         const LLVector3&        getUpAxis()             const   { return mFrameAgent.getUpAxis(); }             // direction avatar is looking, not camera
00312         const LLVector3&        getLeftAxis()   const   { return mFrameAgent.getLeftAxis(); }   // direction avatar is looking, not camera
00313 
00314         LLCoordFrame            getFrameAgent() const   { return mFrameAgent; }
00315         LLVector3                       getVelocity()   const;
00316         F32                                     getVelocityZ()  const   { return getVelocity().mV[VZ]; }        // a hack
00317 
00318         const LLVector3d        &getPositionGlobal();
00319         const LLVector3         &getPositionAgent();
00320         S32                                     getRegionsVisited() const;
00321         F64                                     getDistanceTraveled() const;
00322 
00323         const LLVector3d        &getFocusGlobal() const { return mFocusGlobal; }
00324         const LLVector3d        &getFocusTargetGlobal() const   { return mFocusTargetGlobal; }
00325 
00326         BOOL                            getJump() const                 { return mbJump; }
00327         BOOL                            getAutoPilot() const    { return mAutoPilot; }
00328         LLVector3d                      getAutoPilotTargetGlobal() const        { return mAutoPilotTargetGlobal; }
00329 
00330         LLQuaternion            getQuat() const;                                                        // returns the quat that represents the rotation 
00331                                                                                                                                         // of the agent in the absolute frame
00332 //      BOOL                            getLookingAtAvatar() const;
00333 
00334         void                            getName(LLString& name);
00335 
00336         const LLColor4          &getEffectColor();
00337         void                            setEffectColor(const LLColor4 &color);
00338         //
00339         // UTILITIES
00340         //
00341 
00342         // Set the physics data
00343         void                    slamLookAt(const LLVector3 &look_at);
00344 
00345         void                    setPositionAgent(const LLVector3 &center);
00346 
00347         void                    resetAxes();
00348         void                    resetAxes(const LLVector3 &look_at);                                            // makes reasonable left and up
00349 
00350         // Move the avatar's frame
00351         void                    rotate(F32 angle, const LLVector3 &axis);
00352         void                    rotate(F32 angle, F32 x, F32 y, F32 z);
00353         void                    rotate(const LLMatrix3 &matrix);
00354         void                    rotate(const LLQuaternion &quaternion);
00355         void                    pitch(F32 angle);
00356         void                    roll(F32 angle);
00357         void                    yaw(F32 angle);
00358         LLVector3               getReferenceUpVector();
00359 
00360         void                    setThirdPersonHeadOffset(LLVector3 offset) { mThirdPersonHeadOffset = offset; }
00361         // Flight management
00362         BOOL                    getFlying() const                               { return mControlFlags & AGENT_CONTROL_FLY; }
00363         void                    setFlying(BOOL fly);
00364         void                    toggleFlying();
00365 
00366         // Does this parcel allow you to fly?
00367         BOOL canFly();
00368 
00369         // Animation functions
00370         void                    requestStopMotion( LLMotion* motion );
00371         void                    onAnimStop(const LLUUID& id);
00372 
00373         void                    sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
00374         void                    sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
00375 
00376         LLVector3d              calcFocusOffset(LLViewerObject *object, S32 x, S32 y);
00377         BOOL                    calcCameraMinDistance(F32 &obj_min_distance);
00378 
00379         void                    startCameraAnimation();
00380         void                    stopCameraAnimation();
00381 
00382         void                    cameraZoomIn(const F32 factor);                 // zoom in by fraction of current distance
00383         void                    cameraOrbitAround(const F32 radians);   // rotate camera CCW radians about build focus point
00384         void                    cameraOrbitOver(const F32 radians);             // rotate camera forward radians over build focus point
00385         void                    cameraOrbitIn(const F32 meters);                // move camera in toward build focus point
00386 
00387         F32                             getCameraZoomFraction();                                // get camera zoom as fraction of minimum and maximum zoom
00388         void                    setCameraZoomFraction(F32 fraction);    // set camera zoom as fraction of minimum and maximum zoom
00389 
00390         void                    cameraPanIn(const F32 meters);
00391         void                    cameraPanLeft(const F32 meters);
00392         void                    cameraPanUp(const F32 meters);
00393 
00394         void                    updateFocusOffset();
00395         void                    validateFocusObject();
00396 
00397         void                    setUsingFollowCam( bool using_follow_cam);
00398         
00399         F32                             calcCustomizeAvatarUIOffset( const LLVector3d& camera_pos_global );
00400 
00401         // marks current location as start, sends information to servers
00402         void                    setStartPosition(U32 location_id);
00403 
00404         // Movement from user input.  All set the appropriate animation flags.
00405         // All turn off autopilot and make sure the camera is behind the avatar.
00406         // direction is either positive, zero, or negative
00407         void                    moveAt(S32 direction);
00408         void                    moveAtNudge(S32 direction);
00409         void                    moveLeft(S32 direction);
00410         void                    moveLeftNudge(S32 direction);
00411         void                    moveUp(S32 direction);
00412         void                    moveYaw(F32 mag);
00413         void                    movePitch(S32 direction);
00414 
00415         void                    setOrbitLeftKey(F32 mag)                                { mOrbitLeftKey = mag; }
00416         void                    setOrbitRightKey(F32 mag)                               { mOrbitRightKey = mag; }
00417         void                    setOrbitUpKey(F32 mag)                                  { mOrbitUpKey = mag; }
00418         void                    setOrbitDownKey(F32 mag)                                { mOrbitDownKey = mag; }
00419         void                    setOrbitInKey(F32 mag)                                  { mOrbitInKey = mag; }
00420         void                    setOrbitOutKey(F32 mag)                                 { mOrbitOutKey = mag; }
00421 
00422         void                    setPanLeftKey(F32 mag)                                  { mPanLeftKey = mag; }
00423         void                    setPanRightKey(F32 mag)                                 { mPanRightKey = mag; }
00424         void                    setPanUpKey(F32 mag)                                    { mPanUpKey = mag; }
00425         void                    setPanDownKey(F32 mag)                                  { mPanDownKey = mag; }
00426         void                    setPanInKey(F32 mag)                                    { mPanInKey = mag; }
00427         void                    setPanOutKey(F32 mag)                                   { mPanOutKey = mag; }
00428 
00429         U32                     getControlFlags(); 
00430         void                    setControlFlags(U32 mask);                      // performs bitwise mControlFlags |= mask
00431         void                    clearControlFlags(U32 mask);                    // performs bitwise mControlFlags &= mask
00432         BOOL                    controlFlagsDirty() const;
00433         void                    enableControlFlagReset();
00434         void                    resetControlFlags();
00435 
00436         void                    propagate(const F32 dt);                                                                        // BUG: should roll into updateAgentPosition
00437 
00438         void                    startAutoPilotGlobal(const LLVector3d &pos_global, const std::string& behavior_name = std::string(), const LLQuaternion *target_rotation = NULL, 
00439                                                                         void (*finish_callback)(BOOL, void *) = NULL, void *callback_data = NULL, F32 stop_distance = 0.f, F32 rotation_threshold = 0.03f);
00440 
00441         void                    startFollowPilot(const LLUUID &leader_id);
00442         void                    stopAutoPilot(BOOL user_cancel = FALSE);
00443         void                    setAutoPilotGlobal(const LLVector3d &pos_global);
00444         void                    autoPilot(F32 *delta_yaw);                      // autopilot walking action, angles in radians
00445         void                    renderAutoPilotTarget();
00446 
00447         //
00448         // teportation methods
00449         //
00450 
00451         // go to a named location home
00452         void teleportRequest(
00453                 const U64& region_handle,
00454                 const LLVector3& pos_local);
00455 
00456         // teleport to a landmark
00457         void teleportViaLandmark(const LLUUID& landmark_id);
00458 
00459         // go home
00460         void teleportHome()     { teleportViaLandmark(LLUUID::null); }
00461 
00462         // to an invited location
00463         void teleportViaLure(const LLUUID& lure_id, BOOL godlike);
00464 
00465         // to a global location - this will probably need to be
00466         // deprecated.
00467         void teleportViaLocation(const LLVector3d& pos_global); 
00468 
00469         // cancel the teleport, may or may not be allowed by server
00470         void teleportCancel();
00471 
00472         void                    setTargetVelocity(const LLVector3 &vel);
00473         const LLVector3 &getTargetVelocity() const;
00474 
00475         void sendChat(const LLString &text, S32 channel = 0, EChatType type = CHAT_TYPE_NORMAL, bool animate = false);
00476         void sendChat(const LLWString &text, S32 channel = 0, EChatType type = CHAT_TYPE_NORMAL, bool animate = false)
00477                 { sendChat(wstring_to_utf8str(text), channel, type, animate); }
00478 
00479         // Setting the ability for this avatar to proxy for another avatar.
00480         //static void processAddModifyAbility(LLMessageSystem* msg, void**);
00481         //static void processGrantedProxies(LLMessageSystem* msg, void**);
00482         //static void processRemoveModifyAbility(LLMessageSystem* msg, void**);
00483         //BOOL isProxyFor(const LLUUID& agent_id);// *FIX should be const
00484 
00485         static void             processAgentDataUpdate(LLMessageSystem *msg, void **);
00486         static void             processAgentGroupDataUpdate(LLMessageSystem *msg, void **);
00487         static void             processAgentDropGroup(LLMessageSystem *msg, void **);
00488         static void             processScriptControlChange(LLMessageSystem *msg, void **);
00489         static void             processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void **user_data);
00490         //static void           processControlTake(LLMessageSystem *msg, void **);
00491         //static void           processControlRelease(LLMessageSystem *msg, void **);
00492 
00493         // This method checks to see if this agent can modify an object
00494         // based on the permissions and the agent's proxy status.
00495         BOOL                    isGrantedProxy(const LLPermissions& perm);
00496 
00497         BOOL                    allowOperation(PermissionBit op,
00498                                                                    const LLPermissions& perm,
00499                                                                    U64 group_proxy_power = 0,
00500                                                                    U8 god_minimum = GOD_MAINTENANCE);
00501 
00502         friend std::ostream& operator<<(std::ostream &s, const LLAgent &sphere);
00503 
00504         void                    initOriginGlobal(const LLVector3d &origin_global); // Only to be used in ONE place! - djs 08/07/02
00505 
00506         BOOL leftButtonGrabbed() const  { return (  (!cameraMouselook() && mControlsTakenCount[CONTROL_LBUTTON_DOWN_INDEX] > 0) 
00507                                                                                           ||(cameraMouselook() && mControlsTakenCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0)
00508                                                                                           ||(!cameraMouselook() && mControlsTakenPassedOnCount[CONTROL_LBUTTON_DOWN_INDEX] > 0)
00509                                                                                           ||(cameraMouselook() && mControlsTakenPassedOnCount[CONTROL_ML_LBUTTON_DOWN_INDEX] > 0)); }
00510         BOOL rotateGrabbed() const              { return (  (mControlsTakenCount[CONTROL_YAW_POS_INDEX] > 0)
00511                                                                                           ||(mControlsTakenCount[CONTROL_YAW_NEG_INDEX] > 0)); }
00512         BOOL forwardGrabbed() const             { return (      (mControlsTakenCount[CONTROL_AT_POS_INDEX] > 0)); }
00513         BOOL backwardGrabbed() const            { return (      (mControlsTakenCount[CONTROL_AT_NEG_INDEX] > 0)); }
00514         BOOL upGrabbed() const          { return (      (mControlsTakenCount[CONTROL_UP_POS_INDEX] > 0)); }
00515         BOOL downGrabbed() const        { return (      (mControlsTakenCount[CONTROL_UP_NEG_INDEX] > 0)); }
00516 
00517         // True iff a script has taken over a control.
00518         BOOL                    anyControlGrabbed() const;
00519 
00520         BOOL isControlGrabbed(S32 control_index) const;
00521 
00522         // Send message to simulator to force grabbed controls to be
00523         // released, in case of a poorly written script.
00524         void                    forceReleaseControls();
00525 
00526         BOOL                    sitCameraEnabled() { return mSitCameraEnabled; }
00527 
00528         F32                             getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.magVec(); }
00529 
00530         // look at behavior
00531         BOOL                    setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
00532         ELookAtType             getLookAtType();
00533 
00534         // point at behavior
00535         BOOL                    setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
00536         EPointAtType    getPointAtType();
00537 
00538         void                    setHomePosRegion( const U64& region_handle, const LLVector3& pos_region );
00539         BOOL                    getHomePosGlobal( LLVector3d* pos_global );
00540         void                    setCameraAnimating( BOOL b )    { mCameraAnimating = b; }
00541         void                    setAnimationDuration( F32 seconds ) { mAnimationDuration = seconds; }
00542 
00543         F32                             getNearChatRadius() { return mNearChatRadius; }
00544 
00545         enum ETeleportState
00546         {
00547                 TELEPORT_NONE = 0,                      // No teleport in progress
00548                 TELEPORT_START = 1,                     // Transition to REQUESTED.  Viewer has sent a TeleportRequest to the source simulator
00549                 TELEPORT_REQUESTED = 2,         // Waiting for source simulator to respond
00550                 TELEPORT_MOVING = 3,            // Viewer has received destination location from source simulator
00551                 TELEPORT_START_ARRIVAL = 4,     // Transition to ARRIVING.  Viewer has received avatar update, etc., from destination simulator
00552                 TELEPORT_ARRIVING = 5           // Make the user wait while content "pre-caches"
00553         };
00554 
00555         ETeleportState  getTeleportState() const                        { return mTeleportState; }
00556         void                    setTeleportState( ETeleportState state );
00557         const LLString& getTeleportMessage() const { return mTeleportMessage; }
00558         void setTeleportMessage(const LLString& message)
00559         {
00560                 mTeleportMessage = message;
00561         }
00562 
00563         // trigger random fidget animations
00564         void                    fidget();
00565 
00566         void                    requestEnterGodMode();
00567         void                    requestLeaveGodMode();
00568 
00569         void                    sendAgentSetAppearance();
00570 
00571         void                    sendAgentDataUpdateRequest();
00572 
00573         // Ventrella
00574         LLFollowCam mFollowCam;
00575         // end Ventrella 
00576 
00577         //--------------------------------------------------------------------
00578         // Wearables
00579         //--------------------------------------------------------------------
00580         BOOL                    getWearablesLoaded() const      { return mWearablesLoaded; }
00581 
00582         void                    setWearable( LLInventoryItem* new_item, LLWearable* wearable );
00583         static void             onSetWearableDialog( S32 option, void* userdata );
00584         void                    setWearableFinal( LLInventoryItem* new_item, LLWearable* new_wearable );
00585         void                    setWearableOutfit(      const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove );
00586         void                    queryWearableCache();
00587 
00588         BOOL                    isWearableModifiable(EWearableType type);
00589         BOOL                    isWearableCopyable(EWearableType type);
00590         BOOL                    needsReplacement(EWearableType wearableType, S32 remove);
00591         U32                             getWearablePermMask(EWearableType type);
00592 
00593         LLInventoryItem* getWearableInventoryItem(EWearableType type);
00594 
00595         LLWearable*             getWearable( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mWearable : NULL; }
00596         BOOL                    isWearingItem( const LLUUID& item_id );
00597         LLWearable*             getWearableFromWearableItem( const LLUUID& item_id );
00598         const LLUUID&   getWearableItem( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mItemID : LLUUID::null; }
00599 
00600         static EWearableType getTEWearableType( S32 te );
00601         static LLUUID   getDefaultTEImageID( S32 te );
00602         
00603         void                    copyWearableToInventory( EWearableType type );
00604 
00605         void                    makeNewOutfit(
00606                                                 const std::string& new_folder_name,
00607                                                 const LLDynamicArray<S32>& wearables_to_include,
00608                                                 const LLDynamicArray<S32>& attachments_to_include,
00609                                                 BOOL rename_clothing);
00610         void                    makeNewOutfitDone(S32 index);
00611 
00612         void                    removeWearable( EWearableType type );
00613         static void             onRemoveWearableDialog( S32 option, void* userdata );
00614         void                    removeWearableFinal( EWearableType type );
00615         
00616         void                    sendAgentWearablesUpdate();
00617 
00628         void addWearabletoAgentInventoryDone(
00629                 S32 index,
00630                 const LLUUID& item_id,
00631                 LLWearable* wearable);
00632         
00633         void                    saveWearableAs( EWearableType type, const std::string& new_name, BOOL save_in_lost_and_found );
00634         void                    saveWearable( EWearableType type, BOOL send_update = TRUE );
00635         void                    saveAllWearables();
00636         
00637         void                    revertWearable( EWearableType type );
00638         void                    revertAllWearables();
00639 
00640         void                    setWearableName( const LLUUID& item_id, const std::string& new_name );
00641         void                    createStandardWearables(BOOL female);
00642         void                    createStandardWearablesDone(S32 index);
00643         void                    createStandardWearablesAllDone();
00644 
00645         BOOL                    areWearablesLoaded() { return mWearablesLoaded; }
00646 
00647         void observeFriends();
00648         void friendsChanged();
00649 
00650         // statics
00651         static void             stopFidget();
00652         static void             processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys, void** user_data);
00653         static void             userRemoveWearable( void* userdata );   // userdata is EWearableType
00654         static void             userRemoveAllClothes( void* userdata ); // userdata is NULL
00655         static void             userRemoveAllClothesStep2(BOOL proceed, void* userdata ); // userdata is NULL
00656         static void             userRemoveAllAttachments( void* userdata);      // userdata is NULL
00657         static BOOL             selfHasWearable( void* userdata );                      // userdata is EWearableType
00658 
00659         //debug methods
00660         static void             clearVisualParams(void *);
00661 
00662 protected:
00663         // stuff to do for any sort of teleport. Returns true if the
00664         // teleport can proceed.
00665         bool teleportCore(bool is_local = false);
00666 
00667         // helper function to prematurely age chat when agent is moving
00668         void ageChat();
00669 
00670         // internal wearable functions
00671         void                    sendAgentWearablesRequest();
00672         static void             onInitialWearableAssetArrived(LLWearable* wearable, void* userdata);
00673         void                    recoverMissingWearable(EWearableType type);
00674         void                    recoverMissingWearableDone();
00675         void                    addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
00676                                                 LLWearable* wearable, const LLUUID& category_id = LLUUID::null,
00677                                                 BOOL notify = TRUE);
00678 public:
00679         // TODO: Make these private!
00680         U32                             mViewerPort;                            // Port this agent transmits on.
00681         LLUUID                  mSecureSessionID;                       // secure token for this login session
00682 
00683         F32                             mDrawDistance;
00684 
00685         U64                             mGroupPowers;
00686         BOOL                    mHideGroupTitle;
00687         char                    mGroupTitle[DB_GROUP_TITLE_BUF_SIZE];   /*Flawfinder: ignore*/  // honorific, like "Sir"
00688         char                    mGroupName[DB_GROUP_NAME_BUF_SIZE];     /*Flawfinder: ignore*/
00689         LLUUID                  mGroupID;
00690         //LLUUID                        mGroupInsigniaID;
00691         LLUUID                  mInventoryRootID;
00692         LLUUID                  mMapID;
00693         F64                             mMapOriginX;    // Global x coord of mMapID's bottom left corner.
00694         F64                             mMapOriginY;    // Global y coord of mMapID's bottom left corner.
00695         S32                             mMapWidth;      // Width of map in meters
00696         S32                             mMapHeight;     // Height of map in meters
00697         std::string             mMOTD;  // message of the day
00698 
00699         LLPointer<LLHUDEffectLookAt> mLookAt;
00700         LLPointer<LLHUDEffectPointAt> mPointAt;
00701 
00702         LLDynamicArray<LLGroupData> mGroups;
00703 
00704         BOOL                    mInitialized;
00705 
00706         static BOOL             sDebugDisplayTarget;
00707         S32                             mNumPendingQueries;
00708         S32*                    mActiveCacheQueries;
00709 
00710         BOOL                    mForceMouselook;
00711 
00712         static void parseTeleportMessages(const LLString& xml_filename);
00713         //we should really define ERROR and PROGRESS enums here
00714         //but I don't really feel like doing that, so I am just going
00715         //to expose the mappings....yup
00716         static std::map<LLString, LLString> sTeleportErrorMessages;
00717         static std::map<LLString, LLString> sTeleportProgressMessages;
00718 
00719 private:
00720         // Access or "maturity" level
00721         U8                              mAccess;        // SIM_ACCESS_MATURE or SIM_ACCESS_PG
00722         ETeleportState  mTeleportState;
00723         LLString                mTeleportMessage;
00724 
00725         S32                             mControlsTakenCount[TOTAL_CONTROLS];
00726         S32                             mControlsTakenPassedOnCount[TOTAL_CONTROLS];
00727 
00728         LLViewerRegion  *mRegionp;
00729         LLVector3d              mAgentOriginGlobal;                             // Origin of agent coords from global coords
00730         mutable LLVector3d mPositionGlobal;
00731 
00732         std::set<U64>   mRegionsVisited;                                // stat - what distinct regions has the avatar been to?
00733         F64                             mDistanceTraveled;                              // stat - how far has the avatar moved?
00734         LLVector3d              mLastPositionGlobal;                    // Used to calculate travel distance
00735 
00736         LLPointer<LLVOAvatar> mAvatarObject;                    // NULL until avatar object sent down from simulator
00737 
00738         U8                              mRenderState;                                   // Current behavior state of agent
00739         LLFrameTimer    mTypingTimer;
00740 
00741         ECameraMode             mCameraMode;                                    // target mode after transition animation is done
00742         ECameraMode             mLastCameraMode;
00743         BOOL                    mViewsPushed;                                   // keep track of whether or not we have pushed views.
00744 
00745         BOOL                    mbAlwaysRun;                                    // should the avatar run rather than walk
00746         BOOL                    mShowAvatar;                                    // should we render the avatar?
00747         BOOL                    mCameraAnimating;                               // camera is transitioning from one mode to another
00748         LLVector3d              mAnimationCameraStartGlobal;    // camera start position, global coords
00749         LLVector3d              mAnimationFocusStartGlobal;             // camera focus point, global coords
00750         LLFrameTimer    mAnimationTimer;                                // seconds that transition animation has been active
00751         F32                             mAnimationDuration;                             // seconds
00752         F32                             mCameraFOVZoomFactor;                   // amount of fov zoom applied to camera when zeroing in on an object
00753         F32                             mCameraCurrentFOVZoomFactor;    // interpolated fov zoom
00754         F32                             mCameraFOVDefault;                              // default field of view that is basis for FOV zoom effect
00755         LLVector3d              mCameraFocusOffset;                             // offset from focus point in build mode
00756         LLVector3d              mCameraFocusOffsetTarget;               // target towards which we are lerping the camera's focus offset
00757         LLVector3               mCameraOffsetDefault;                   // default third-person camera offset
00758         LLVector4               mCameraCollidePlane;                    // colliding plane for camera
00759         F32                             mCurrentCameraDistance;                 // current camera offset from avatar
00760         F32                             mTargetCameraDistance;                  // target camera offset from avatar
00761         F32                             mCameraZoomFraction;                    // mousewheel driven fraction of zoom
00762         LLVector3               mCameraLag;                                             // third person camera lag
00763         LLVector3               mThirdPersonHeadOffset;                 // head offset for third person camera position
00764         LLVector3               mCameraPositionAgent;                   // camera position in agent coordinates
00765         LLVector3               mCameraVirtualPositionAgent;    // camera virtual position (target) before performing FOV zoom
00766         BOOL                    mSitCameraEnabled;                              // use provided camera information when sitting?
00767         LLVector3               mSitCameraPos;                                  // root relative camera pos when sitting
00768         LLVector3               mSitCameraFocus;                                // root relative camera target when sitting
00769 
00770         //Ventrella
00771         LLVector3               mCameraUpVector;                                // camera's up direction in world coordinates (determines the 'roll' of the view)
00772         //End Ventrella
00773 
00774         LLPointer<LLViewerObject> mSitCameraReferenceObject;    // object to which camera is related when sitting
00775 
00776         BOOL                    mFocusOnAvatar;                                 
00777         LLVector3d              mFocusGlobal;
00778         LLVector3d              mFocusTargetGlobal;
00779         LLPointer<LLViewerObject>       mFocusObject;
00780         F32                             mFocusObjectDist;
00781         LLVector3               mFocusObjectOffset;
00782         F32                             mFocusDotRadius;                                // meters
00783         BOOL                    mTrackFocusObject;
00784         F32                             mUIOffset;
00785 
00786         LLCoordFrame    mFrameAgent;                                    // Agent position and view, agent-region coordinates
00787 
00788         BOOL                    mCrouching;
00789         BOOL                    mIsBusy;
00790 
00791         S32                     mAtKey;                                                 // Either 1, 0, or -1... indicates that movement-key is pressed
00792         S32                             mWalkKey;                                               // like AtKey, but causes less forward thrust
00793         S32                     mLeftKey;
00794         S32                             mUpKey;
00795         F32                             mYawKey;
00796         S32                             mPitchKey;
00797 
00798         F32                             mOrbitLeftKey;
00799         F32                             mOrbitRightKey;
00800         F32                             mOrbitUpKey;
00801         F32                             mOrbitDownKey;
00802         F32                             mOrbitInKey;
00803         F32                             mOrbitOutKey;
00804 
00805         F32                             mPanUpKey;                                              
00806         F32                             mPanDownKey;                                    
00807         F32                             mPanLeftKey;                                    
00808         F32                             mPanRightKey;                                   
00809         F32                             mPanInKey;
00810         F32                             mPanOutKey;
00811 
00812         U32                             mControlFlags;                                  // replacement for the mFooKey's
00813         BOOL                    mbFlagsDirty;
00814         BOOL                    mbFlagsNeedReset;                               // HACK for preventing incorrect flags sent when crossing region boundaries
00815 
00816         BOOL                    mbJump;
00817 
00818         BOOL                    mAutoPilot;
00819         BOOL                    mAutoPilotFlyOnStop;
00820         LLVector3d              mAutoPilotTargetGlobal;
00821         F32                             mAutoPilotStopDistance;
00822         BOOL                    mAutoPilotUseRotation;
00823         LLVector3               mAutoPilotTargetFacing;
00824         F32                             mAutoPilotTargetDist;
00825         S32                             mAutoPilotNoProgressFrameCount;
00826         F32                             mAutoPilotRotationThreshold;
00827         std::string             mAutoPilotBehaviorName;
00828         void                    (*mAutoPilotFinishedCallback)(BOOL, void *);
00829         void*                   mAutoPilotCallbackData;
00830         LLUUID                  mLeaderID;
00831 
00832         std::set<LLUUID> mProxyForAgents;
00833 
00834         LLColor4 mEffectColor;
00835 
00836         BOOL mHaveHomePosition;
00837         U64                             mHomeRegionHandle;
00838         LLVector3               mHomePosRegion;
00839         LLFrameTimer    mChatTimer;
00840         LLUUID                  mLastChatterID;
00841         F32                             mNearChatRadius;
00842         BOOL                    mAdminOverride;
00843 
00844         // See indra_constants.h for values.
00845         U8                              mGodLevel;
00846         LLFrameTimer    mFidgetTimer;
00847         LLFrameTimer    mFocusObjectFadeTimer;
00848         std::set<LLPointer <LLViewerObject> > mFadeObjects;
00849         F32                             mNextFidgetTime;
00850         S32                             mCurrentFidget;
00851         BOOL                    mFirstLogin;
00852         BOOL                    mGenderChosen;
00853         
00854         //--------------------------------------------------------------------
00855         // Wearables
00856         //--------------------------------------------------------------------
00857         struct LLWearableEntry
00858         {
00859                 LLWearableEntry() : mItemID( LLUUID::null ), mWearable( NULL ) {}
00860 
00861                 LLUUID          mItemID;        // ID of the inventory item in the agent's inventory.
00862                 LLWearable*     mWearable;
00863         };
00864         LLWearableEntry mWearableEntry[ WT_COUNT ];
00865         U32                             mAgentWearablesUpdateSerialNum;
00866         BOOL                    mWearablesLoaded;
00867         S32                             mTextureCacheQueryID;
00868         U32                             mAppearanceSerialNum;
00869         LLAnimPauseRequest mPauseRequest;
00870 
00871         class createStandardWearablesAllDoneCallback : public LLRefCount
00872         {
00873         protected:
00874                 ~createStandardWearablesAllDoneCallback();
00875         };
00876         class sendAgentWearablesUpdateCallback : public LLRefCount
00877         {
00878         protected:
00879                 ~sendAgentWearablesUpdateCallback();
00880         };
00881 
00882         class addWearableToAgentInventoryCallback : public LLInventoryCallback
00883         {
00884         public:
00885                 enum {
00886                         CALL_NONE = 0,
00887                         CALL_UPDATE = 1,
00888                         CALL_RECOVERDONE = 2,
00889                         CALL_CREATESTANDARDDONE = 4,
00890                         CALL_MAKENEWOUTFITDONE = 8
00891                 } EType;
00892 
00903                 addWearableToAgentInventoryCallback(
00904                         LLPointer<LLRefCount> cb,
00905                         S32 index,
00906                         LLWearable* wearable,
00907                         U32 todo = CALL_NONE);
00908                 virtual void fire(const LLUUID& inv_item);
00909 
00910         private:
00911                 S32 mIndex;
00912                 LLWearable* mWearable;
00913                 U32 mTodo;
00914                 LLPointer<LLRefCount> mCB;
00915         };
00916 
00917         //control listeners
00918         class LLHideGroupTitleListener: public LLSimpleListener
00919         {
00920         public:
00921                 bool handleEvent(LLPointer<LLEvent> event, const LLSD &userdata);
00922         };
00923 
00924         class LLEffectColorListener: public LLSimpleListener
00925         {
00926         public:
00927                 bool handleEvent(LLPointer<LLEvent> event, const LLSD &userdata);
00928         };
00929 
00930         LLHideGroupTitleListener mHideGroupTitleListener;
00931         LLEffectColorListener mEffectColorListener;
00932         LLFriendObserver* mFriendObserver;
00933 };
00934 
00935 extern LLAgent gAgent;
00936 
00937 #endif

Generated on Thu Jul 1 06:08:18 2010 for Second Life Viewer by  doxygen 1.4.7