viewer.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_VIEWER_H
00033 #define LL_VIEWER_H
00034 
00035 // DO NOT ADD DEPENDENCIES HERE
00036 // Almost every file in the viewer depends on this file.
00037 // If you need to add a shared class, put it in its own
00038 // little file. JC
00039 
00040 // *TODO: remove this, viewer.h doesn't need it, but there
00041 // are lots of .cpp files that depend on this recursive
00042 // dependency.
00043 #include "llviewercontrol.h"
00044 
00045 // Enabled this definition to compile a 'hacked' viewer that
00046 // allows a hacked godmode to be toggled on and off.
00047 #define TOGGLE_HACKED_GODLIKE_VIEWER 
00048 #ifdef TOGGLE_HACKED_GODLIKE_VIEWER
00049 extern BOOL gHackGodmode;
00050 #endif
00051 
00052 
00053 //
00054 // Forward Declarations
00055 //
00056 class LLAudioEngine;
00057 class LLFrameTimer;
00058 class LLMessageSystem;
00059 class LLHost;
00060 class LLPieMenu;
00061 class LLWorkerThread;
00062 class LLTextureFetch;
00063 class LLTextureCache;
00064 class LLPumpIO;
00065 class LLHTTPNode;
00066 class LLTimer;
00067 class LLUUID;
00068 class LLVector3;
00069 class LLVector3d;
00070 class LLViewerObject;
00071 class LLViewerRegion;
00072 class LLVFS;
00073 
00074 //
00075 // Global Variables
00076 //
00077 
00078 extern LLString gSecondLife;
00079 
00080 extern S32 gNumSessions;
00081 extern BOOL gNoRender;
00082 extern LLMemoryInfo gSysMemory;
00083 extern BOOL gLogMessages;
00084 extern BOOL gUseAudio;
00085 extern bool gPreloadImages;
00086 extern BOOL gGodConnect;
00087 extern LLString gCmdLineFirstName;
00088 extern LLString gCmdLineLastName;
00089 extern LLString gCmdLinePassword;
00090 extern BOOL gAutoLogin;
00091 extern U32 gFrameCount;
00092 extern U32 gForegroundFrameCount;
00093 extern BOOL gRequestInventoryLibrary;
00094 extern BOOL gAcceptTOS;
00095 extern BOOL gAcceptCriticalMessage;
00096 extern std::string gChannelName;
00097 extern LLUUID gInventoryLibraryOwner;
00098 extern LLUUID gInventoryLibraryRoot;
00099 extern BOOL gLastExecFroze;
00100 extern F32 gLogoutMaxTime;
00101 extern LLTimer gRenderStartTime;
00102 extern LLFrameTimer gForegroundTime;
00103 extern LLTimer gLogoutTimer;
00104 extern BOOL gInProductionGrid;
00105 extern S32 gCrashBehavior;
00106 extern bool gVerifySSLCert;
00107 extern const char* DEFAULT_SETTINGS_FILE;
00108 
00109 // TODO: Eliminate most of these, move into a globals structure.
00110 extern const U32 PATCH_SIZE;
00111 extern const LLVector3 DEFAULT_OBJECT_SCALE;
00112 extern BOOL             gDisconnected;
00113 extern BOOL             gDisableVoice;
00114 extern BOOL             gQuit;                                          // We're done, quit after processing this message.
00115 extern BOOL             gQuitRequested;                         // User wants to quit, may have modified documents open.
00116 extern BOOL             gLogoutRequestSent;                     // Disconnect message sent to simulator, no longer safe to send messages to the sim.
00117 extern BOOL             gInitializationComplete;        // OK to call display() and idle()
00118 extern BOOL             gUseWireframe;
00119 extern BOOL             gPurgeCache;                            // Cache was purged on startup
00120 extern U32              gSecondsPerDay;
00121 extern U32              gSecondsPerYear;
00122 // Is the Pacific time zone (aka server time zone)
00123 // currently in daylight savings time?
00124 extern BOOL gPacificDaylightTime;
00125 
00126 extern LLString gLastVersionChannel;
00127 
00128 extern LLVector3 gWindVec;
00129 extern LLVector3 gRelativeWindVec;
00130 
00131 extern U64      gFrameTime;                                     // The timestamp of the most-recently-processed frame
00132 extern F32              gFrameTimeSeconds;                      // Loses msec precision after ~4.5 hours...
00133 extern F32              gFrameIntervalSeconds;          // Elapsed time between current and previous gFrameTimeSeconds
00134 extern F32              gFPSClamped;                                            // Frames per second, smoothed, weighted toward last frame
00135 extern F32              gFrameDTClamped;
00136 extern U64              gStartTime;
00137 
00138 extern LLFrameTimer     gRestoreGLTimer;
00139 extern BOOL                     gRestoreGL;
00140 
00141 extern BOOL                     gDisplayCameraPos;
00142 extern BOOL                     gDisplayWindInfo;
00143 extern BOOL                     gDisplayNearestWater;
00144 extern BOOL                     gDisplayFOV;
00145 extern BOOL                     gForceRenderLandFence;
00146 
00147 extern BOOL                     gAllowIdleAFK;
00148 extern F32                      gAFKTimeout;
00149 extern BOOL                     gShowObjectUpdates;
00150 
00151 extern BOOL                     gTeleportDisplay;
00152 extern LLFrameTimer     gTeleportDisplayTimer;
00153 
00154 extern std::map<S32,LLFrameTimer> gDebugTimers;
00155 
00156 // VFS globals - gVFS is for general use
00157 // gStaticVFS is read-only and is shipped w/ the viewer
00158 // it has pre-cache data like the UI .TGAs
00159 extern LLVFS    *gStaticVFS;
00160 
00161 extern LLUUID   gViewerDigest;  // MD5 digest of the viewer's executable file.
00162 
00163 extern LLWorkerThread* gImageDecodeThread;
00164 extern LLTextureFetch* gTextureFetch;
00165 extern LLTextureCache* gTextureCache;
00166 
00167 extern LLPumpIO* gServicePump;
00168 
00169 extern LLUUID gSunTextureID;
00170 extern LLUUID gMoonTextureID;
00171 
00172 extern BOOL gHandleKeysAsync;
00173 
00174 // Map scale in pixels per region
00175 extern F32 gMapScale;
00176 extern F32 gMiniMapScale;
00177 
00178 extern F32 gMouseSensitivity;
00179 extern BOOL gInvertMouse;
00180 
00181 //
00182 // Defines and constants
00183 //
00184 
00185 const S32 AGENT_UPDATES_PER_SECOND  = 10;
00186 
00187 // Global because multiple functions need to identify the window
00188 // by its name.
00189 extern LLString gWindowTitle;
00190 extern LLString gDisabledMessage;
00191 extern BOOL gHideLinks;
00192 
00193 #define REGIONS_PER_LANDSCAPE_EDGE  3 
00194 #define NUMBER_OF_REGIONS       (REGIONS_PER_LANDSCAPE_EDGE             \
00195                                                         * REGIONS_PER_LANDSCAPE_EDGE)
00196 #define CENTER_REGION           ((REGIONS_PER_LANDSCAPE_EDGE / 2)       \
00197                                                         * REGIONS_PER_LANDSCAPE_EDGE            \
00198                                                         + REGIONS_PER_LANDSCAPE_EDGE / 2)
00199 
00200 
00201 // translates constant EAST, NORTH, WEST, etc. to x,y offsets
00202 // eg, EAST = +1, 0
00203 // eg, SOUTHWEST = -1, -1
00204 const S32 MAP_REGION_TO_X[NUMBER_OF_REGIONS - 1] =
00205 {
00206         1,      // east
00207         0,      // north
00208         -1,     // west
00209         0,      // south
00210         1,      // northeast
00211         -1,     // northwest
00212         -1,     // southwest
00213         1       // southeast
00214 };
00215 const S32 MAP_REGION_TO_Y[NUMBER_OF_REGIONS - 1] =
00216 {
00217         0,      // east
00218         1,      // north
00219         0,      // west
00220         -1,     // south
00221         1,      // northeast
00222         1,      // northwest
00223         -1,     // southwest
00224         -1      // southeast
00225 };
00226 
00227 const BOOL FOR_SELECTION = TRUE;
00228 const BOOL NOT_FOR_SELECTION = FALSE;
00229 
00230 const U8 YES_PHYSICS = 1;
00231 const U8 NO_PHYSICS = 0;
00232 
00233 //
00234 // Prototypes
00235 //
00236 void display(BOOL rebuild = TRUE, F32 zoom_factor = 1.f, int subfield = 0);
00237 void draw_axes();
00238 
00239 void fire_shot(const U8 shot_type, const U8 use_physics );
00240 void add_object(LLPCode pcode, 
00241                                 U8 use_physics, 
00242                                 const LLVector3d &object_pos_global, 
00243                                 const LLQuaternion &rotation, 
00244                                 const LLVector3 &scale, 
00245                                 const LLVector3 &velocity,
00246                                 const LLVector3 &angular_velocity);
00247 
00248 BOOL add_object(LLPCode pcode, S32 screen_x, S32 screen_y, U8 use_physics);
00249 
00250 void idle();
00251 void idle_network();
00252 void init_audio();
00253 void init_textures();
00254 void init_landscape();
00255 void keyboard(char key);
00256 void keyboard_windows(char key);
00257 void kill_all_trees();
00258 void move_sun();
00259 BOOL raycast_for_new_obj_pos( S32 x, S32 y, LLViewerObject** hit_obj, S32* hit_face, BOOL* b_hit_land, LLVector3* ray_start_region, LLVector3* ray_end_region, LLViewerRegion** region );
00260 
00261 void audio_update_volume(bool force_update = true);
00262 void audio_update_listener();
00263 void audio_update_wind(bool force_update = true);
00264 
00265 // Saves the final snapshot, but only once.
00266 void save_final_snapshot(void*);
00267 
00268 // Call when user is requesting application to quit, ask for confirmation.
00269 void app_user_quit();
00270 
00271 // Call when user is requesting application to quit.
00272 void app_request_quit();
00273 
00274 // Call when user aborts the quit, for example, canceling a required save of 
00275 // dirty document.
00276 void app_abort_quit();
00277 
00278 // Call if you need to quit immediately.  You can optionally
00279 // spawn a web page or open another application.
00280 void app_force_quit(const char* launch_file_on_quit = NULL);
00281 
00282 // Display an error dialog and forcibly quit.
00283 void app_early_exit(const LLString& message);
00284 
00285 // exit() immediately (after some cleanup)
00286 void app_force_exit(S32 arg);
00287 
00288 void do_disconnect(const LLString& message);
00289 void send_logout_request();
00290 void save_avatar(void*);
00291 
00292 void set_view(S32 which);
00293 
00294 void user_logout();
00295 
00296 F32 mouse_x_from_center(S32 x);
00297 F32 mouse_y_from_center(S32 x);
00298 
00299 void print_agent_nvpairs(void*);
00300 void reload_viewer(void);
00301 void reset_statistics();
00302 void output_statistics(void*);
00303 void write_debug(const char *str);
00304 void write_debug(const std::string& str);
00305 void login_alert_done(S32 option, void* user_data);
00306 void callback_cache_name(const LLUUID& id, const char* firstname, const char* lastname, BOOL is_group, void* data);
00307 void load_name_cache();
00308 void remove_marker_file();
00309 
00310 // Avoid including llagent.h everywhere.  This returns gAgent.getID().
00311 const LLUUID& agent_get_id();
00312 const LLUUID& agent_get_session_id();
00313 void agent_send_reliable_message();
00314 
00315 // Helpers for URIs
00316 const std::vector<std::string>& getLoginURIs();
00317 const std::string& getHelperURI();
00318 void resetURIs();
00319 
00320 void load_region_name_cache();
00321 void save_region_name_cache();
00322 
00323 
00324 
00325 #if LL_WINDOWS
00326 class llLCD;
00327 extern llLCD    *gLcdScreen; 
00328 #endif
00329 
00330 #endif

Generated on Thu Jul 1 06:10:03 2010 for Second Life Viewer by  doxygen 1.4.7