OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coVRConfig.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_VR_CONFIG_H
9 #define CO_VR_CONFIG_H
10 
24 #include <util/coExport.h>
25 #include <osg/Vec3>
26 #include <osg/ref_ptr>
27 #include <osg/Camera>
28 #include <osg/Multisample>
29 #include <osg/Texture2D>
30 #include <osgViewer/GraphicsWindow>
31 #include <osgUtil/SceneView>
32 #include <string>
33 
34 namespace osg
35 {
36 class DisplaySettings;
37 class GraphicsContext;
38 }
39 
40 namespace osgViewer
41 {
42 class GraphicsWindow;
43 }
44 
45 namespace opencover
46 {
47 
48 class coVRPlugin;
49 
52 {
53  float hsize; // horizontal size in mm
54  float vsize; // vertical size in mm
55  osg::Vec3 xyz; // screen center in mm
56  osg::Vec3 hpr; // screen orientation in degree euler angles
57  std::string name;
58  bool render;
59  float lTan; // left, right, top bottom field of views, default/not set is -1
60  float rTan;
61  float tTan;
62  float bTan;
63 
65  : hsize(0)
66  , vsize(0)
67  , xyz(0, 0, 0)
68  , hpr(0, 0, 0)
69  , name("UninitializedScreen")
70  , render(false)
71  , lTan(-1)
72  , rTan(-1)
73  , tTan(-1)
74  , bTan(-1)
75  {}
76 };
77 
80 {
81  std::string name;
82 
83  int PBONum; // destination PBO or -1 if rendering to a viewport directly
84  int viewportNum; // destination viewport or -1 if rendering to a PBO
85  int screenNum; // screen index
86 
87  osg::ref_ptr<osg::Camera> camera;
88  osg::DisplaySettings *ds;
89  bool stereo;
92  float stereoOffset;
93  osg::Matrixd leftView, rightView;
94  osg::Matrixd leftProj, rightProj;
95 
97  : name("UninitializedChannel")
98  , PBONum(-1)
99  , viewportNum(-1)
100  , screenNum(-1)
101  , ds(NULL)
102  , stereo(true)
103  , stereoMode(osg::DisplaySettings::LEFT_EYE)
104  , fixedViewer(false)
105  , stereoOffset(0.f)
106  {}
107 };
108 
110 struct PBOStruct
111 {
112  int PBOsx, PBOsy; // PBO size
113  int windowNum; // pipe to render to
114  osg::ref_ptr<osg::Texture2D> renderTargetTexture;
115 
117  : PBOsx(-1)
118  , PBOsy(-1)
119  , windowNum(-1)
120  {}
121 };
122 
123 
124 class COVEREXPORT angleStruct
125 {
126 public:
127  int analogInput; // number of analog port at Cereal Box
128  float cmin, cmax; // min and max values that analog port delivers
129  float minangle, maxangle; // minimum and maximum angle in real world
130  int screen; // screen number for these values
131  float *value; // actual value (is set by VRPolhemusTracker::initCereal)
132  int hpr; // which angle: hue, pitch or roll?
133 };
134 
137 {
138  int ox, oy;
139  int sx, sy;
140  osg::ref_ptr<osg::GraphicsContext> context;
141  osg::ref_ptr<osgViewer::GraphicsWindow> window;
142  int pipeNum;
143  std::string name;
145  bool resize;
146  bool stereo;
147  bool embedded;
148  bool pbuffer;
152  std::string type;
154 
156  : ox(-1)
157  , oy(-1)
158  , sx(-1)
159  , sy(-1)
160  , context(NULL)
161  , window(NULL)
162  , pipeNum(-1)
163  , name("UninitializedWindow")
164  , decoration(true)
165  , resize(true)
166  , stereo(false)
167  , embedded(false)
168  , pbuffer(false)
169  , doublebuffer(true)
170  , swapGroup(-1)
171  , swapBarrier(-1)
172  , windowPlugin(NULL)
173  {}
174 };
175 
176 struct viewportStruct // describes an OpenGL Viewport
177 {
178  enum Mode
179  {
180  Channel, //< channel renders directly into viewport
181  PBO, //< PBO is copied to viewport
182  TridelityML, //< 5 PBOs are copied interweaved into viewport
183  TridelityMV, //< 5 PBOs are copied interweaved into viewport
184  };
185  Mode mode; //< image source
186  int window;
187  std::vector<int> pbos;
188  int PBOnum;
189  float sourceXMin;
190  float sourceYMin;
191  float sourceXMax;
192  float sourceYMax;
193 
198 
199  std::string distortMeshName;
200  std::string blendingTextureName;
201 
203  : mode(Channel)
204  , window(-1)
205  , PBOnum(-1)
206  , distortMeshName("NoDistortMesh")
207  , blendingTextureName("NoBlendingTexture")
208  {}
209 };
210 
211 struct blendingTextureStruct // describes a blending Texture
212 {
213  int window;
218 
219  std::string blendingTextureName;
220 
222  : window(-1)
223  , blendingTextureName("UninitialzedBlendingTexture")
224  {}
225 };
226 
229 {
232  std::string x11DisplayHost;
234 
236  : x11DisplayNum(-1)
237  , x11ScreenNum(-1)
238  , useDISPLAY(false)
239  {}
240 };
241 
242 class COVEREXPORT coVRConfig
243 {
244  friend class coVRPluginSupport;
245  friend class VRWindow;
246  friend class VRSceneGraph;
247  friend class OpenCOVER;
248  friend class VRViewer;
249 
250  static coVRConfig *s_instance;
251 
252 public:
253  static coVRConfig *instance();
254 
256  {
260  MONO_NONE
261  };
262 
263  // mono rendering mode
264  MonoViews monoView() const;
265 
266  enum
267  {
272  NONE
273  } envMapModes;
274  /*
275  //my
276  enum MarkNodes
277  {
278  MOVE,
279  SHOWHIDE,
280  SELECTION,
281  ANNOTATION
282  };
283  */
284  int getEnvMapMode(){return m_envMapMode;};
285  int numScreens() const;
286  int numChannels() const;
287  int numPBOs() const;
288  int numViewports() const;
289  int numBlendingTextures() const;
290  int numWindows() const;
291  int numPipes() const;
292  int lockToCPU() const;
293 
294  // get the scene size defined in covise.config
295  float getSceneSize() const;
296 
297  int stereoMode() const;
298  static int parseStereoMode(const char *modeName, bool *stereo=NULL);
299  static bool requiresTwoViewpoints(int stereomode);
300  // have all the screens the same orientation?
301  bool haveFlatDisplay() const;
302 
303  // if mouse needs to be checked
304  bool mouseNav() const;
305 
306  // if mouse needs to be checked
307  bool mouseTracking() const;
308 
309  // whether there is a Person with a 6DoF input device
310  bool has6DoFInput() const;
311 
312  // if WiiMote needs to be checked
313  bool useWiiMote() const;
314  // wii navigation
315  bool useWiiNavigationVisenso() const;
316 
317  // menu mode on
318  bool isMenuModeOn() const;
319  // color scene in menu mode
320  bool colorSceneInMenuMode() const;
321 
322  // optional Collaborative configuration file (-c option)
324 
325  // optional Collaborative configuration file (-c option)
326  std::string viewpointsFile;
327 
328  // returns true if level <= debugLevel
329  // debug levels should be used like this
330  // 0 no output
331  // 1 covise.config entries, coVRInit
332  // 2 constructors, destructors
333  // 3 all functions which are not called continously
334  // 4
335  // 5 all functions which are called continously
336  bool debugLevel(int level) const;
337 
338  // get debug level
339  int getDebugLevel() const;
340 
341  // set debug level
342  void setDebugLevel(int level);
343 
344  // return true, if OpenCOVER is configured for stereo rendering
345  bool stereoState() const;
346 
347  float stereoSeparation() const;
348 
349  // get number of requested stencil bits (default = 1)
350  int numStencilBits() const;
351 
352  // current configured angle of workbench
353  float worldAngle() const;
354 
356  bool frozen() const;
357 
359  void setFrozen(bool state);
360 
362  bool orthographic() const;
363 
365  void setOrthographic(bool state);
366 
368  bool useDisplayLists() const;
369 
371  bool useVBOs() const;
372 
374  float nearClip() const;
375 
377  float farClip() const;
378 
380  float getLODScale() const;
381  void setLODScale(float);
382 
384  {
385  return multisample;
386  }
388  {
389  return multisampleInvert;
390  }
392  {
393  return multisampleCoverage;
394  }
396  {
397  return multisampleSamples;
398  }
400  {
401  return multisampleSampleBuffers;
402  }
403  osg::Multisample::Mode getMultisampleMode()
404  {
405  return multisampleMode;
406  }
407 
408  bool stencil() const;
409 
410  void setFrameRate(float fr);
411  float frameRate() const;
412 
413  bool continuousRendering() const;
414 
415  std::vector<screenStruct> screens; // list of physical screens
416  std::vector<channelStruct> channels; // list of physical screens
417  std::vector<PBOStruct> PBOs; // list of physical screens
418  std::vector<pipeStruct> pipes; // list of pipes (X11: identified by display and screen)
419  std::vector<windowStruct> windows; // list of windows
420  std::vector<viewportStruct> viewports; // list of PixelBufferObjects
421  std::vector<blendingTextureStruct> blendingTextures; // list of blendingTextures
422 
423  bool useDisplayVariable() const
424  {
425  return m_useDISPLAY;
426  }
427 
428  bool useVirtualGL() const
429  {
430  return m_useVirtualGL;
431  }
432 
433  void setNearFar(float nearC, float farC)
434  {
435  if (nearC > 0 && farC > 0)
436  {
437  m_farClip = farC;
438  m_nearClip = nearC;
439  }
440  }
441 
442  int getLanguage() const
443  {
444  return m_language;
445  }
447  {
449  GERMAN
450  };
452  std::string glVersion;
454 
455 private:
456  coVRConfig();
457  ~coVRConfig();
458 
459  // configuration entries
460 
461  bool m_useDisplayLists;
462  bool m_useVBOs;
463 
464  bool m_useDISPLAY;
465  bool m_useVirtualGL;
466  int m_stencilBits;
467  float m_sceneSize;
468 
469  float m_nearClip;
470  float m_farClip;
471  float m_LODScale;
472  float m_worldAngle;
473 
474  bool m_stereoState;
475  int m_stereoMode;
476  float m_stereoSeparation;
477  MonoViews m_monoView; // MONO_MIDDLE MONO_LEFT MONO_RIGHT
478  int m_envMapMode;
479  bool m_freeze;
480  bool m_passiveStereo;
481  bool m_orthographic;
482  bool m_stencil; //< user stencil buffers
483  bool HMDMode;
484 
485  bool trackedHMD;
486 
487  int drawStatistics;
488 
489  // multi-sampling
490  int multisampleSamples;
491  int multisampleSampleBuffers;
492  float multisampleCoverage;
493  bool multisampleInvert;
494  bool multisample;
495  osg::Multisample::Mode multisampleMode;
496 
497  int m_dLevel; // debugLevel
498  bool m_mouseNav;
499  bool m_useWiiMote;
500  bool m_useWiiNavVisenso;
501 
502  bool m_flatDisplay;
503  bool m_doRender;
504 
505  bool constantFrameRate;
506  float constFrameTime;
507  bool m_continuousRendering;
508 
509  int m_language;
510 
511  bool m_menuModeOn;
512  bool m_coloringSceneInMenuMode;
513  int m_lockToCPU;
514 };
515 }
516 #endif
int PBONum
Definition: coVRConfig.h:83
coVRPlugin * windowPlugin
Definition: coVRConfig.h:153
bool getMultisampleInvert()
Definition: coVRConfig.h:387
Definition: coVRConfig.h:182
std::string name
Definition: coVRConfig.h:81
bool resize
Definition: coVRConfig.h:145
int PBOsx
Definition: coVRConfig.h:112
bool pbuffer
Definition: coVRConfig.h:148
osg::Matrixd rightProj
Definition: coVRConfig.h:94
float * value
Definition: coVRConfig.h:131
int getLanguage() const
Definition: coVRConfig.h:442
Definition: VRViewer.h:52
osg::ref_ptr< osg::GraphicsContext > context
Definition: coVRConfig.h:140
osg::Matrixd leftView
Definition: coVRConfig.h:93
std::string collaborativeOptionsFile
Definition: coVRConfig.h:323
float getMultisampleCoverage()
Definition: coVRConfig.h:391
void setNearFar(float nearC, float farC)
Definition: coVRConfig.h:433
osg::Vec3 hpr
Definition: coVRConfig.h:56
int stereoMode
Definition: coVRConfig.h:90
Definition: coVRConfig.h:124
Definition: VRWindow.h:42
int ox
Definition: coVRConfig.h:138
int getMultisampleSampleBuffers()
Definition: coVRConfig.h:399
osg::ref_ptr< osg::Camera > camera
Definition: coVRConfig.h:87
int pipeNum
Definition: coVRConfig.h:142
osg::ref_ptr< osg::Texture2D > renderTargetTexture
Definition: coVRConfig.h:114
float HMDViewingAngle
Definition: coVRConfig.h:451
int getEnvMapMode()
Definition: coVRConfig.h:284
windowStruct()
Definition: coVRConfig.h:155
float vsize
Definition: coVRConfig.h:54
std::vector< channelStruct > channels
Definition: coVRConfig.h:416
std::vector< PBOStruct > PBOs
Definition: coVRConfig.h:417
bool stereo
Definition: coVRConfig.h:146
int sx
Definition: coVRConfig.h:139
int analogInput
Definition: coVRConfig.h:127
describes a PBO
Definition: coVRConfig.h:110
int swapGroup
Definition: coVRConfig.h:150
describes one window of the windowing system
Definition: coVRConfig.h:136
float viewportXMin
Definition: coVRConfig.h:214
int PBOnum
Definition: coVRConfig.h:188
bool fixedViewer
Definition: coVRConfig.h:91
float viewportXMax
Definition: coVRConfig.h:216
bool render
Definition: coVRConfig.h:58
pipeStruct()
Definition: coVRConfig.h:235
bool useVirtualGL() const
Definition: coVRConfig.h:428
std::vector< viewportStruct > viewports
Definition: coVRConfig.h:420
Definition: coVRConfig.h:183
bool useDisplayVariable() const
Definition: coVRConfig.h:423
int swapBarrier
Definition: coVRConfig.h:151
Definition: coVRConfig.h:268
std::string type
Definition: coVRConfig.h:152
osg::Vec3 xyz
Definition: coVRConfig.h:55
float cmin
Definition: coVRConfig.h:128
int window
Definition: coVRConfig.h:186
bool useDISPLAY
Definition: coVRConfig.h:233
MonoViews
Definition: coVRConfig.h:255
int screenNum
Definition: coVRConfig.h:85
float bTan
Definition: coVRConfig.h:62
int x11ScreenNum
Definition: coVRConfig.h:231
float tTan
Definition: coVRConfig.h:61
Definition: coVRConfig.h:176
bool stereo
Definition: coVRConfig.h:89
float sourceYMax
Definition: coVRConfig.h:192
std::vector< int > pbos
Definition: coVRConfig.h:187
Definition: coVRConfig.h:211
osg::DisplaySettings * ds
Definition: coVRConfig.h:88
describes a physical screen, such as one wall of a CAVE
Definition: coVRConfig.h:51
make sure to clean up properly in the plugin&#39;s dtor
Definition: coVRPlugin.h:70
float hsize
Definition: coVRConfig.h:53
int PBOsy
Definition: coVRConfig.h:112
describes a render Channel which renders to a PBO or viewport
Definition: coVRConfig.h:79
float sourceXMin
Definition: coVRConfig.h:189
osg::ref_ptr< osgViewer::GraphicsWindow > window
Definition: coVRConfig.h:141
std::vector< blendingTextureStruct > blendingTextures
Definition: coVRConfig.h:421
int sy
Definition: coVRConfig.h:139
std::string viewpointsFile
Definition: coVRConfig.h:326
std::string distortMeshName
Definition: coVRConfig.h:199
screenStruct()
Definition: coVRConfig.h:64
std::string name
Definition: coVRConfig.h:143
float sourceXMax
Definition: coVRConfig.h:191
float stereoOffset
Definition: coVRConfig.h:92
std::string x11DisplayHost
Definition: coVRConfig.h:232
float lTan
Definition: coVRConfig.h:59
PBOStruct()
Definition: coVRConfig.h:116
std::vector< screenStruct > screens
Definition: coVRConfig.h:415
osg::Multisample::Mode getMultisampleMode()
Definition: coVRConfig.h:403
int window
Definition: coVRConfig.h:213
Definition: coVRConfig.h:448
int getMultisampleSamples()
Definition: coVRConfig.h:395
float viewportYMax
Definition: coVRConfig.h:217
float sourceYMin
Definition: coVRConfig.h:190
int windowNum
Definition: coVRConfig.h:113
Definition: coVRConfig.h:269
Definition: coVRConfig.h:181
int viewportNum
Definition: coVRConfig.h:84
bool embedded
Definition: coVRConfig.h:147
int screen
Definition: coVRConfig.h:130
describes what is responsible for rendering the window
Definition: coVRConfig.h:228
Definition: OpenCOVER.h:53
blendingTextureStruct()
Definition: coVRConfig.h:221
bool doublebuffer
Definition: coVRConfig.h:149
Definition: coVRConfig.h:258
float viewportXMin
Definition: coVRConfig.h:194
Definition: coVRConfig.h:180
float rTan
Definition: coVRConfig.h:60
osg::Matrixd leftProj
Definition: coVRConfig.h:94
Definition: coVRConfig.h:259
channelStruct()
Definition: coVRConfig.h:96
bool OpenVR_HMD
Definition: coVRConfig.h:453
Definition: coVRConfig.h:257
std::string blendingTextureName
Definition: coVRConfig.h:200
bool decoration
Definition: coVRConfig.h:144
float viewportYMin
Definition: coVRConfig.h:215
float minangle
Definition: coVRConfig.h:129
Mode mode
Definition: coVRConfig.h:185
float viewportXMax
Definition: coVRConfig.h:196
int oy
Definition: coVRConfig.h:138
Languages
Definition: coVRConfig.h:446
Mode
Definition: coVRConfig.h:178
std::string blendingTextureName
Definition: coVRConfig.h:219
std::vector< pipeStruct > pipes
Definition: coVRConfig.h:418
int hpr
Definition: coVRConfig.h:132
Definition: coVRPluginSupport.h:191
bool doMultisample()
Definition: coVRConfig.h:383
Definition: coVRConfig.h:242
float viewportYMin
Definition: coVRConfig.h:195
std::string name
Definition: coVRConfig.h:57
float viewportYMax
Definition: coVRConfig.h:197
int x11DisplayNum
Definition: coVRConfig.h:230
Definition: VRSceneGraph.h:60
std::string glVersion
Definition: coVRConfig.h:452
osg::Matrixd rightView
Definition: coVRConfig.h:93
std::vector< windowStruct > windows
Definition: coVRConfig.h:419
viewportStruct()
Definition: coVRConfig.h:202