Klamp't  0.9.0
WorldViewProgram.h
1 #ifndef WORLD_VIEW_PROGRAM_H
2 #define WORLD_VIEW_PROGRAM_H
3 
5 #include <KrisLibrary/GLdraw/GL.h>
6 #include <KrisLibrary/GLdraw/Widget.h>
7 #include <KrisLibrary/math3d/Ray3D.h>
8 
9 #if HAVE_GLUI
10 
11  #include <KrisLibrary/GLdraw/GLUINavigationProgram.h>
12  #include <KrisLibrary/GLdraw/GLScreenshotProgram.h>
13  #if defined (__APPLE__) || defined (MACOSX)
14  #include <glui.h>
15  #else
16  #include <GL/glui.h>
17  #endif //__APPLE__ || MACOSX
18 
19  #define BASE_PROGRAM GLUINavigationProgram
20 
21 #else
22 
23  #if HAVE_GLUT
24 
25  #include <KrisLibrary/GLdraw/GLUTNavigationProgram.h>
26  #include <KrisLibrary/GLdraw/GLScreenshotProgram.h>
27  #define BASE_PROGRAM GLUTNavigationProgram
28 
29  #if defined (__APPLE__) || defined (MACOSX)
30  #include <GLUT/glut.h>
31  #else
32  #include <GL/glut.h>
33  #endif // Apple
34 
35  #if FREEGLUT
36  #include <GL/freeglut_ext.h>
37  #endif //FREEGLUT
38 
39 
40  #endif //HAVE_GLUT
41 
42 #endif //HAVE_GLUI
43 
44 namespace Klampt {
45  using namespace Math3D;
46  using namespace GLDraw;
47 
48 bool LoadWorldCommandLine(WorldModel& world,int argc, const char** argv);
49 
50 
51 #if HAVE_GLUI || HAVE_GLUT
52 
59 class WorldViewProgram : public GLScreenshotProgram<BASE_PROGRAM>
60 {
61 public:
62  WorldViewProgram(WorldModel* world);
63  virtual ~WorldViewProgram() {}
64 
65  bool LoadCommandLine(int argc,const char** argv);
66  virtual bool Initialize();
67  virtual void SetWorldLights();
68  void ClickRay(int x,int y,Ray3D& r) const;
69  RobotModel* ClickRobot(const Ray3D& r,int& body,Vector3& localpt) const;
70  RigidObjectModel* ClickObject(const Ray3D& r,Vector3& localpt) const;
71  virtual void RefreshIdle();
72  virtual void RenderWorld();
73  virtual void DoFreeDrag(int dx,int dy,int button);
74  virtual void DoCtrlDrag(int dx,int dy,int button);
75  virtual void DoAltDrag(int dx,int dy,int button);
76  virtual void DoShiftDrag(int dx,int dy,int button);
77 
78  WorldModel* world;
79 };
80 
81 #endif // HAVE_GLUI || HAVE_GLUT
82 
83 
86 class WorldViewWidget : public Widget
87 {
88 public:
90  virtual bool Hover(int x, int y, Camera::Viewport& viewport, double& distance);
91  //these currently don't do anything, but can be overloaded to do something with the current robot
92  virtual bool BeginDrag(int x, int y, Camera::Viewport& viewport, double& distance);
93  virtual void Drag(int dx, int dy, Camera::Viewport& viewport) {}
94  virtual void EndDrag() {}
95 
96  virtual void DrawGL(Camera::Viewport& viewport);
97 
98  WorldModel* world;
99  //click information
100  RobotModel* clickedRobot;
101  RigidObjectModel* clickedObject;
102  int body;
103  Vector3 localpt;
104 };
105 
106 } // namespace Klampt
107 
108 #endif
A (static) rigid object that may be manipulated.
Definition: RigidObject.h:15
Defines the WorldModel class.
The main robot type used in RobotSim.
Definition: Robot.h:83
Definition: ContactDistance.h:6
A widget interface that can be overloaded to interact with a world.
Definition: WorldViewProgram.h:86
The main world class containing multiple robots, objects, and static geometries (terrains). Lights and other viewport information may also be stored here.
Definition: World.h:24