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