SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLSceneView.h
Go to the documentation of this file.
1 /**
2  * \file SLSceneView.h
3  * \date July 2014
4  * \remarks Please use clangformat to format the code. See more code style on
5  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
6  * \authors Marc Wacker, Marcus Hudritsch
7  * \copyright http://opensource.org/licenses/GPL-3.0
8 */
9 
10 #ifndef SLSCENEVIEW_H
11 #define SLSCENEVIEW_H
12 
13 #include <SLAABBox.h>
14 #include <SLDrawBits.h>
15 #include <SLEventHandler.h>
16 #include <SLGLOculusFB.h>
17 #include <SLGLVertexArrayExt.h>
18 #include <SLNode.h>
19 #include <SLPathtracer.h>
20 #include <SLRaytracer.h>
21 #include <SLScene.h>
22 #include <SLOptixRaytracer.h>
23 #include <SLOptixPathtracer.h>
24 #include <math/SLRect.h>
25 #include "SLUiInterface.h"
26 #include <SLImGui.h>
27 #include <unordered_set>
28 
29 //-----------------------------------------------------------------------------
30 class SLCamera;
31 class SLLight;
32 class SLScene;
33 class SLInputManager;
34 class SLImGui;
35 class SLUiInterface;
36 
37 //-----------------------------------------------------------------------------
38 /*
39 There are only a very few callbacks from the SLInterface up to the GUI
40 framework. All other function calls are downwards from the GUI framework
41 */
42 //! Callback function typedef for custom SLSceneView derived creator function
43 typedef SLSceneView*(SL_STDCALL* cbOnNewSceneView)(SLScene* s,
44  int dotsPerInch,
45  SLInputManager& inputManager);
46 
47 //! Callback function typedef for GUI window updateRec
48 typedef SLbool(SL_STDCALL* cbOnWndUpdate)();
49 
50 //! Callback function typedef for select node
51 typedef void(SL_STDCALL* cbOnSelectNodeMesh)(SLNode*, SLMesh*);
52 
53 //-----------------------------------------------------------------------------
54 //! SceneView class represents a dynamic real time 3D view onto the scene.
55 /*!
56  The SLSceneView class has a pointer to an active camera that is used to
57  generate the 3D view into a window of the clients GUI system.
58  OpenGL ES3.0 or newer is used the default renderer for framebuffer rendering.
59  Alternatively the sceneview can be rendered with a software ray tracing or
60  path tracing renderer.
61  All mouse, touch, keyboard, resize and paint events of the GUI system are
62  handled in this class by the appropriate event handler methods. If your
63  app need special event handling you can subclass this class and override the
64  virtual function.
65  If the scene contains itself no camera node the sceneview provides its own
66  camera object.
67 */
68 class SLSceneView : public SLObject
69 {
70  friend class SLNode;
71  friend class SLRaytracer;
72  friend class SLOptixRaytracer;
73  friend class SLPathtracer;
74 
75 public:
76  SLSceneView(SLScene* s, int dpi, SLInputManager& inputManager);
77  ~SLSceneView() override;
78 
79  void init(SLstring name,
80  SLint screenWidth,
81  SLint screenHeight,
82  void* onWndUpdateCallback,
83  void* onSelectNodeMeshCallback,
85  const string& configPath);
86  void unInit();
87 
88  // Not overridable event handlers
89  void onInitialize();
90  SLbool onPaint();
92 
93  // overridable for subclasses of SLSceneView
94  virtual void onStartup() {}
95  virtual void preDraw() {}
96  virtual void postDraw() {}
97  virtual void postSceneLoad() {}
98  virtual SLbool onMouseDown(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod);
99  virtual SLbool onMouseUp(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod);
100  virtual SLbool onMouseMove(SLint x, SLint y);
101  virtual SLbool onMouseWheelPos(SLint wheelPos, SLKey mod);
102  virtual SLbool onMouseWheel(SLint delta, SLKey mod);
103  virtual SLbool onTouch2Down(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2);
104  virtual SLbool onTouch2Move(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2);
105  virtual SLbool onTouch2Up(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2);
106  virtual SLbool onDoubleClick(SLMouseButton button, SLint x, SLint y, SLKey mod);
107  virtual SLbool onKeyPress(SLKey key, SLKey mod);
108  virtual SLbool onKeyRelease(SLKey key, SLKey mod);
109  virtual SLbool onCharInput(SLuint c);
110 
111  // Drawing subroutines
112  SLbool draw3DGL(SLfloat elapsedTimeSec);
113  void draw3DGLAll();
114  void draw3DGLNodes(SLVNode& nodes, SLbool alphaBlended, SLbool depthSorted);
115  void draw3DGLLines(SLVNode& nodes);
116  void draw3DGLLinesOverlay(SLVNode& nodes);
117  void draw2DGL();
118  void draw2DGLNodes();
119  SLbool draw3DRT();
120  SLbool draw3DPT();
122 
123  // SceneView camera
124  void initSceneViewCamera(const SLVec3f& dir = -SLVec3f::AXISZ,
129 
130  // Misc.
132  void printStats() { _stats3D.print(); }
134  void startPathtracing(SLint maxDepth, SLint samples);
135  void setViewportFromRatio(const SLVec2i& vpRatio,
136  SLViewportAlign vpAlignment,
137  SLbool vpSameAsVideo);
138  void saveFrameBufferAsImage(SLstring pathFilename, cv::Size targetSize = cv::Size(-1, -1));
139 
140  // Callback routines
141  cbOnWndUpdate onWndUpdate; //!< C-Callback for app for intermediate window repaint
142  cbOnSelectNodeMesh onSelectedNodeMesh; //!< C-Callback for app on node selection
143 
144  // Setters
146  void scene(SLScene* scene) { _s = scene; }
147  void scrW(SLint scrW) { _scrW = scrW; }
148  void scrH(SLint scrH) { _scrH = scrH; }
149  void doWaitOnIdle(SLbool doWI) { _doWaitOnIdle = doWI; }
150  void doMultiSampling(SLbool doMS) { _doMultiSampling = doMS; }
151  void doDepthTest(SLbool doDT) { _doDepthTest = doDT; }
153  void doAlphaSorting(SLbool doAS) { _doAlphaSorting = doAS; }
155  void viewportSameAsVideo(bool sameAsVideo) { _viewportSameAsVideo = sameAsVideo; }
156  void screenCaptureIsRequested(bool doScreenCap)
157  {
158  if (doScreenCap)
159  {
160  _gui->drawMouseCursor(false);
162  }
163  _screenCaptureIsRequested = doScreenCap;
164  }
165 
166  // Getters
167  SLScene* s() { return _s; }
168  SLCamera* camera() { return _camera; }
170  SLint scrW() const { return _scrW; }
171  SLint scrH() const { return _scrH; }
172  SLint scrWdiv2() const { return _scrWdiv2; }
173  SLint scrHdiv2() const { return _scrHdiv2; }
174  SLfloat scrWdivH() const { return _scrWdivH; }
175  SLint dpi() const { return _dpi; }
176  SLRecti viewportRect() const { return _viewportRect; }
178  SLfloat viewportWdivH() const { return (float)_viewportRect.width / (float)_viewportRect.height; }
179  SLint viewportW() const { return _viewportRect.width; }
180  SLint viewportH() const { return _viewportRect.height; }
183  SLUiInterface* gui() { return _gui; }
187  SLbool doDepthTest() const { return _doDepthTest; }
188  SLbool doWaitOnIdle() const { return _doWaitOnIdle; }
196  SLRenderType renderType() const { return _renderType; }
198  SLDrawBits* drawBits() { return &_drawBits; }
199  SLbool drawBit(SLuint bit) { return _drawBits.get(bit); }
204  SLNodeStats& stats2D() { return _stats2D; }
205  SLNodeStats& stats3D() { return _stats3D; }
207 
208  std::unordered_set<SLMaterial*>& visibleMaterials2D() { return _visibleMaterials2D; }
209  std::unordered_set<SLMaterial*>& visibleMaterials3D() { return _visibleMaterials3D; }
210 
211 #ifdef SL_HAS_OPTIX
212  SLOptixRaytracer* optixRaytracer()
213  {
214  return &_optixRaytracer;
215  }
216  SLOptixPathtracer* optixPathtracer() { return &_optixPathtracer; }
217  SLbool draw3DOptixRT();
218  SLbool draw3DOptixPT();
219  void startOptixRaytracing(SLint maxDepth);
220  void startOptixPathtracing(SLint maxDepth, SLint samples);
221 #endif
222 
223 protected:
224  SLScene* _s; //!< Pointer to the scene observed by this scene view
225  SLCamera* _camera; //!< Pointer to the _active camera
226  SLCamera _sceneViewCamera; //!< Default camera for this SceneView (default cam not in scenegraph)
227  SLUiInterface* _gui = nullptr; //!< new tighter imgui wrapper
228  SLNodeStats _stats2D; //!< Statistic numbers for 2D nodes
229  SLNodeStats _stats3D; //!< Statistic numbers for 3D nodes
230  SLbool _gotPainted; //!< flag if this sceneview got painted
231  SLRenderType _renderType; //!< rendering type (GL,RT,PT)
232 
233  SLbool _doDepthTest; //!< Flag if depth test is turned on
234  SLbool _doMultiSampling; //!< Flag if multisampling is on
235  SLbool _doFrustumCulling; //!< Flag if view frustum culling is on
236  SLbool _doAlphaSorting; //!< Flag if alpha sorting in blending is on
237  SLbool _doWaitOnIdle; //!< Flag for Event waiting
238  SLbool _isFirstFrame; //!< Flag if it is the first frame rendering
239  SLDrawBits _drawBits; //!< Sceneview level drawing flags
240 
241  SLfloat _shadowMapTimeMS; //!< time for drawing the shadow maps in ms
242  SLfloat _cullTimeMS; //!< time for culling in ms
243  SLfloat _draw3DTimeMS; //!< time for 3D drawing in ms
244  SLfloat _draw2DTimeMS; //!< time for 2D drawing in ms
245 
246  SLbool _mouseDownL; //!< Flag if left mouse button is pressed
247  SLbool _mouseDownR; //!< Flag if right mouse button is pressed
248  SLbool _mouseDownM; //!< Flag if middle mouse button is pressed
249  SLKey _mouseMod; //!< mouse modifier key on key down
250  SLint _touchDowns; //!< finger touch down count
251  SLVec2i _touch[3]; //!< up to 3 finger touch coordinates
252 
253  SLGLVertexArrayExt _vaoTouch; //!< Buffer for touch pos. rendering
254  SLGLVertexArrayExt _vaoCursor; //!< Virtual cursor for stereo rendering
255 
256  SLint _scrW; //!< Screen width in pixels
257  SLint _scrH; //!< Screen height in pixels
258  SLint _scrWdiv2; //!< Screen half width in pixels
259  SLint _scrHdiv2; //!< Screen half height in pixels
260  SLfloat _scrWdivH; //!< Screen side aspect ratio
261  int _dpi; //!< dots per inch of screen
262  SLVec2i _viewportRatio; //!< ratio of viewport
263  SLViewportAlign _viewportAlign; //!< alignment of viewport
264  SLRecti _viewportRect; //!< rectangle of viewport
265  SLbool _viewportSameAsVideo; //!< Adapt viewport aspect to the input video
266  SLbool _screenCaptureIsRequested; //!< Flag if screen capture is requested
267  SLint _screenCaptureWaitFrames; //!< Frames to delay the screen capture
268 
269  SLGLOculusFB _oculusFB; //!< Oculus framebuffer
270 
271  std::unordered_set<SLMaterial*> _visibleMaterials3D; //!< visible materials 3D per frame
272  std::unordered_set<SLMaterial*> _visibleMaterials2D; //!< visible materials 2D per frame
273 
274  SLVNode _nodesOpaque2D; //!< Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D
275  SLVNode _nodesBlended2D; //!< Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D
276  SLVNode _nodesOpaque3D; //!< Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D
277  SLVNode _nodesBlended3D; //!< Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D
278  SLVNode _nodesOverdrawn; //!< Vector of helper nodes drawn over all others
279 
280  SLRaytracer _raytracer; //!< Whitted style raytracer
281  SLbool _stopRT; //!< Flag to stop the RT
282  SLPathtracer _pathtracer; //!< Pathtracer
283  SLbool _stopPT; //!< Flag to stop the PT
284 
285 #ifdef SL_HAS_OPTIX
286  SLOptixRaytracer _optixRaytracer; //!< Whitted style raytracer with Optix
287  SLbool _stopOptixRT; //!< Flag to stop the Optix RT
288  SLOptixPathtracer _optixPathtracer; //!< Path tracer with Optix
289  SLbool _stopOptixPT; //!< Flag to stop the Optix PT
290 #endif
291 
293 
294  AvgFloat _shadowMapTimesMS; //!< Averaged time for drawing the shadow maps in ms
295  AvgFloat _cullTimesMS; //!< Averaged time for culling in ms
296  AvgFloat _draw3DTimesMS; //!< Averaged time for 3D drawing in ms
297  AvgFloat _draw2DTimesMS; //!< Averaged time for 2D drawing in ms
298 };
299 //-----------------------------------------------------------------------------
300 typedef vector<SLSceneView*> SLVSceneView;
301 //-----------------------------------------------------------------------------
302 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
SLProjType
Enumeration for different camera projections.
Definition: SLEnums.h:134
@ P_monoPerspective
standard mono pinhole perspective projection
Definition: SLEnums.h:135
SLRenderType
Rendering type enumeration.
Definition: SLEnums.h:69
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
SLViewportAlign
Mouse button codes.
Definition: SLEnums.h:254
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
typedef void(SL_STDCALL *cbOnImGuiBuild)(SLScene *s
Callback function typedef for ImGui build function.
OpenGL Frame Buffer Object for the Oculus Rift Display.
Extension class with functions for quick line & point drawing.
Wrapper Class around the external ImGui GUI-framework.
deque< SLNode * > SLVNode
SLVNode typedef for a vector of SLNodes.
Definition: SLNode.h:26
void(SL_STDCALL * cbOnSelectNodeMesh)(SLNode *, SLMesh *)
Callback function typedef for select node.
Definition: SLSceneView.h:51
SLbool(SL_STDCALL * cbOnWndUpdate)()
Callback function typedef for GUI window updateRec.
Definition: SLSceneView.h:48
SLSceneView *SL_STDCALL * cbOnNewSceneView(SLScene *s, int dotsPerInch, SLInputManager &inputManager)
Callback function typedef for custom SLSceneView derived creator function.
Definition: SLSceneView.h:43
vector< SLSceneView * > SLVSceneView
Definition: SLSceneView.h:300
Active or visible camera node class.
Definition: SLCamera.h:54
Drawing states stored in the bits of an unsigned int.
Definition: SLDrawBits.h:42
SLbool get(SLuint bit)
Returns the specified bit.
Definition: SLDrawBits.h:69
Wrapper around Oculus Rift and its Frame Buffer Objects.
Definition: SLGLOculusFB.h:25
SLuint height()
Definition: SLGLTexture.h:219
SLuint width()
Definition: SLGLTexture.h:218
SLGLVertexArray adds Helper Functions for quick Line & Point Drawing.
ImGui Interface class for forwarding all events to the original ImGui Handlers.
Definition: SLImGui.h:62
SLInputManager. manages system input and custom input devices.
Abstract Light class for OpenGL light sources.
Definition: SLLight.h:61
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
Base class for all other classes.
Definition: SLObject.h:23
const SLstring & name() const
Definition: SLObject.h:38
Classic Monte Carlo Pathtracing algorithm for real global illumination.
Definition: SLPathtracer.h:18
SLRaytracer hold all the methods for Whitted style Ray Tracing.
Definition: SLRaytracer.h:57
SLint maxDepth() const
Definition: SLRaytracer.h:114
T width
Definition: SLRect.h:29
T height
Definition: SLRect.h:29
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
SLKey _mouseMod
mouse modifier key on key down
Definition: SLSceneView.h:249
SLfloat _draw2DTimeMS
time for 2D drawing in ms
Definition: SLSceneView.h:244
SLbool _screenCaptureIsRequested
Flag if screen capture is requested.
Definition: SLSceneView.h:266
SLPathtracer _pathtracer
Pathtracer.
Definition: SLSceneView.h:282
virtual void onStartup()
Definition: SLSceneView.h:94
AvgFloat & shadowMapTimeMS()
Definition: SLSceneView.h:200
std::unordered_set< SLMaterial * > _visibleMaterials2D
visible materials 2D per frame
Definition: SLSceneView.h:272
void printStats()
Definition: SLSceneView.h:132
SLint _scrW
Screen width in pixels.
Definition: SLSceneView.h:256
void draw3DGLLinesOverlay(SLVNode &nodes)
SLVNode & nodesOpaque2D()
Definition: SLSceneView.h:191
SLDrawBits * drawBits()
Definition: SLSceneView.h:198
SLRecti viewportRect() const
Definition: SLSceneView.h:176
void switchToNextCameraInScene()
Sets the active camera to the next in the scene.
std::unordered_set< SLMaterial * > _visibleMaterials3D
visible materials 3D per frame
Definition: SLSceneView.h:271
virtual void postDraw()
Definition: SLSceneView.h:96
SLbool doWaitOnIdle() const
Definition: SLSceneView.h:188
AvgFloat & draw3DTimesMS()
Definition: SLSceneView.h:203
SLbool screenCaptureIsRequested()
Definition: SLSceneView.h:206
SLbool _stopPT
Flag to stop the PT.
Definition: SLSceneView.h:283
SLNodeStats _stats3D
Statistic numbers for 3D nodes.
Definition: SLSceneView.h:229
SLfloat _scrWdivH
Screen side aspect ratio.
Definition: SLSceneView.h:260
SLint _screenCaptureWaitFrames
Frames to delay the screen capture.
Definition: SLSceneView.h:267
virtual SLbool onDoubleClick(SLMouseButton button, SLint x, SLint y, SLKey mod)
void draw3DGLAll()
SLint _scrH
Screen height in pixels.
Definition: SLSceneView.h:257
void doMultiSampling(SLbool doMS)
Definition: SLSceneView.h:150
SLRaytracer _raytracer
Whitted style raytracer.
Definition: SLSceneView.h:280
SLbool _gotPainted
flag if this sceneview got painted
Definition: SLSceneView.h:230
virtual SLbool onMouseWheelPos(SLint wheelPos, SLKey mod)
SLbool _mouseDownM
Flag if middle mouse button is pressed.
Definition: SLSceneView.h:248
SLint scrHdiv2() const
Definition: SLSceneView.h:173
SLbool isSceneViewCameraActive()
Definition: SLSceneView.h:128
SLVNode _nodesBlended3D
Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D.
Definition: SLSceneView.h:277
SLVNode _nodesOverdrawn
Vector of helper nodes drawn over all others.
Definition: SLSceneView.h:278
void draw3DGLNodes(SLVNode &nodes, SLbool alphaBlended, SLbool depthSorted)
SLint viewportH() const
Definition: SLSceneView.h:180
cbOnWndUpdate onWndUpdate
C-Callback for app for intermediate window repaint.
Definition: SLSceneView.h:141
SLVNode _nodesOpaque2D
Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D.
Definition: SLSceneView.h:274
virtual SLbool onCharInput(SLuint c)
void doDepthTest(SLbool doDT)
Definition: SLSceneView.h:151
SLVNode _nodesBlended2D
Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D.
Definition: SLSceneView.h:275
SLbool doDepthTest() const
Definition: SLSceneView.h:187
SLbool _doMultiSampling
Flag if multisampling is on.
Definition: SLSceneView.h:234
SLRenderType _renderType
rendering type (GL,RT,PT)
Definition: SLSceneView.h:231
SLGLOculusFB _oculusFB
Oculus framebuffer.
Definition: SLSceneView.h:269
void draw3DGLLines(SLVNode &nodes)
SLVNode & nodesOpaque3D()
Definition: SLSceneView.h:189
void startPathtracing(SLint maxDepth, SLint samples)
SLVNode & nodesBlended2D()
Definition: SLSceneView.h:192
void onResize(SLint width, SLint height)
SLNodeStats & stats3D()
Definition: SLSceneView.h:205
SLfloat scrWdivH() const
Definition: SLSceneView.h:174
cbOnSelectNodeMesh onSelectedNodeMesh
C-Callback for app on node selection.
Definition: SLSceneView.h:142
SLbool _mouseDownL
Flag if left mouse button is pressed.
Definition: SLSceneView.h:246
void switchToSceneViewCamera()
virtual void postSceneLoad()
Definition: SLSceneView.h:97
std::unordered_set< SLMaterial * > & visibleMaterials3D()
Definition: SLSceneView.h:209
SLint scrW() const
Definition: SLSceneView.h:170
SLRecti _viewportRect
rectangle of viewport
Definition: SLSceneView.h:264
AvgFloat & draw2DTimesMS()
Definition: SLSceneView.h:202
SLVNode _nodesOpaque3D
Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D.
Definition: SLSceneView.h:276
SLGLVertexArrayExt _vaoTouch
Buffer for touch pos. rendering.
Definition: SLSceneView.h:253
SLUiInterface * _gui
new tighter imgui wrapper
Definition: SLSceneView.h:227
SLbool doFrustumCulling() const
Definition: SLSceneView.h:184
SLViewportAlign _viewportAlign
alignment of viewport
Definition: SLSceneView.h:263
SLbool _doFrustumCulling
Flag if view frustum culling is on.
Definition: SLSceneView.h:235
SLfloat _draw3DTimeMS
time for 3D drawing in ms
Definition: SLSceneView.h:243
SLint _scrWdiv2
Screen half width in pixels.
Definition: SLSceneView.h:258
void draw2DGLNodes()
SLbool _doWaitOnIdle
Flag for Event waiting.
Definition: SLSceneView.h:237
virtual SLbool onMouseMove(SLint x, SLint y)
friend class SLOptixRaytracer
Definition: SLSceneView.h:72
virtual void preDraw()
Definition: SLSceneView.h:95
SLbool draw3DPT()
SLbool _doAlphaSorting
Flag if alpha sorting in blending is on.
Definition: SLSceneView.h:236
SLint _scrHdiv2
Screen half height in pixels.
Definition: SLSceneView.h:259
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
AvgFloat _shadowMapTimesMS
Averaged time for drawing the shadow maps in ms.
Definition: SLSceneView.h:294
SLGLOculusFB * oculusFB()
Definition: SLSceneView.h:197
SLstring windowTitle()
SLNodeStats _stats2D
Statistic numbers for 2D nodes.
Definition: SLSceneView.h:228
SLbool _mouseDownR
Flag if right mouse button is pressed.
Definition: SLSceneView.h:247
void init(SLstring name, SLint screenWidth, SLint screenHeight, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, SLUiInterface *gui, const string &configPath)
Definition: SLSceneView.cpp:64
SLbool doMultiSampling() const
Definition: SLSceneView.h:186
SLint viewportW() const
Definition: SLSceneView.h:179
SLPathtracer * pathtracer()
Definition: SLSceneView.h:195
void viewportSameAsVideo(bool sameAsVideo)
Definition: SLSceneView.h:155
void startRaytracing(SLint maxDepth)
SLbool drawBit(SLuint bit)
Definition: SLSceneView.h:199
void initSceneViewCamera(const SLVec3f &dir=-SLVec3f::AXISZ, SLProjType proj=P_monoPerspective)
void renderType(SLRenderType rt)
Definition: SLSceneView.h:154
AvgFloat & cullTimesMS()
Definition: SLSceneView.h:201
virtual SLbool onKeyRelease(SLKey key, SLKey mod)
SLbool doAlphaSorting() const
Definition: SLSceneView.h:185
SLbool draw3DCT()
SLRenderType renderType() const
Definition: SLSceneView.h:196
SLbool _viewportSameAsVideo
Adapt viewport aspect to the input video.
Definition: SLSceneView.h:265
SLbool _doDepthTest
Flag if depth test is turned on.
Definition: SLSceneView.h:233
SLbool _isFirstFrame
Flag if it is the first frame rendering.
Definition: SLSceneView.h:238
void saveFrameBufferAsImage(SLstring pathFilename, cv::Size targetSize=cv::Size(-1, -1))
Saves after n wait frames the front frame buffer as a PNG image.
~SLSceneView() override
Definition: SLSceneView.cpp:51
SLint dpi() const
Definition: SLSceneView.h:175
SLSceneView(SLScene *s, int dpi, SLInputManager &inputManager)
SLSceneView default constructor.
Definition: SLSceneView.cpp:37
void doAlphaSorting(SLbool doAS)
Definition: SLSceneView.h:153
AvgFloat _cullTimesMS
Averaged time for culling in ms.
Definition: SLSceneView.h:295
SLbool draw3DRT()
SLint scrH() const
Definition: SLSceneView.h:171
void onInitialize()
SLVNode & nodesBlended3D()
Definition: SLSceneView.h:190
virtual SLbool onMouseWheel(SLint delta, SLKey mod)
SLGLVertexArrayExt _vaoCursor
Virtual cursor for stereo rendering.
Definition: SLSceneView.h:254
SLint _touchDowns
finger touch down count
Definition: SLSceneView.h:250
SLbool onPaint()
SLVec2i _touch[3]
up to 3 finger touch coordinates
Definition: SLSceneView.h:251
SLInputManager & _inputManager
Definition: SLSceneView.h:292
SLCamera _sceneViewCamera
Default camera for this SceneView (default cam not in scenegraph)
Definition: SLSceneView.h:226
AvgFloat _draw2DTimesMS
Averaged time for 2D drawing in ms.
Definition: SLSceneView.h:297
SLfloat _cullTimeMS
time for culling in ms
Definition: SLSceneView.h:242
SLVec2i viewportRatio() const
Definition: SLSceneView.h:177
SLRaytracer * raytracer()
Definition: SLSceneView.h:194
SLNodeStats & stats2D()
Definition: SLSceneView.h:204
SLVec2i _viewportRatio
ratio of viewport
Definition: SLSceneView.h:262
int _dpi
dots per inch of screen
Definition: SLSceneView.h:261
virtual SLbool onTouch2Move(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
virtual SLbool onMouseUp(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
SLVNode & nodesOverdrawn()
Definition: SLSceneView.h:193
SLScene * _s
Pointer to the scene observed by this scene view.
Definition: SLSceneView.h:224
SLfloat _shadowMapTimeMS
time for drawing the shadow maps in ms
Definition: SLSceneView.h:241
void setViewportFromRatio(const SLVec2i &vpRatio, SLViewportAlign vpAlignment, SLbool vpSameAsVideo)
Sets the viewport ratio and the viewport rectangle.
virtual SLbool onKeyPress(SLKey key, SLKey mod)
void scene(SLScene *scene)
Definition: SLSceneView.h:146
AvgFloat _draw3DTimesMS
Averaged time for 3D drawing in ms.
Definition: SLSceneView.h:296
virtual SLbool onMouseDown(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
void scrW(SLint scrW)
Definition: SLSceneView.h:147
SLViewportAlign viewportAlign() const
Definition: SLSceneView.h:181
SLScene * s()
Definition: SLSceneView.h:167
SLfloat viewportWdivH() const
Definition: SLSceneView.h:178
void doFrustumCulling(SLbool doFC)
Definition: SLSceneView.h:152
SLbool viewportSameAsVideo() const
Definition: SLSceneView.h:182
SLCamera * camera()
Definition: SLSceneView.h:168
SLint scrWdiv2() const
Definition: SLSceneView.h:172
virtual SLbool onTouch2Up(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
SLCamera * _camera
Pointer to the _active camera.
Definition: SLSceneView.h:225
void doWaitOnIdle(SLbool doWI)
Definition: SLSceneView.h:149
void screenCaptureIsRequested(bool doScreenCap)
Definition: SLSceneView.h:156
SLDrawBits _drawBits
Sceneview level drawing flags.
Definition: SLSceneView.h:239
SLbool _stopRT
Flag to stop the RT.
Definition: SLSceneView.h:281
void scrH(SLint scrH)
Definition: SLSceneView.h:148
std::unordered_set< SLMaterial * > & visibleMaterials2D()
Definition: SLSceneView.h:208
SLCamera * sceneViewCamera()
Definition: SLSceneView.h:169
SLbool draw3DGL(SLfloat elapsedTimeSec)
Draws the 3D scene with OpenGL.
virtual SLbool onTouch2Down(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
SLUiInterface * gui()
Definition: SLSceneView.h:183
Interface for ui integration in SLSceneView.
Definition: SLUiInterface.h:24
virtual void drawMouseCursor(bool doDraw)
Turns on or off the mouse cursor drawing.
Definition: SLUiInterface.h:67
static SLVec3 AXISZ
Definition: SLVec3.h:299
T mod(T a, T b)
Definition: Utils.h:250
Struct for scene graph statistics.
Definition: SLNode.h:37
void print() const
Prints all statistic informations on the std out stream.
Definition: SLNode.h:73