00001
00009 #ifndef IS3DENGINE_H
00010 #define IS3DENGINE_H
00011
00012 #include "IS3DCommon.H"
00013 #include "ISApp.H"
00014 #include "ClusterSync.H"
00015 #include "DebugDraw.H"
00016
00017 namespace IS3D {
00018
00021 #define RD IS3DEngine::getRenderDevice()
00022
00024 #define LOG IS3DEngine::getDebugLog()
00025
00028 #define DBG IS3DEngine::getDebugDraw()
00029
00030
00031 typedef ReferenceCountedPointer<class ClockSyncListener> ClockSyncListenerRef;
00032
00033
00034 class IS3DEngine
00035 {
00036 public:
00037
00038 enum LightType { NOLIGHT, DIRECTIONAL, POINT, SPOT };
00039
00041 static void init(int argc, char **argv);
00042
00045 static void run(ISApp *app);
00046
00047
00050 static void createLog(std::string filename=std::string("log.txt"));
00051
00060 static void loadConfigsFromArguments(int argc, char **argv,
00061 bool exitOnUnrecognizedArgument=true);
00062 static void showHelpAndExit(const std::string &programName);
00063
00065 static void setHeadFrame(CoordinateFrame m) {
00066 if (!_headLocked)
00067 _head = m;
00068 }
00069 static CoordinateFrame getHeadFrame() { return _head; }
00070 static Vector3 getHeadPos() { return _head.translation; }
00071 static CoordinateFrame getLeftEyeFrame();
00072 static Vector3 getLeftEyePos();
00073 static CoordinateFrame getRightEyeFrame();
00074 static Vector3 getRightEyePos();
00075
00077 static void lockHeadFrame() { _headLocked = true; }
00079 static void unlockHeadFrame() { _headLocked = false; }
00080
00083 static CoordinateFrame getCameraFrame() { return _head; }
00084 static Vector3 getCameraPos() { return _head.translation; }
00085
00089 static double getSynchronizedTime();
00090
00091
00092 static void setSynchronizedTime(double t) { _synchronizedTime = t; }
00093
00094
00096 static RenderDevice* getRenderDevice() { return _renderDevice; }
00097 static Log* getDebugLog() { return _debugLog; }
00098 static VARAreaRef getVarDynamic() { return _varDynamic; }
00099 static VARAreaRef getVarStatic() { return _varStatic; }
00100 static GFontRef getFont();
00101
00102 static DebugDrawRef getDebugDraw();
00103
00105 static void setIOD(double iod) { _iod = iod; }
00106 static double getIOD() { return _iod; }
00107
00108 static void toggleStereo() {
00109
00110 if (_iod==0)
00111 _iod=2.5/12.0;
00112 else
00113 _iod=0;
00114 }
00115
00117 static Vector3 getDisplayTopLeft() { return _topl; }
00118 static Vector3 getDisplayTopRight() { return _topr; }
00119 static Vector3 getDisplayBottomLeft() { return _botl; }
00120 static Vector3 getDisplayBottomRight() { return _botr; }
00121
00122 static Vector3 getUpVector() { return (_topl - _botl).unit(); }
00123 static Vector3 getForwardVector() {
00124 return cross((_topl-_botl), (_botr-_botl)).unit();
00125 }
00126
00128 static int getDisplayHeightPixels() { return _h; }
00129 static int getDisplayWidthPixels() { return _w; }
00130
00132 static int getMaxScreenWidth();
00133 static int getMaxScreenHeight();
00134
00136 static long getFrameCount() { return _frameCount; }
00137
00140 static std::string getG3DDataDir();
00141
00147 static std::string getIS3DDataDir();
00148
00150 static void quit();
00151
00153 static void runloop();
00154
00155 static int argc() { return _argc; }
00156 static char** argv() { return _argv; }
00157
00158
00159
00160 static void printVARInfo();
00161
00162 static void resetClippingPlanes(double nclip, double fclip);
00163
00164 static double getFarClip() { return _farclip; };
00165 static double getNearClip() { return _nearclip; };
00166
00167 static bool isLightOn( int i );
00168 static void turnLightOff( int i );
00169 static void turnLightOn( int i );
00170 static void setLightPosition(int i, const Vector3 &pos);
00171 static void setLightColor( int i, const Color3& c );
00172 static Color3 getLightColor( int i );
00173 static Vector4 getLightVector( int i );
00174 static bool isValidLightIndex( int i );
00175 static GLight getLight( int i );
00176
00177
00178 static bool isRunningOnDesktop();
00179 static bool isRunningInCluster();
00180 static bool isFullScreen();
00181
00182 static int getClusterNodeID();
00183
00184 private:
00185
00187 static void readDisplaySettings();
00188
00193 static void readLightingSettings();
00194
00196 static void setProjection(const CoordinateFrame &eye2room);
00197
00199 static void processInput();
00200
00201 static void pollWindowInput();
00202 static void sendKbdEvent(const std::string &keyname, const bool down);
00203 static std::string getKeyName(GKey::Value key, GKeyMod mod);
00204 static void mousemotion(const int x, const int y);
00205
00208 static void isInit();
00209
00214 static void isGLContextInit();
00215
00216 static ISApp* _app;
00217 static CoordinateFrame _head;
00218 static double _iod;
00219 static bool _quit;
00220 static long _frameCount;
00221 static Vector3 _topl, _topr, _botl, _botr;
00222 static int _h, _w;
00223 static bool _fullscreen;
00224 static int _xpos, _ypos;
00225 static bool _stereo;
00226 static double _nearclip;
00227 static double _farclip;
00228 static CoordinateFrame _room2tile;
00229 static double _halftilew;
00230 static double _halftileh;
00231 static RenderDevice *_renderDevice;
00232 static Log *_debugLog;
00233 static VARAreaRef _varDynamic;
00234 static VARAreaRef _varStatic;
00235 static Vector2 _curMousePos;
00236 static bool _headLocked;
00237 static LightType* _lightTypes;
00238 static GLight* _lightInfoArray;
00239 static GWindow* _gwindow;
00240 static ClusterSyncClient *_clusterSyncClient;
00241 static double _synchronizedTime;
00242 static ClockSyncListenerRef _clockSyncListener;
00243 static bool _runningInCluster;
00244 static double _localClockStartTime;
00245 static GFontRef _font;
00246 static DebugDrawRef _debugDraw;
00247 static int _clusterNodeID;
00248 static int _argc;
00249 static char **_argv;
00250 };
00251
00252 }
00253
00254
00255 #endif