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) University of Illinois and Steven M. 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 // The University of Illinois 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 <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   // view parameters
00052   float Fov, AspectRatio, Near, Far;
00053   float EyeX, EyeY, EyeZ;
00054   float VpX, VpY, VpZ;
00055   float VupX, VupY, VupZ;
00056   float ViewLength;  // the distance from the eye to the center of the scene
00057 
00058   // unit MSLVector for the viewer coordinate
00059   MSLVector VCoordZ, VCoordY, VCoordX;
00060   MSLVector VRpy;
00061 
00062   MSLVector DefVCoordZ, DefVCoordY, DefVCoordX;
00063   MSLVector DefVRpy;
00064 
00065   MSLVector RpyModification;
00066 
00067   // unit MSLVector for the scene coordinate
00068   MSLVector SCoordZ, SCoordY, SCoordX;
00069 
00070   // light position
00071   float LightPosX, LightPosY, LightPosZ;
00072 
00073   // number of object(robots and obstacles)
00074   int NumberOfObject;
00075   int NumberOfBody;
00076   int NumberOfEnvObj;
00077 
00078   // robot and obstacle model information list
00079   mslGLObject ** SceneBodyLib;
00080   mslGLObject ** SceneEnvObjLib;
00081   
00082   // used to control the original scale, position of object 
00083   MSLVector EnvTransform;
00084   MSLVector BodyTransform;
00085 
00086   // used for gui control
00087   int MainWindow;
00088 
00089   // control varibles
00090   int SelectObjectID;
00091   int CurrentObject;
00092  
00093   // mouse control parameter 
00094   int CurrentMouseButton, CurrentMouseState;
00095   int CurrentKeyboard;
00096   float LastX, LastY;
00097   float ChangeRate;
00098   float AnimationTimeScaleTmp;
00099 
00100   // method to load the configuration
00101   void LoadConfig();
00102 
00103   // method to add new object into scene
00104   void AddBodyObject(mslGLObject * obj);
00105   void AddEnvObject(mslGLObject * obj);
00106 
00107   // method to get object according to object ID
00108   mslGLObject* WhichObject(int id);
00109   void SceneRender();
00110 
00111   // method to set the position of light
00112   void SetLightPos();
00113 
00114   // method to set the change of orientation and position
00115   void SetSceneOrientationChange(const MSLVector& oric);
00116   void SetScenePositionChange(const MSLVector& posc);
00117 
00118   // method to set the body or environment obstacles' position and orientation
00119   void SetBodyState(const MSLVector& state);
00120   void SetEnvState(const MSLVector& state);
00121 
00122   // method to draw the bounding box
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   // method to reset the scene
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
Motion Strategy Library


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