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 "llcontrol.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 
00083 typedef enum e_anim_request
00084 {
00085         ANIM_REQUEST_START,
00086         ANIM_REQUEST_STOP
00087 } EAnimRequest;
00088 
00089 class LLChat;
00090 class LLVOAvatar;
00091 class LLViewerRegion;
00092 class LLMotion;
00093 class LLToolset;
00094 class LLMessageSystem;
00095 class LLPermissions;
00096 class LLHost;
00097 class LLFriendObserver;
00098 
00099 struct LLGroupData
00100 {
00101         LLUUID mID;
00102         LLUUID mInsigniaID;
00103         U64 mPowers;
00104         BOOL mAcceptNotices;
00105         BOOL mListInProfile;
00106         S32 mContribution;
00107         std::string mName;
00108 };
00109 
00110 inline bool operator==(const LLGroupData &a, const LLGroupData &b)
00111 {
00112         return (a.mID == b.mID);
00113 }
00114 
00115 // forward declarations
00116 
00117 //
00118 
00119 class LLAgent : public LLObservable
00120 {
00121         LOG_CLASS(LLAgent);
00122         
00123 public:
00124         // When the agent hasn't typed anything for this duration, it leaves the 
00125         // typing state (for both chat and IM).
00126         static const F32 TYPING_TIMEOUT_SECS;
00127 
00128         LLAgent();
00129         ~LLAgent();
00130 
00131         void                    init();
00132         void                    cleanup();
00133 
00134         //
00135         // MANIPULATORS
00136         //
00137         // TODO: Put all non-const functions here.
00138 
00139         // Called whenever the agent moves.  Puts camera back in default position,
00140         // deselects items, etc.
00141         void                    resetView(BOOL reset_camera = TRUE);
00142 
00143         // Called on camera movement, to allow the camera to be unlocked from the 
00144         // default position behind the avatar.
00145         void                    unlockView();
00146 
00147         void            onAppFocusGained();
00148 
00149         void                    sendMessage();                                          // Send message to this agent's region.
00150         void                    sendReliableMessage();
00151 
00152         LLVector3d              calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
00153         LLVector3d              calcFocusPositionTargetGlobal();                        // target for this mode
00154         LLVector3d              getCameraPositionGlobal() const;
00155         const LLVector3 &getCameraPositionAgent() const;
00156         F32                             calcCameraFOVZoomFactor();
00157         F32                             getCameraMinOffGround();                        // minimum height off ground for this mode, meters
00158         void                    endAnimationUpdateUI();
00159         void                    setKey(const S32 direction, S32 &key);          // sets key to +1 for +direction, -1 for -direction
00160         void                    handleScrollWheel(S32 clicks);                          // mousewheel driven zoom
00161         
00162         void                    setAvatarObject(LLVOAvatar *avatar);
00163 
00164         // rendering state bitmask helpers
00165         void                    startTyping();
00166         void                    stopTyping();
00167         void                    setRenderState(U8 newstate);
00168         void                    clearRenderState(U8 clearstate);
00169         U8                              getRenderState();
00170 
00171         // Set the home data
00172         void                    setRegion(LLViewerRegion *regionp);
00173         LLViewerRegion  *getRegion() const;
00174         const LLHost&   getRegionHost() const;
00175         std::string             getSLURL() const;
00176         
00177         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
00178         void                    updateLookAt(const S32 mouse_x, const S32 mouse_y);
00179 
00180 
00181         void                    updateCamera();                 // call once per frame to update camera location/orientation
00182         void                    resetCamera();                                          // slam camera into its default position
00183         void                    setupSitCamera();
00184         void                    setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; }
00185 
00186         void                    changeCameraToDefault();
00187         void                    changeCameraToMouselook(BOOL animate = TRUE);
00188         void                    changeCameraToThirdPerson(BOOL animate = TRUE);
00189         void                    changeCameraToCustomizeAvatar(BOOL avatar_animate = TRUE, BOOL camera_animate = TRUE);                  // trigger transition animation
00190         // Ventrella
00191         void                    changeCameraToFollow(BOOL animate = TRUE);
00192         //end Ventrella
00193 
00194         void                    setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
00195         void                    setFocusOnAvatar(BOOL focus, BOOL animate);
00196         void                    setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
00197         void                    setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
00198         void                    clearFocusObject();
00199         void                    setFocusObject(LLViewerObject* object);
00200         void                    setObjectTracking(BOOL track) { mTrackFocusObject = track; }
00201 //      void                    setLookingAtAvatar(BOOL looking);
00202 
00203         void                    heardChat(const LLUUID& id);
00204         void                    lookAtLastChat();
00205         F32                     getTypingTime() { return mTypingTimer.getElapsedTimeF32(); }
00206 
00207         void                    setAFK();
00208         void                    clearAFK();
00209         BOOL                    getAFK() const;
00210 
00211         void                    setAlwaysRun() { mbAlwaysRun = true; }
00212         void                    clearAlwaysRun() { mbAlwaysRun = false; }
00213 
00214         void                    setRunning() { mbRunning = true; }
00215         void                    clearRunning() { mbRunning = false; }
00216 
00217         void                    setBusy();
00218         void                    clearBusy();
00219         BOOL                    getBusy() const;
00220 
00221         void                    setAdminOverride(BOOL b)        { mAdminOverride = b; }
00222         void                    setGodLevel(U8 god_level)       { mGodLevel = god_level; }
00223         void                    setFirstLogin(BOOL b)           { mFirstLogin = b; }
00224         void                    setGenderChosen(BOOL b)         { mGenderChosen = b; }
00225 
00226         // update internal datastructures and update the server with the
00227         // new contribution level. Returns true if the group id was found
00228         // and contribution could be set.
00229         BOOL                    setGroupContribution(const LLUUID& group_id, S32 contribution);
00230         BOOL                    setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile);
00231         void                    setHideGroupTitle(BOOL hide)    { mHideGroupTitle = hide; }
00232 
00233         //
00234         // ACCESSORS
00235         //
00236         // TODO: Put all read functions here, make them const
00237 
00238         const LLUUID&   getID() const                           { return gAgentID; }
00239         const LLUUID&   getSessionID() const            { return gAgentSessionID; }
00240         
00241         const LLUUID&   getSecureSessionID() const      { return mSecureSessionID; }
00242                 // Note: NEVER send this value in the clear or over any weakly
00243                 // encrypted channel (such as simple XOR masking).  If you are unsure
00244                 // ask Aaron or MarkL.
00245                 
00246         BOOL                    isGodlike() const;
00247         U8                              getGodLevel() const;
00248         bool isTeen() const;
00249         void setTeen(bool teen);
00250         BOOL                    isGroupTitleHidden() const              { return mHideGroupTitle; }
00251         BOOL                    isGroupMember() const           { return !mGroupID.isNull(); }          // This is only used for building titles!
00252         const LLUUID    &getGroupID() const                     { return mGroupID; }
00253         ECameraMode             getCameraMode() const           { return mCameraMode; }
00254         BOOL                    getFocusOnAvatar() const        { return mFocusOnAvatar; }
00255         LLPointer<LLViewerObject>&      getFocusObject()                { return mFocusObject; }
00256         F32                             getFocusObjectDist() const      { return mFocusObjectDist; }
00257         BOOL                    inPrelude();
00258         BOOL                    canManageEstate() const;
00259         BOOL                    getAdminOverride() const        { return mAdminOverride; }
00260 
00261         LLUUID                  getLastChatter() const { return mLastChatterID; }
00262         bool                    getAlwaysRun() const { return mbAlwaysRun; }
00263         bool                    getRunning() const { return mbRunning; }
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() const;
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     F32             clampPitchToLimits(F32 angle);
00360 
00361         void                    setThirdPersonHeadOffset(LLVector3 offset) { mThirdPersonHeadOffset = offset; }
00362         // Flight management
00363         BOOL                    getFlying() const                               { return mControlFlags & AGENT_CONTROL_FLY; }
00364         void                    setFlying(BOOL fly);
00365         void                    toggleFlying();
00366 
00367         // Does this parcel allow you to fly?
00368         BOOL canFly();
00369 
00370         // Animation functions
00371         void                    requestStopMotion( LLMotion* motion );
00372         void                    onAnimStop(const LLUUID& id);
00373 
00374         void                    sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
00375         void                    sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
00376 
00377         LLVector3d              calcFocusOffset(LLViewerObject *object, S32 x, S32 y);
00378         BOOL                    calcCameraMinDistance(F32 &obj_min_distance);
00379 
00380         void                    startCameraAnimation();
00381         void                    stopCameraAnimation();
00382 
00383         void                    cameraZoomIn(const F32 factor);                 // zoom in by fraction of current distance
00384         void                    cameraOrbitAround(const F32 radians);   // rotate camera CCW radians about build focus point
00385         void                    cameraOrbitOver(const F32 radians);             // rotate camera forward radians over build focus point
00386         void                    cameraOrbitIn(const F32 meters);                // move camera in toward build focus point
00387 
00388         F32                             getCameraZoomFraction();                                // get camera zoom as fraction of minimum and maximum zoom
00389         void                    setCameraZoomFraction(F32 fraction);    // set camera zoom as fraction of minimum and maximum zoom
00390 
00391         void                    cameraPanIn(const F32 meters);
00392         void                    cameraPanLeft(const F32 meters);
00393         void                    cameraPanUp(const F32 meters);
00394 
00395         void                    updateFocusOffset();
00396         void                    validateFocusObject();
00397 
00398         void                    setUsingFollowCam( bool using_follow_cam);
00399         
00400         F32                             calcCustomizeAvatarUIOffset( const LLVector3d& camera_pos_global );
00401 
00402         // marks current location as start, sends information to servers
00403         void                    setStartPosition(U32 location_id);
00404 
00405         // Movement from user input.  All set the appropriate animation flags.
00406         // All turn off autopilot and make sure the camera is behind the avatar.
00407         // direction is either positive, zero, or negative
00408         void                    moveAt(S32 direction, bool reset_view = true);
00409         void                    moveAtNudge(S32 direction);
00410         void                    moveLeft(S32 direction);
00411         void                    moveLeftNudge(S32 direction);
00412         void                    moveUp(S32 direction);
00413         void                    moveYaw(F32 mag, bool reset_view = true);
00414         void                    movePitch(S32 direction);
00415 
00416         void                    setOrbitLeftKey(F32 mag)                                { mOrbitLeftKey = mag; }
00417         void                    setOrbitRightKey(F32 mag)                               { mOrbitRightKey = mag; }
00418         void                    setOrbitUpKey(F32 mag)                                  { mOrbitUpKey = mag; }
00419         void                    setOrbitDownKey(F32 mag)                                { mOrbitDownKey = mag; }
00420         void                    setOrbitInKey(F32 mag)                                  { mOrbitInKey = mag; }
00421         void                    setOrbitOutKey(F32 mag)                                 { mOrbitOutKey = mag; }
00422 
00423         void                    setPanLeftKey(F32 mag)                                  { mPanLeftKey = mag; }
00424         void                    setPanRightKey(F32 mag)                                 { mPanRightKey = mag; }
00425         void                    setPanUpKey(F32 mag)                                    { mPanUpKey = mag; }
00426         void                    setPanDownKey(F32 mag)                                  { mPanDownKey = mag; }
00427         void                    setPanInKey(F32 mag)                                    { mPanInKey = mag; }
00428         void                    setPanOutKey(F32 mag)                                   { mPanOutKey = mag; }
00429 
00430         U32                     getControlFlags(); 
00431         void                    setControlFlags(U32 mask);                      // performs bitwise mControlFlags |= mask
00432         void                    clearControlFlags(U32 mask);                    // performs bitwise mControlFlags &= ~mask
00433         BOOL                    controlFlagsDirty() const;
00434         void                    enableControlFlagReset();
00435         void                    resetControlFlags();
00436 
00437         void                    propagate(const F32 dt);                                                                        // BUG: should roll into updateAgentPosition
00438 
00439         void                    startAutoPilotGlobal(const LLVector3d &pos_global, const std::string& behavior_name = std::string(), const LLQuaternion *target_rotation = NULL, 
00440                                                                         void (*finish_callback)(BOOL, void *) = NULL, void *callback_data = NULL, F32 stop_distance = 0.f, F32 rotation_threshold = 0.03f);
00441 
00442         void                    startFollowPilot(const LLUUID &leader_id);
00443         void                    stopAutoPilot(BOOL user_cancel = FALSE);
00444         void                    setAutoPilotGlobal(const LLVector3d &pos_global);
00445         void                    autoPilot(F32 *delta_yaw);                      // autopilot walking action, angles in radians
00446         void                    renderAutoPilotTarget();
00447 
00448         //
00449         // teportation methods
00450         //
00451 
00452         // go to a named location home
00453         void teleportRequest(
00454                 const U64& region_handle,
00455                 const LLVector3& pos_local);
00456 
00457         // teleport to a landmark
00458         void teleportViaLandmark(const LLUUID& landmark_id);
00459 
00460         // go home
00461         void teleportHome()     { teleportViaLandmark(LLUUID::null); }
00462 
00463         // to an invited location
00464         void teleportViaLure(const LLUUID& lure_id, BOOL godlike);
00465 
00466         // to a global location - this will probably need to be
00467         // deprecated.
00468         void teleportViaLocation(const LLVector3d& pos_global); 
00469 
00470         // cancel the teleport, may or may not be allowed by server
00471         void teleportCancel();
00472 
00473         void                    setTargetVelocity(const LLVector3 &vel);
00474         const LLVector3 &getTargetVelocity() const;
00475 
00476         const std::string getTeleportSourceSLURL() const { return mTeleportSourceSLURL; }
00477 
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 EDoubleTapRunMode
00546         {
00547                 DOUBLETAP_NONE,
00548                 DOUBLETAP_FORWARD,
00549                 DOUBLETAP_BACKWARD,
00550                 DOUBLETAP_SLIDELEFT,
00551                 DOUBLETAP_SLIDERIGHT
00552         };
00553 
00554         enum ETeleportState
00555         {
00556                 TELEPORT_NONE = 0,                      // No teleport in progress
00557                 TELEPORT_START = 1,                     // Transition to REQUESTED.  Viewer has sent a TeleportRequest to the source simulator
00558                 TELEPORT_REQUESTED = 2,         // Waiting for source simulator to respond
00559                 TELEPORT_MOVING = 3,            // Viewer has received destination location from source simulator
00560                 TELEPORT_START_ARRIVAL = 4,     // Transition to ARRIVING.  Viewer has received avatar update, etc., from destination simulator
00561                 TELEPORT_ARRIVING = 5           // Make the user wait while content "pre-caches"
00562         };
00563 
00564         ETeleportState  getTeleportState() const                        { return mTeleportState; }
00565         void                    setTeleportState( ETeleportState state );
00566         const LLString& getTeleportMessage() const { return mTeleportMessage; }
00567         void setTeleportMessage(const LLString& message)
00568         {
00569                 mTeleportMessage = message;
00570         }
00571 
00572         // trigger random fidget animations
00573         void                    fidget();
00574 
00575         void                    requestEnterGodMode();
00576         void                    requestLeaveGodMode();
00577 
00578         void                    sendAgentSetAppearance();
00579 
00580         void                    sendAgentDataUpdateRequest();
00581 
00582         // Ventrella
00583         LLFollowCam mFollowCam;
00584         // end Ventrella 
00585 
00586         //--------------------------------------------------------------------
00587         // Wearables
00588         //--------------------------------------------------------------------
00589         BOOL                    getWearablesLoaded() const      { return mWearablesLoaded; }
00590 
00591         void                    setWearable( LLInventoryItem* new_item, LLWearable* wearable );
00592         static void             onSetWearableDialog( S32 option, void* userdata );
00593         void                    setWearableFinal( LLInventoryItem* new_item, LLWearable* new_wearable );
00594         void                    setWearableOutfit(      const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove );
00595         void                    queryWearableCache();
00596 
00597         BOOL                    isWearableModifiable(EWearableType type);
00598         BOOL                    isWearableCopyable(EWearableType type);
00599         BOOL                    needsReplacement(EWearableType wearableType, S32 remove);
00600         U32                             getWearablePermMask(EWearableType type);
00601 
00602         LLInventoryItem* getWearableInventoryItem(EWearableType type);
00603 
00604         LLWearable*             getWearable( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mWearable : NULL; }
00605         BOOL                    isWearingItem( const LLUUID& item_id );
00606         LLWearable*             getWearableFromWearableItem( const LLUUID& item_id );
00607         const LLUUID&   getWearableItem( EWearableType type ) { return (type < WT_COUNT) ? mWearableEntry[ type ].mItemID : LLUUID::null; }
00608 
00609         static EWearableType getTEWearableType( S32 te );
00610         static LLUUID   getDefaultTEImageID( S32 te );
00611         
00612         void                    copyWearableToInventory( EWearableType type );
00613 
00614         void                    makeNewOutfit(
00615                                                 const std::string& new_folder_name,
00616                                                 const LLDynamicArray<S32>& wearables_to_include,
00617                                                 const LLDynamicArray<S32>& attachments_to_include,
00618                                                 BOOL rename_clothing);
00619         void                    makeNewOutfitDone(S32 index);
00620 
00621         void                    removeWearable( EWearableType type );
00622         static void             onRemoveWearableDialog( S32 option, void* userdata );
00623         void                    removeWearableFinal( EWearableType type );
00624         
00625         void                    sendAgentWearablesUpdate();
00626 
00637         void addWearabletoAgentInventoryDone(
00638                 S32 index,
00639                 const LLUUID& item_id,
00640                 LLWearable* wearable);
00641         
00642         void                    saveWearableAs( EWearableType type, const std::string& new_name, BOOL save_in_lost_and_found );
00643         void                    saveWearable( EWearableType type, BOOL send_update = TRUE );
00644         void                    saveAllWearables();
00645         
00646         void                    revertWearable( EWearableType type );
00647         void                    revertAllWearables();
00648 
00649         void                    setWearableName( const LLUUID& item_id, const std::string& new_name );
00650         void                    createStandardWearables(BOOL female);
00651         void                    createStandardWearablesDone(S32 index);
00652         void                    createStandardWearablesAllDone();
00653 
00654         BOOL                    areWearablesLoaded() { return mWearablesLoaded; }
00655 
00656         void sendWalkRun(bool running);
00657 
00658         void observeFriends();
00659         void friendsChanged();
00660 
00661         // statics
00662         static void             stopFidget();
00663         static void             processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys, void** user_data);
00664         static void             userRemoveWearable( void* userdata );   // userdata is EWearableType
00665         static void             userRemoveAllClothes( void* userdata ); // userdata is NULL
00666         static void             userRemoveAllClothesStep2(BOOL proceed, void* userdata ); // userdata is NULL
00667         static void             userRemoveAllAttachments( void* userdata);      // userdata is NULL
00668         static BOOL             selfHasWearable( void* userdata );                      // userdata is EWearableType
00669 
00670         //debug methods
00671         static void             clearVisualParams(void *);
00672 
00673 protected:
00674         // stuff to do for any sort of teleport. Returns true if the
00675         // teleport can proceed.
00676         bool teleportCore(bool is_local = false);
00677 
00678         // helper function to prematurely age chat when agent is moving
00679         void ageChat();
00680 
00681         // internal wearable functions
00682         void                    sendAgentWearablesRequest();
00683         static void             onInitialWearableAssetArrived(LLWearable* wearable, void* userdata);
00684         void                    recoverMissingWearable(EWearableType type);
00685         void                    recoverMissingWearableDone();
00686         void                    addWearableToAgentInventory(LLPointer<LLInventoryCallback> cb,
00687                                                 LLWearable* wearable, const LLUUID& category_id = LLUUID::null,
00688                                                 BOOL notify = TRUE);
00689 public:
00690         // TODO: Make these private!
00691         LLUUID                  mSecureSessionID;                       // secure token for this login session
00692 
00693         F32                             mDrawDistance;
00694 
00695         U64                             mGroupPowers;
00696         BOOL                    mHideGroupTitle;
00697         char                    mGroupTitle[DB_GROUP_TITLE_BUF_SIZE];   /*Flawfinder: ignore*/  // honorific, like "Sir"
00698         char                    mGroupName[DB_GROUP_NAME_BUF_SIZE];     /*Flawfinder: ignore*/
00699         LLUUID                  mGroupID;
00700         //LLUUID                        mGroupInsigniaID;
00701         LLUUID                  mInventoryRootID;
00702         LLUUID                  mMapID;
00703         F64                             mMapOriginX;    // Global x coord of mMapID's bottom left corner.
00704         F64                             mMapOriginY;    // Global y coord of mMapID's bottom left corner.
00705         S32                             mMapWidth;      // Width of map in meters
00706         S32                             mMapHeight;     // Height of map in meters
00707         std::string             mMOTD;  // message of the day
00708 
00709         LLPointer<LLHUDEffectLookAt> mLookAt;
00710         LLPointer<LLHUDEffectPointAt> mPointAt;
00711 
00712         LLDynamicArray<LLGroupData> mGroups;
00713 
00714         BOOL                    mInitialized;
00715 
00716         static BOOL             sDebugDisplayTarget;
00717         S32                             mNumPendingQueries;
00718         S32*                    mActiveCacheQueries;
00719 
00720         BOOL                    mForceMouselook;
00721 
00722         static void parseTeleportMessages(const LLString& xml_filename);
00723         //we should really define ERROR and PROGRESS enums here
00724         //but I don't really feel like doing that, so I am just going
00725         //to expose the mappings....yup
00726         static std::map<LLString, LLString> sTeleportErrorMessages;
00727         static std::map<LLString, LLString> sTeleportProgressMessages;
00728 
00729         LLFrameTimer mDoubleTapRunTimer;
00730         EDoubleTapRunMode mDoubleTapRunMode;
00731 
00732 private:
00733         bool mbAlwaysRun; // should the avatar run by default rather than walk
00734         bool mbRunning; // is the avatar trying to run right now
00735 
00736         // Access or "maturity" level
00737         U8                              mAccess;        // SIM_ACCESS_MATURE or SIM_ACCESS_PG
00738         ETeleportState  mTeleportState;
00739         LLString                mTeleportMessage;
00740 
00741         S32                             mControlsTakenCount[TOTAL_CONTROLS];
00742         S32                             mControlsTakenPassedOnCount[TOTAL_CONTROLS];
00743 
00744         LLViewerRegion  *mRegionp;
00745         LLVector3d              mAgentOriginGlobal;                             // Origin of agent coords from global coords
00746         mutable LLVector3d mPositionGlobal;
00747 
00748         std::string             mTeleportSourceSLURL;                   // SLURL where last TP began.
00749 
00750         std::set<U64>   mRegionsVisited;                                // stat - what distinct regions has the avatar been to?
00751         F64                             mDistanceTraveled;                              // stat - how far has the avatar moved?
00752         LLVector3d              mLastPositionGlobal;                    // Used to calculate travel distance
00753 
00754         LLPointer<LLVOAvatar> mAvatarObject;                    // NULL until avatar object sent down from simulator
00755 
00756         U8                              mRenderState;                                   // Current behavior state of agent
00757         LLFrameTimer    mTypingTimer;
00758 
00759         ECameraMode             mCameraMode;                                    // target mode after transition animation is done
00760         ECameraMode             mLastCameraMode;
00761         BOOL                    mViewsPushed;                                   // keep track of whether or not we have pushed views.
00762 
00763         BOOL            mCustomAnim ;                   //current animation is ANIM_AGENT_CUSTOMIZE ?
00764         BOOL                    mShowAvatar;                                    // should we render the avatar?
00765         BOOL                    mCameraAnimating;                               // camera is transitioning from one mode to another
00766         LLVector3d              mAnimationCameraStartGlobal;    // camera start position, global coords
00767         LLVector3d              mAnimationFocusStartGlobal;             // camera focus point, global coords
00768         LLFrameTimer    mAnimationTimer;                                // seconds that transition animation has been active
00769         F32                             mAnimationDuration;                             // seconds
00770         F32                             mCameraFOVZoomFactor;                   // amount of fov zoom applied to camera when zeroing in on an object
00771         F32                             mCameraCurrentFOVZoomFactor;    // interpolated fov zoom
00772         F32                             mCameraFOVDefault;                              // default field of view that is basis for FOV zoom effect
00773         LLVector3d              mCameraFocusOffset;                             // offset from focus point in build mode
00774         LLVector3d              mCameraFocusOffsetTarget;               // target towards which we are lerping the camera's focus offset
00775         LLVector3               mCameraOffsetDefault;                   // default third-person camera offset
00776         LLVector4               mCameraCollidePlane;                    // colliding plane for camera
00777         F32                             mCurrentCameraDistance;                 // current camera offset from avatar
00778         F32                             mTargetCameraDistance;                  // target camera offset from avatar
00779         F32                             mCameraZoomFraction;                    // mousewheel driven fraction of zoom
00780         LLVector3               mCameraLag;                                             // third person camera lag
00781         LLVector3               mThirdPersonHeadOffset;                 // head offset for third person camera position
00782         LLVector3               mCameraPositionAgent;                   // camera position in agent coordinates
00783         LLVector3               mCameraVirtualPositionAgent;    // camera virtual position (target) before performing FOV zoom
00784         BOOL                    mSitCameraEnabled;                              // use provided camera information when sitting?
00785         LLVector3               mSitCameraPos;                                  // root relative camera pos when sitting
00786         LLVector3               mSitCameraFocus;                                // root relative camera target when sitting
00787         LLVector3d      mCameraSmoothingLastPositionGlobal;    
00788         LLVector3d      mCameraSmoothingLastPositionAgent;    
00789         
00790         //Ventrella
00791         LLVector3               mCameraUpVector;                                // camera's up direction in world coordinates (determines the 'roll' of the view)
00792         //End Ventrella
00793 
00794         LLPointer<LLViewerObject> mSitCameraReferenceObject;    // object to which camera is related when sitting
00795 
00796         BOOL                    mFocusOnAvatar;                                 
00797         LLVector3d              mFocusGlobal;
00798         LLVector3d              mFocusTargetGlobal;
00799         LLPointer<LLViewerObject>       mFocusObject;
00800         F32                             mFocusObjectDist;
00801         LLVector3               mFocusObjectOffset;
00802         F32                             mFocusDotRadius;                                // meters
00803         BOOL                    mTrackFocusObject;
00804         F32                             mUIOffset;
00805 
00806         LLCoordFrame    mFrameAgent;                                    // Agent position and view, agent-region coordinates
00807 
00808         BOOL                    mCrouching;
00809         BOOL                    mIsBusy;
00810 
00811         S32                     mAtKey;                                                 // Either 1, 0, or -1... indicates that movement-key is pressed
00812         S32                             mWalkKey;                                               // like AtKey, but causes less forward thrust
00813         S32                     mLeftKey;
00814         S32                             mUpKey;
00815         F32                             mYawKey;
00816         S32                             mPitchKey;
00817 
00818         F32                             mOrbitLeftKey;
00819         F32                             mOrbitRightKey;
00820         F32                             mOrbitUpKey;
00821         F32                             mOrbitDownKey;
00822         F32                             mOrbitInKey;
00823         F32                             mOrbitOutKey;
00824 
00825         F32                             mPanUpKey;                                              
00826         F32                             mPanDownKey;                                    
00827         F32                             mPanLeftKey;                                    
00828         F32                             mPanRightKey;                                   
00829         F32                             mPanInKey;
00830         F32                             mPanOutKey;
00831 
00832         U32                             mControlFlags;                                  // replacement for the mFooKey's
00833         BOOL                    mbFlagsDirty;
00834         BOOL                    mbFlagsNeedReset;                               // HACK for preventing incorrect flags sent when crossing region boundaries
00835 
00836         BOOL                    mbJump;
00837 
00838         BOOL                    mAutoPilot;
00839         BOOL                    mAutoPilotFlyOnStop;
00840         LLVector3d              mAutoPilotTargetGlobal;
00841         F32                             mAutoPilotStopDistance;
00842         BOOL                    mAutoPilotUseRotation;
00843         LLVector3               mAutoPilotTargetFacing;
00844         F32                             mAutoPilotTargetDist;
00845         S32                             mAutoPilotNoProgressFrameCount;
00846         F32                             mAutoPilotRotationThreshold;
00847         std::string             mAutoPilotBehaviorName;
00848         void                    (*mAutoPilotFinishedCallback)(BOOL, void *);
00849         void*                   mAutoPilotCallbackData;
00850         LLUUID                  mLeaderID;
00851 
00852         std::set<LLUUID> mProxyForAgents;
00853 
00854         LLColor4 mEffectColor;
00855 
00856         BOOL mHaveHomePosition;
00857         U64                             mHomeRegionHandle;
00858         LLVector3               mHomePosRegion;
00859         LLFrameTimer    mChatTimer;
00860         LLUUID                  mLastChatterID;
00861         F32                             mNearChatRadius;
00862         BOOL                    mAdminOverride;
00863 
00864         // See indra_constants.h for values.
00865         U8                              mGodLevel;
00866         LLFrameTimer    mFidgetTimer;
00867         LLFrameTimer    mFocusObjectFadeTimer;
00868         F32                             mNextFidgetTime;
00869         S32                             mCurrentFidget;
00870         BOOL                    mFirstLogin;
00871         BOOL                    mGenderChosen;
00872         
00873         //--------------------------------------------------------------------
00874         // Wearables
00875         //--------------------------------------------------------------------
00876         struct LLWearableEntry
00877         {
00878                 LLWearableEntry() : mItemID( LLUUID::null ), mWearable( NULL ) {}
00879 
00880                 LLUUID          mItemID;        // ID of the inventory item in the agent's inventory.
00881                 LLWearable*     mWearable;
00882         };
00883         LLWearableEntry mWearableEntry[ WT_COUNT ];
00884         U32                             mAgentWearablesUpdateSerialNum;
00885         BOOL                    mWearablesLoaded;
00886         S32                             mTextureCacheQueryID;
00887         U32                             mAppearanceSerialNum;
00888         LLAnimPauseRequest mPauseRequest;
00889 
00890         class createStandardWearablesAllDoneCallback : public LLRefCount
00891         {
00892         protected:
00893                 ~createStandardWearablesAllDoneCallback();
00894         };
00895         class sendAgentWearablesUpdateCallback : public LLRefCount
00896         {
00897         protected:
00898                 ~sendAgentWearablesUpdateCallback();
00899         };
00900 
00901         class addWearableToAgentInventoryCallback : public LLInventoryCallback
00902         {
00903         public:
00904                 enum {
00905                         CALL_NONE = 0,
00906                         CALL_UPDATE = 1,
00907                         CALL_RECOVERDONE = 2,
00908                         CALL_CREATESTANDARDDONE = 4,
00909                         CALL_MAKENEWOUTFITDONE = 8
00910                 } EType;
00911 
00922                 addWearableToAgentInventoryCallback(
00923                         LLPointer<LLRefCount> cb,
00924                         S32 index,
00925                         LLWearable* wearable,
00926                         U32 todo = CALL_NONE);
00927                 virtual void fire(const LLUUID& inv_item);
00928 
00929         private:
00930                 S32 mIndex;
00931                 LLWearable* mWearable;
00932                 U32 mTodo;
00933                 LLPointer<LLRefCount> mCB;
00934         };
00935 
00936         LLFriendObserver* mFriendObserver;
00937 };
00938 
00939 extern LLAgent gAgent;
00940 
00941 #endif

Generated on Fri May 16 08:33:14 2008 for SecondLife by  doxygen 1.5.5