Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

rendergl.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //               The Motion Strategy Library (MSL)
00003 //----------------------------------------------------------------------
00004 //
00005 // Copyright (c) 1998-2000 Iowa State University and Steve LaValle.  
00006 // All Rights Reserved.
00007 // 
00008 // Permission to use, copy, and distribute this software and its 
00009 // documentation is hereby granted free of charge, provided that 
00010 // (1) it is not a component of a commercial product, and 
00011 // (2) this notice appears in all copies of the software and
00012 //     related documentation. 
00013 // 
00014 // Iowa State University and the author make no representations
00015 // about the suitability or fitness of this software for any purpose.  
00016 // It is provided "as is" without express or implied warranty.
00017 //----------------------------------------------------------------------
00018 
00019 // RenderGL was written by Peng Cheng (chp@cs.iastate.edu)
00020 // Modifications made by Steve LaValle (lavalle@cs.iatate.edu)
00021 
00022 #ifndef MSL_RENDERGL_H
00023 #define MSL_RENDERGL_H
00024 
00025 #include <LEDA/file.h>
00026 #include <LEDA/list.h>
00027 #include <LEDA/matrix.h>
00028 #include <LEDA/point.h>
00029 #include <LEDA/polygon.h>
00030 #include <LEDA/stream.h>
00031 #include <LEDA/string.h>
00032 #include <LEDA/vector.h>
00033 #include <LEDA/d3_point.h>
00034 
00035 #include<GL/glut.h>
00036 #include<GL/gl.h>
00037 
00038 #include "3Dtriangle.h"
00039 #include "render.h"
00040 #include "renderglobj.h"
00041 
00042 
00043 #include <LEDA/REDEFINE_NAMES.h>
00044 
00046 class RenderGL: public Render
00047 {
00048  protected:
00049   array<int> EnvIndex;
00050   array<int> BodyIndex;
00051 
00052   float WindowX, WindowY, WindowZ;
00053 
00054   float BoundingBoxMin[3];
00055   float BoundingBoxMax[3];
00056 
00057   float Orientation[3];
00058   float Position[3];
00059 
00060   // view parameters
00061   float Fov, AspectRatio, Near, Far;
00062   float EyeX, EyeY, EyeZ;
00063   float VpX, VpY, VpZ;
00064   float VupX, VupY, VupZ;
00065   float ViewLength;  // the distance from the eye to the center of the scene
00066 
00067   // unit vector for the viewer coordinate
00068   vector VCoordZ, VCoordY, VCoordX;
00069   vector VRpy;
00070 
00071   vector DefVCoordZ, DefVCoordY, DefVCoordX;
00072   vector DefVRpy;
00073 
00074   vector RpyModification;
00075 
00076   // unit vector for the scene coordinate
00077   vector SCoordZ, SCoordY, SCoordX;
00078 
00079   // light position
00080   float LightPosX, LightPosY, LightPosZ;
00081 
00082   // number of object(robots and obstacles)
00083   int NumberOfObject;
00084   int NumberOfBody;
00085   int NumberOfEnvObj;
00086 
00087   // robot and obstacle model information list
00088   mslGLObject ** SceneBodyLib;
00089   mslGLObject ** SceneEnvObjLib;
00090   
00091   // used to control the original scale, position of object 
00092   vector EnvTransform;
00093   vector BodyTransform;
00094 
00095   // used for gui control
00096   int MainWindow;
00097 
00098   // control varibles
00099   int SelectObjectID;
00100   int CurrentObject;
00101  
00102   // mouse control parameter 
00103   int CurrentMouseButton, CurrentMouseState;
00104   int CurrentKeyboard;
00105   float LastX, LastY;
00106   float ChangeRate;
00107   float AnimationTimeScaleTmp;
00108 
00109   // method to load the configuration
00110   void LoadConfig();
00111 
00112   // method to add new object into scene
00113   void AddBodyObject(mslGLObject * obj);
00114   void AddEnvObject(mslGLObject * obj);
00115 
00116   // method to get object according to object ID
00117   mslGLObject* WhichObject(int id);
00118   void SceneRender();
00119 
00120   // method to set the position of light
00121   void SetLightPos();
00122 
00123   // method to set the change of orientation and position
00124   void SetSceneOrientationChange(const vector& oric);
00125   void SetScenePositionChange(const vector& posc);
00126 
00127   // method to set the body or environment obstacles' position and orientation
00128   void SetBodyState(const vector& state);
00129   void SetEnvState(const vector& state);
00130 
00131   // method to draw the bounding box
00132   void DrawBoundingBox();
00133 
00134   void DrawPath();
00135 
00136   void InitData();
00137   void InitGeometry(list<Triangle> triangles);
00138   void DrawBodies(const vector &x);
00139   void DrawEnv();
00140   void NormCrossProduct(float v1[3], float v2[3], float out[3]);
00141   void Normalize(float v[3]);
00142 
00143   void ShowCoordinateFrame();
00144 
00145  public: 
00146   Gui *G;
00147 
00148   RenderGL();
00149   RenderGL(string filepath);
00150   RenderGL(Scene *s, string filepath);
00151   virtual ~RenderGL();
00152 
00153   // method to reset the scene
00154   virtual void Reset();
00155 
00156   virtual void Init();
00157   virtual void MainLoop(Gui *g);
00158 
00159   static void GlutIdleProcessing();
00160   static void GlutDrawEnvironment();
00161   static void GlutReshape(int w, int h);
00162   static void GlutMouse(int button, int state, int x, int y);
00163   static void GlutMouseMove( int x, int y );
00164   static void GlutKeyboard(unsigned char Key, int x, int y);
00165 
00166 };
00167 
00168 
00169 #include <LEDA/UNDEFINE_NAMES.h>
00170 
00171 #endif
Motion Strategy Library


Web page maintained by Steve LaValle
Partial support provided by NSF CAREER Award IRI-970228 (LaValle), Honda Research, and Iowa State University.
Contributors: Anna Atramentov, Peng Cheng, James Kuffner, Steve LaValle, and Libo Yang.