llworldmap.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLWORLDMAP_H
00033 #define LL_LLWORLDMAP_H
00034 
00035 #include <map>
00036 #include <string>
00037 #include <vector>
00038 
00039 #include "v3math.h"
00040 #include "v3dmath.h"
00041 #include "llframetimer.h"
00042 #include "llmapimagetype.h"
00043 #include "lluuid.h"
00044 #include "llmemory.h"
00045 #include "llviewerimage.h"
00046 #include "lleventinfo.h"
00047 #include "v3color.h"
00048 
00049 class LLMessageSystem;
00050 
00051 
00052 class LLItemInfo
00053 {
00054 public:
00055         LLItemInfo(F32 global_x, F32 global_y, const std::string& name, LLUUID id, S32 extra = 0, S32 extra2 = 0);
00056 
00057         std::string mName;
00058         std::string mToolTip;
00059         LLVector3d      mPosGlobal;
00060         LLUUID          mID;
00061         BOOL            mSelected;
00062         S32                     mExtra;
00063         S32                     mExtra2;
00064         U64                     mRegionHandle;
00065 };
00066 
00067 #define MAP_SIM_IMAGE_TYPES 3
00068 // 0 - Prim
00069 // 1 - Terrain Only
00070 // 2 - Overlay: Land For Sale
00071 
00072 class LLSimInfo
00073 {
00074 public:
00075         LLSimInfo();
00076 
00077         LLVector3d getGlobalPos(LLVector3 local_pos) const;
00078 
00079 public:
00080         U64 mHandle;
00081         std::string mName;
00082 
00083         F64 mAgentsUpdateTime;
00084         BOOL mShowAgentLocations;       // are agents visible?
00085 
00086         U8 mAccess;
00087         U32 mRegionFlags;
00088         F32 mWaterHeight;
00089 
00090         F32 mAlpha;
00091 
00092         // Image ID for the current overlay mode.
00093         LLUUID mMapImageID[MAP_SIM_IMAGE_TYPES];
00094 
00095         // Hold a reference to the currently displayed image.
00096         LLPointer<LLViewerImage> mCurrentImage;
00097         LLPointer<LLViewerImage> mOverlayImage;
00098 };
00099 
00100 #define MAP_BLOCK_RES 256
00101 
00102 struct LLWorldMapLayer
00103 {
00104         BOOL LayerDefined;
00105         LLPointer<LLViewerImage> LayerImage;
00106         LLUUID LayerImageID;
00107         LLRect LayerExtents;
00108 
00109         LLWorldMapLayer() : LayerDefined(FALSE) { }
00110 };
00111 
00112 
00113 class LLWorldMap
00114 {
00115 public:
00116         typedef void(*url_callback_t)(U64 region_handle, const std::string& url, const LLUUID& snapshot_id, bool teleport);
00117 
00118         LLWorldMap();
00119         ~LLWorldMap();
00120 
00121         // clears the list
00122         void reset();
00123 
00124         // clear the visible items
00125         void eraseItems();
00126 
00127         // Removes references to cached images
00128         void clearImageRefs();
00129 
00130         // Clears the flags indicating that we've received sim infos
00131         // Causes a re-request of the sim info without erasing extisting info
00132         void clearSimFlags();
00133 
00134         // Returns simulator information, or NULL if out of range
00135         LLSimInfo* simInfoFromHandle(const U64 handle);
00136 
00137         // Returns simulator information, or NULL if out of range
00138         LLSimInfo* simInfoFromPosGlobal(const LLVector3d& pos_global);
00139 
00140         // Returns simulator information for named sim, or NULL if non-existent
00141         LLSimInfo* simInfoFromName(const LLString& sim_name);
00142 
00143         // Gets simulator name for a global position, returns true if it was found
00144         bool simNameFromPosGlobal(const LLVector3d& pos_global, LLString & outSimName );
00145 
00146         // Sets the current layer
00147         void setCurrentLayer(S32 layer, bool request_layer = false);
00148 
00149         void sendMapLayerRequest();
00150         void sendMapBlockRequest(U16 min_x, U16 min_y, U16 max_x, U16 max_y, bool return_nonexistent = false);
00151         void sendNamedRegionRequest(std::string region_name);
00152         void sendNamedRegionRequest(std::string region_name, 
00153                 url_callback_t callback,
00154                 const std::string& callback_url,
00155                 bool teleport);
00156         void sendItemRequest(U32 type, U64 handle = 0);
00157 
00158         static void processMapLayerReply(LLMessageSystem*, void**);
00159         static void processMapBlockReply(LLMessageSystem*, void**);
00160         static void processMapItemReply(LLMessageSystem*, void**);
00161 
00162         void dump();
00163 
00164         // Extend the bounding box of the list of simulators. Returns true
00165         // if the extents changed.
00166         BOOL extendAABB(U32 x_min, U32 y_min, U32 x_max, U32 y_max);
00167 
00168         // build coverage maps for telehub region visualization
00169         void updateTelehubCoverage();
00170         BOOL coveredByTelehub(LLSimInfo* infop);
00171 
00172         // Bounds of the world, in meters
00173         U32 getWorldWidth() const;
00174         U32 getWorldHeight() const;
00175 public:
00176         // Map from region-handle to simulator info
00177         typedef std::map<U64, LLSimInfo*> sim_info_map_t;
00178         sim_info_map_t mSimInfoMap;
00179 
00180         BOOL                    mIsTrackingUnknownLocation, mInvalidLocation, mIsTrackingDoubleClick, mIsTrackingCommit;
00181         LLVector3d              mUnknownLocation;
00182 
00183         bool mRequestLandForSale;
00184 
00185         typedef std::vector<LLItemInfo> item_info_list_t;
00186         item_info_list_t mTelehubs;
00187         item_info_list_t mInfohubs;
00188         item_info_list_t mPGEvents;
00189         item_info_list_t mMatureEvents;
00190         item_info_list_t mPopular;
00191         item_info_list_t mLandForSale;
00192         item_info_list_t mClassifieds;
00193 
00194         std::map<U64,S32> mNumAgents;
00195 
00196         typedef std::map<U64, item_info_list_t> agent_list_map_t;
00197         agent_list_map_t mAgentLocationsMap;
00198         
00199         std::vector<LLWorldMapLayer>    mMapLayers[MAP_SIM_IMAGE_TYPES];
00200         BOOL                                                    mMapLoaded[MAP_SIM_IMAGE_TYPES];
00201         BOOL *                                                  mMapBlockLoaded[MAP_SIM_IMAGE_TYPES];
00202         S32                                                             mCurrentMap;
00203 
00204         // AABB of the list of simulators
00205         U32             mMinX;
00206         U32             mMaxX;
00207         U32             mMinY;
00208         U32             mMaxY;
00209 
00210         U8*             mNeighborMap;
00211         U8*             mTelehubCoverageMap;
00212         S32             mNeighborMapWidth;
00213         S32             mNeighborMapHeight;
00214 
00215 private:
00216         LLTimer mRequestTimer;
00217 
00218         // search for named region for url processing
00219         std::string mSLURLRegionName;
00220         std::string mSLURL;
00221         url_callback_t mSLURLCallback;
00222         bool mSLURLTeleport;
00223 };
00224 
00225 extern LLWorldMap* gWorldMap;
00226 
00227 #endif

Generated on Thu Jul 1 06:09:47 2010 for Second Life Viewer by  doxygen 1.4.7