00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MSL_RENDERGL_H
00023 #define MSL_RENDERGL_H
00024
00025
00026
00027 #include "../../configs/configGLUT.h"
00028 #include "../../configs/configGL.h"
00029
00030
00031
00032
00033
00034 #include "render.h"
00035 #include "triangle.h"
00036 #include "renderglobj.h"
00037 #include "vector.h"
00038 #include "defs.h"
00039 #include "util.h"
00040 #include "mslio.h"
00041
00043 class RenderGL: public Render
00044 {
00045 protected:
00046 vector<int> EnvIndex;
00047 vector<int> BodyIndex;
00048
00049 float WindowX, WindowY, WindowZ;
00050
00051 float BoundingBoxMin[3];
00052 float BoundingBoxMax[3];
00053
00054 float Orientation[3];
00055 float Position[3];
00056
00057
00058 float Fov, AspectRatio, Near, Far;
00059 float EyeX, EyeY, EyeZ;
00060 float VpX, VpY, VpZ;
00061 float VupX, VupY, VupZ;
00062 float ViewLength;
00063
00064
00065 MSLVector VCoordZ, VCoordY, VCoordX;
00066 MSLVector VRpy;
00067
00068 MSLVector DefVCoordZ, DefVCoordY, DefVCoordX;
00069 MSLVector DefVRpy;
00070
00071 MSLVector RpyModification;
00072
00073
00074 MSLVector SCoordZ, SCoordY, SCoordX;
00075
00076
00077 float LightPosX, LightPosY, LightPosZ;
00078
00079
00080 int NumberOfObject;
00081 int NumberOfBody;
00082 int NumberOfEnvObj;
00083
00084
00085 mslGLObject ** SceneBodyLib;
00086 mslGLObject ** SceneEnvObjLib;
00087
00088
00089 MSLVector EnvTransform;
00090 MSLVector BodyTransform;
00091
00092
00093 int MainWindow;
00094
00095
00096 int SelectObjectID;
00097 int CurrentObject;
00098
00099
00100 int CurrentMouseButton, CurrentMouseState;
00101 int CurrentKeyboard;
00102 float LastX, LastY;
00103 float ChangeRate;
00104 float AnimationTimeScaleTmp;
00105
00106
00107 void LoadConfig();
00108
00109
00110 void AddBodyObject(mslGLObject * obj);
00111 void AddEnvObject(mslGLObject * obj);
00112
00113
00114 mslGLObject* WhichObject(int id);
00115 void SceneRender();
00116
00117
00118 void SetLightPos();
00119
00120
00121 void SetSceneOrientationChange(const MSLVector& oric);
00122 void SetScenePositionChange(const MSLVector& posc);
00123
00124
00125 void SetBodyState(const MSLVector& state);
00126 void SetEnvState(const MSLVector& state);
00127
00128
00129 void DrawBoundingBox();
00130
00131 void DrawPath();
00132
00133 void InitData();
00134 void InitGeometry(list<MSLTriangle> triangles);
00135 void DrawBodies(const MSLVector &x);
00136 void DrawEnv();
00137 void NormCrossProduct(float v1[3], float v2[3], float out[3]);
00138 void Normalize(float v[3]);
00139
00140 void ShowCoordinateFrame();
00141
00142 public:
00143 Gui *G;
00144
00145 RenderGL();
00146 RenderGL(string filepath);
00147 RenderGL(Scene *s, string filepath);
00148 virtual ~RenderGL();
00149
00150
00151 virtual void Reset();
00152
00153 virtual void Init();
00154 virtual void MainLoop(Gui *g);
00155
00156 static void GlutIdleProcessing();
00157 static void GlutDrawEnvironment();
00158 static void GlutReshape(int w, int h);
00159 static void GlutMouse(int button, int state, int x, int y);
00160 static void GlutMouseMove( int x, int y );
00161 static void GlutKeyboard(unsigned char Key, int x, int y);
00162
00163 };
00164
00165
00166 #endif