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 : public LLSingleton<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 sendHandleRegionRequest(U64 region_handle, 
00157                 url_callback_t callback,
00158                 const std::string& callback_url,
00159                 bool teleport);
00160         void sendItemRequest(U32 type, U64 handle = 0);
00161 
00162         static void processMapLayerReply(LLMessageSystem*, void**);
00163         static void processMapBlockReply(LLMessageSystem*, void**);
00164         static void processMapItemReply(LLMessageSystem*, void**);
00165 
00166         void dump();
00167 
00168         // Extend the bounding box of the list of simulators. Returns true
00169         // if the extents changed.
00170         BOOL extendAABB(U32 x_min, U32 y_min, U32 x_max, U32 y_max);
00171 
00172         // build coverage maps for telehub region visualization
00173         void updateTelehubCoverage();
00174         BOOL coveredByTelehub(LLSimInfo* infop);
00175 
00176         // Bounds of the world, in meters
00177         U32 getWorldWidth() const;
00178         U32 getWorldHeight() const;
00179 public:
00180         // Map from region-handle to simulator info
00181         typedef std::map<U64, LLSimInfo*> sim_info_map_t;
00182         sim_info_map_t mSimInfoMap;
00183 
00184         BOOL                    mIsTrackingUnknownLocation, mInvalidLocation, mIsTrackingDoubleClick, mIsTrackingCommit;
00185         LLVector3d              mUnknownLocation;
00186 
00187         bool mRequestLandForSale;
00188 
00189         typedef std::vector<LLItemInfo> item_info_list_t;
00190         item_info_list_t mTelehubs;
00191         item_info_list_t mInfohubs;
00192         item_info_list_t mPGEvents;
00193         item_info_list_t mMatureEvents;
00194         item_info_list_t mLandForSale;
00195         item_info_list_t mClassifieds;
00196 
00197         std::map<U64,S32> mNumAgents;
00198 
00199         typedef std::map<U64, item_info_list_t> agent_list_map_t;
00200         agent_list_map_t mAgentLocationsMap;
00201         
00202         std::vector<LLWorldMapLayer>    mMapLayers[MAP_SIM_IMAGE_TYPES];
00203         BOOL                                                    mMapLoaded[MAP_SIM_IMAGE_TYPES];
00204         BOOL *                                                  mMapBlockLoaded[MAP_SIM_IMAGE_TYPES];
00205         S32                                                             mCurrentMap;
00206 
00207         // AABB of the list of simulators
00208         U32             mMinX;
00209         U32             mMaxX;
00210         U32             mMinY;
00211         U32             mMaxY;
00212 
00213         U8*             mNeighborMap;
00214         U8*             mTelehubCoverageMap;
00215         S32             mNeighborMapWidth;
00216         S32             mNeighborMapHeight;
00217 
00218 private:
00219         LLTimer mRequestTimer;
00220 
00221         // search for named region for url processing
00222         std::string mSLURLRegionName;
00223         U64 mSLURLRegionHandle;
00224         std::string mSLURL;
00225         url_callback_t mSLURLCallback;
00226         bool mSLURLTeleport;
00227 };
00228 
00229 #endif

Generated on Fri May 16 08:34:26 2008 for SecondLife by  doxygen 1.5.5