Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

controlEngine.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
00017 *********************************************************************************** */
00018 
00023 #ifndef INCLUDE_CONTROL_ENGINE_H
00024 #define INCLUDE_CONTROL_ENGINE_H
00025 
00026 #include "3d.h"
00027 
00028 #include "texture.h"
00029 #include "box.h"
00030 #include "fog.h"
00031 #include "light.h"
00032 #include "region.h"
00033 #include "polygonMode.h"
00034 
00035 #include "openGL_tools.h"
00036 #include "windowTools.h"
00037 #include "primitive.h"
00038 
00039 #include "control.h"
00040 #include "univers.h"
00041 #include "taskWindow.h"
00042 #include "picking.h"
00043 
00044 #include "perfMon.h"
00045 #include "screen.h"
00046 
00047 #include "masterContainer.h"
00048 #include "cursor.h"
00049 #include "tip.h"
00050 
00051 #include "resource.h"
00052 
00053 #define DEFAULT_DOUBLE_CLICK    0.25    // timeout du DblClk pour les touches
00054 #define SEUIL_MIN_INERTIA               5
00055 #define SEUIL_MAX_INERTIA               15
00056 
00057 // config par default (sauvé dans la registry)
00058 #define DEFAULT_LIGHT_MOVE0             FALSE
00059 #define DEFAULT_LIGHT_MOVE1             FALSE
00060 #define DEFAULT_LIGHT_MOVE2             FALSE
00061 #define DEFAULT_LIGHT_ENABLE0   FALSE
00062 #define DEFAULT_LIGHT_ENABLE1   FALSE 
00063 #define DEFAULT_LIGHT_ENABLE2   TRUE
00064 #define DEFAULT_FOG_ENABLE              FALSE
00065 #define DEFAULT_FOG_START               4.5f
00066 #define DEFAULT_FOG_END                 6.0f
00067 #define DEFAULT_FOG_DENSITY             0.3f
00068 #define DEFAULT_FOG_MODE                fogLinear
00069 #define DEFAULT_ANTIALIASING    FALSE
00070 #define DEFAULT_ANTIALIASING_QUALITY    4 // 4 points
00071 #define DEFAULT_VIEW_REPERE             FALSE
00072 #define DEFAULT_VIEW_LIGHT              FALSE
00073 #define DEFAULT_PICKING                 TRUE
00074 #define DEFAULT_DELTA                   FALSE
00075 #define DEFAULT_VIEW_BACKGROUND TRUE
00076 #define DEFAULT_VIEW_FPS                FALSE
00077 #define DEFAULT_INERTIA                 FALSE
00078 #define DEFAULT_MONITOR                 FALSE
00079 #define DEFAULT_VIEW_INERTIA    TRUE
00080 #define DEFAULT_FULLSCREEN              TRUE
00081 #define DEFAULT_TITLED                  TRUE
00082 #define DEFAULT_VIEW_REGION             FALSE
00083 #define DEFAULT_POLYGON_BACK    fill
00084 #define DEFAULT_POLYGON_FRONT   fill
00085 #define DEFAULT_XSIZE                   500
00086 #define DEFAULT_YSIZE                   400
00087 #define DEFAULT_TIMER_REFRESH   30
00088 #define DEFAULT_CPU_LIMIT               100
00089 
00090 // init de la freetype
00091 int FTLibraryInit ();
00092 void FTLibraryFree ();
00093 
00094 typedef enum 
00095 { 
00096         ssRGB,ssDepth,ssBlending,ssLuminance
00097 } TypeScreenShot;
00098 
00099 LRESULT CALLBACK ControlEngineProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
00100 
00102 typedef struct
00103 {
00104         Texture background;
00105         Texture plus;
00106         Texture minus;
00107         Texture min;
00108         Texture max;
00109         Texture maxAlternate;
00110         Texture rotateFace;
00111         Texture close;
00112         Texture tropique;
00113         Texture arrow;
00114         Texture arrowOblique;
00115         Texture degradeeFocus;
00116         Texture degradeeUnFocus;
00117         Texture iconBase;
00118         Texture cursorArrow;
00119         Texture cursorWait;
00120         Texture cursorText;
00121         Texture cursorMoving;
00122         Texture cursorPush;     
00123         Texture grip;
00124 } Textures ;
00125 
00131 class ControlEngine : public has_slots<>
00132 {
00133 private:
00134         MyStack<Control *> stack;       
00135 
00136 public: // variable de class
00137         PerfMonitor monitor;            
00138         Primitive primitive;            
00139         MyTree<Face> trash;                     
00140         Fog fog;                                        
00141         Light lights[4];                        
00142         BOOL enableAntiAliasing;        
00143         int antiAliasingQuality;        
00144         BOOL enableCursor ;                     
00145         BOOL enableRepere;                      
00146         BOOL enableLightView;           
00147         BOOL enableFPS;                         
00148         Tip *tipFPS;                            
00149         Cursor cursor;                          
00150         BOOL enableInertia;                     
00151         BOOL enableViewInertia;         
00152         PolygonMode polygonMode;        
00153         Box3D boxLights[3];                     
00154         GLdouble aspect;                        
00155 
00156         // Handle       
00157         Screen screenMain;                      
00158         Screen screenSystray;           
00159         Screen screenConfig;            
00160         HINSTANCE hInst;                        
00161         double dxWin;                           
00162         double dyWin;                           
00163         int cpuLimit;                           
00164 
00165         // pour la gestion des region (cf.: CreatePolyPolygonRgn)
00166         GLdouble projMatrix[16];        
00167         GLdouble modelMatrix[16];       
00168         GLint viewPort[4];                      
00169         int     refreshTime;                    
00170         #define deltaXwin viewPort[2]
00171         #define deltaYwin viewPort[3]
00172         BOOL enablePicking;                     
00173         BOOL enableDelta;                       
00174         BOOL enableBackGround;          
00175         GLdouble depth;                         
00176         BOOL lightsMove[4];                     
00177         Timer timerRefresh;                     
00178         Univers *univers;                       
00179         TaskWindow *taskWindow;         
00180         MasterContainer *masterContainer; 
00181         StateKey key;                           
00182         Picking pickingCursor;          
00183         Picking pickingInertia;         
00184         int usingInertia;                       
00185         EventInertia eventInertia[3];
00186 
00187         // gestion des fonte
00188         FTFont *fontPixmap;                     
00189         FTFont *fontTexture;            
00190         FTFont *fontExtrude;            
00191         FTFont *fontOutline;            
00192         FTFont *fontPolygon;            
00193         FTFont *fontBitmap;                     
00194 
00195         Textures texture;                       
00196 
00197 public:
00198         ControlEngine();
00199         ~ControlEngine();
00200         void Start(HINSTANCE hInstance);
00201         void Stop();
00202         void Loop();
00203         void InitViewPort(int deltaX,int deltaY);
00204         void Setup(int deltaX, int deltaY);
00205         void Refresh(BOOL setSize);
00206         void SetTimerRefresh(int value); // 10 au plus rapide 60 ==> 15Frm/s 30 ==> 30Frm/s 40 ==> 21Frm/s
00207         int      OnRefresh(Timer *timer);
00208 
00209         BOOL Push(Control *control);
00210         Control * Pop();
00211         Control * Peek();
00212 
00213         void InitMonitor();
00214         BOOL InitFont();
00215         void InitTextures();
00216         void InitLights();
00217         void EndFont();
00218 
00219         void Draw();
00220         BOOL DrawBackGround();
00221         void DrawScene(BOOL isPicking);
00222         void DrawLight();
00223         void DrawCursors();
00224         void DrawCursor(Point2D<int> pos,Color color,BOOL isDrawInertia);
00225         void Draw2DText(int xCenter,int yCenter,int x,int y,char *text,Color *color=NULL); // if !color ==> black
00226         BOOL DrawOrigineRepere();
00227         BOOL DrawFPS();
00228 
00229         void MajLights();
00230 
00231         float GiveFPS();
00232 
00233         void SetPerspective(float xJitter,float yJiiter);
00234         void ApplyScaleView();
00235 
00236         BOOL RegionAdd(double x,double y);
00237         BOOL RegionGet(double x,double y,Point3D<double> *pt);
00238 
00239         LRESULT Proc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam);
00240 
00241         void ScreenShot(TypeScreenShot type);
00242 
00243         double ComputeRealZ(double logicZ);
00244         BOOL ProjectWindowToObject(Point3D<GLdouble> &windowPos,Point3D<GLdouble> *objectPos);
00245         BOOL ProjectWindowToObject(GLdouble windowPosX,GLdouble windowPosY,GLdouble windowPosZ,GLdouble *objectPosX,GLdouble *objectPosY,GLdouble *objectPosZ); 
00246         BOOL ProjectObjectToWindow(Point3D<GLdouble> &objectPos,Point3D<GLdouble> *windowPos);
00247         BOOL ProjectObjectToWindow(GLdouble objectPosX,GLdouble objectPosY,GLdouble objectPosZ,GLdouble *windowPosX,GLdouble *windowPosY,GLdouble *windowPosZ);
00248 };
00249 
00250 #endif

Generated on Fri Aug 20 19:19:44 2004 for 3d Controls by doxygen 1.3.6