SLProject  4.3.020
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  //! Starts the path tracer. maxDepth is only a safety net against an
135  /*! endless specular chain: since SLPathtracer uses Russian roulette, the
136  length of a path is decided by the albedo of the surfaces it meets and
137  virtually no path reaches this cap. */
138  void startPathtracing(SLint maxDepth, SLint samples);
139  void setViewportFromRatio(const SLVec2i& vpRatio,
140  SLViewportAlign vpAlignment,
141  SLbool vpSameAsVideo);
142  void saveFrameBufferAsImage(SLstring pathFilename, cv::Size targetSize = cv::Size(-1, -1));
143 
144  // Callback routines
145  cbOnWndUpdate onWndUpdate; //!< C-Callback for app for intermediate window repaint
146  cbOnSelectNodeMesh onSelectedNodeMesh; //!< C-Callback for app on node selection
147 
148  // Setters
150  void scene(SLScene* scene) { _s = scene; }
151  void scrW(SLint scrW) { _scrW = scrW; }
152  void scrH(SLint scrH) { _scrH = scrH; }
153  void doWaitOnIdle(SLbool doWI) { _doWaitOnIdle = doWI; }
154  void doMultiSampling(SLbool doMS) { _doMultiSampling = doMS; }
155  void doDepthTest(SLbool doDT) { _doDepthTest = doDT; }
157  void doAlphaSorting(SLbool doAS) { _doAlphaSorting = doAS; }
159  void viewportSameAsVideo(bool sameAsVideo) { _viewportSameAsVideo = sameAsVideo; }
160  void screenCaptureIsRequested(bool doScreenCap)
161  {
162  if (doScreenCap)
163  {
164  _gui->drawMouseCursor(false);
166  }
167  _screenCaptureIsRequested = doScreenCap;
168  }
169 
170  // Getters
171  SLScene* s() { return _s; }
172  SLCamera* camera() { return _camera; }
174  SLint scrW() const { return _scrW; }
175  SLint scrH() const { return _scrH; }
176  SLint scrWdiv2() const { return _scrWdiv2; }
177  SLint scrHdiv2() const { return _scrHdiv2; }
178  SLfloat scrWdivH() const { return _scrWdivH; }
179  SLint dpi() const { return _dpi; }
180  SLRecti viewportRect() const { return _viewportRect; }
182  SLfloat viewportWdivH() const { return (float)_viewportRect.width / (float)_viewportRect.height; }
183  SLint viewportW() const { return _viewportRect.width; }
184  SLint viewportH() const { return _viewportRect.height; }
187  SLUiInterface* gui() { return _gui; }
191  SLbool doDepthTest() const { return _doDepthTest; }
192  SLbool doWaitOnIdle() const { return _doWaitOnIdle; }
200  SLRenderType renderType() const { return _renderType; }
202  SLDrawBits* drawBits() { return &_drawBits; }
203  SLbool drawBit(SLuint bit) { return _drawBits.get(bit); }
208  SLNodeStats& stats2D() { return _stats2D; }
209  SLNodeStats& stats3D() { return _stats3D; }
211 
212  std::unordered_set<SLMaterial*>& visibleMaterials2D() { return _visibleMaterials2D; }
213  std::unordered_set<SLMaterial*>& visibleMaterials3D() { return _visibleMaterials3D; }
214 
215 #ifdef SL_HAS_OPTIX
216  SLOptixRaytracer* optixRaytracer()
217  {
218  return &_optixRaytracer;
219  }
220  SLOptixPathtracer* optixPathtracer() { return &_optixPathtracer; }
221  SLbool draw3DOptixRT();
222  SLbool draw3DOptixPT();
223  void startOptixRaytracing(SLint maxDepth);
224  void startOptixPathtracing(SLint maxDepth, SLint samples);
225 #endif
226 
227 protected:
228  SLScene* _s; //!< Pointer to the scene observed by this scene view
229  SLCamera* _camera; //!< Pointer to the _active camera
230  SLCamera _sceneViewCamera; //!< Default camera for this SceneView (default cam not in scenegraph)
231  SLUiInterface* _gui = nullptr; //!< new tighter imgui wrapper
232  SLNodeStats _stats2D; //!< Statistic numbers for 2D nodes
233  SLNodeStats _stats3D; //!< Statistic numbers for 3D nodes
234  SLbool _gotPainted; //!< flag if this sceneview got painted
235  SLRenderType _renderType; //!< rendering type (GL,RT,PT)
236 
237  SLbool _doDepthTest; //!< Flag if depth test is turned on
238  SLbool _doMultiSampling; //!< Flag if multisampling is on
239  SLbool _doFrustumCulling; //!< Flag if view frustum culling is on
240  SLbool _doAlphaSorting; //!< Flag if alpha sorting in blending is on
241  SLbool _doWaitOnIdle; //!< Flag for Event waiting
242  SLbool _isFirstFrame; //!< Flag if it is the first frame rendering
243  SLDrawBits _drawBits; //!< Sceneview level drawing flags
244 
245  SLfloat _shadowMapTimeMS; //!< time for drawing the shadow maps in ms
246  SLfloat _cullTimeMS; //!< time for culling in ms
247  SLfloat _draw3DTimeMS; //!< time for 3D drawing in ms
248  SLfloat _draw2DTimeMS; //!< time for 2D drawing in ms
249 
250  SLbool _mouseDownL; //!< Flag if left mouse button is pressed
251  SLbool _mouseDownR; //!< Flag if right mouse button is pressed
252  SLbool _mouseDownM; //!< Flag if middle mouse button is pressed
253  SLKey _mouseMod; //!< mouse modifier key on key down
254  SLint _touchDowns; //!< finger touch down count
255  SLVec2i _touch[3]; //!< up to 3 finger touch coordinates
256 
257  SLGLVertexArrayExt _vaoTouch; //!< Buffer for touch pos. rendering
258  SLGLVertexArrayExt _vaoCursor; //!< Virtual cursor for stereo rendering
259 
260  SLint _scrW; //!< Screen width in pixels
261  SLint _scrH; //!< Screen height in pixels
262  SLint _scrWdiv2; //!< Screen half width in pixels
263  SLint _scrHdiv2; //!< Screen half height in pixels
264  SLfloat _scrWdivH; //!< Screen side aspect ratio
265  int _dpi; //!< dots per inch of screen
266  SLVec2i _viewportRatio; //!< ratio of viewport
267  SLViewportAlign _viewportAlign; //!< alignment of viewport
268  SLRecti _viewportRect; //!< rectangle of viewport
269  SLbool _viewportSameAsVideo; //!< Adapt viewport aspect to the input video
270  SLbool _screenCaptureIsRequested; //!< Flag if screen capture is requested
271  SLint _screenCaptureWaitFrames; //!< Frames to delay the screen capture
272 
273  SLGLOculusFB _oculusFB; //!< Oculus framebuffer
274 
275  std::unordered_set<SLMaterial*> _visibleMaterials3D; //!< visible materials 3D per frame
276  std::unordered_set<SLMaterial*> _visibleMaterials2D; //!< visible materials 2D per frame
277 
278  SLVNode _nodesOpaque2D; //!< Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D
279  SLVNode _nodesBlended2D; //!< Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D
280  SLVNode _nodesOpaque3D; //!< Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D
281  SLVNode _nodesBlended3D; //!< Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D
282  SLVNode _nodesOverdrawn; //!< Vector of helper nodes drawn over all others
283 
284  SLRaytracer _raytracer; //!< Whitted style raytracer
285  SLbool _stopRT; //!< Flag to stop the RT
286  SLPathtracer _pathtracer; //!< Pathtracer
287  SLbool _stopPT; //!< Flag to stop the PT
288 
289 #ifdef SL_HAS_OPTIX
290  SLOptixRaytracer _optixRaytracer; //!< Whitted style raytracer with Optix
291  SLbool _stopOptixRT; //!< Flag to stop the Optix RT
292  SLOptixPathtracer _optixPathtracer; //!< Path tracer with Optix
293  SLbool _stopOptixPT; //!< Flag to stop the Optix PT
294 #endif
295 
297 
298  AvgFloat _shadowMapTimesMS; //!< Averaged time for drawing the shadow maps in ms
299  AvgFloat _cullTimesMS; //!< Averaged time for culling in ms
300  AvgFloat _draw3DTimesMS; //!< Averaged time for 3D drawing in ms
301  AvgFloat _draw2DTimesMS; //!< Averaged time for 2D drawing in ms
302 };
303 //-----------------------------------------------------------------------------
304 typedef vector<SLSceneView*> SLVSceneView;
305 //-----------------------------------------------------------------------------
306 #endif
float SLfloat
analog to GLfloat
Definition: SL.h:200
unsigned int SLuint
analog to GLuint
Definition: SL.h:198
bool SLbool
analog to GLbool
Definition: SL.h:202
string SLstring
Redefinition of standard types for platform independence.
Definition: SL.h:185
int SLint
analog to GLint
Definition: SL.h:197
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:27
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:304
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:148
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:58
SLint maxDepth() const
Definition: SLRaytracer.h:115
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:253
SLfloat _draw2DTimeMS
time for 2D drawing in ms
Definition: SLSceneView.h:248
SLbool _screenCaptureIsRequested
Flag if screen capture is requested.
Definition: SLSceneView.h:270
SLPathtracer _pathtracer
Pathtracer.
Definition: SLSceneView.h:286
virtual void onStartup()
Definition: SLSceneView.h:94
AvgFloat & shadowMapTimeMS()
Definition: SLSceneView.h:204
std::unordered_set< SLMaterial * > _visibleMaterials2D
visible materials 2D per frame
Definition: SLSceneView.h:276
void printStats()
Definition: SLSceneView.h:132
SLint _scrW
Screen width in pixels.
Definition: SLSceneView.h:260
void draw3DGLLinesOverlay(SLVNode &nodes)
SLVNode & nodesOpaque2D()
Definition: SLSceneView.h:195
SLDrawBits * drawBits()
Definition: SLSceneView.h:202
SLRecti viewportRect() const
Definition: SLSceneView.h:180
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:275
virtual void postDraw()
Definition: SLSceneView.h:96
SLbool doWaitOnIdle() const
Definition: SLSceneView.h:192
AvgFloat & draw3DTimesMS()
Definition: SLSceneView.h:207
SLbool screenCaptureIsRequested()
Definition: SLSceneView.h:210
SLbool _stopPT
Flag to stop the PT.
Definition: SLSceneView.h:287
SLNodeStats _stats3D
Statistic numbers for 3D nodes.
Definition: SLSceneView.h:233
SLfloat _scrWdivH
Screen side aspect ratio.
Definition: SLSceneView.h:264
SLint _screenCaptureWaitFrames
Frames to delay the screen capture.
Definition: SLSceneView.h:271
virtual SLbool onDoubleClick(SLMouseButton button, SLint x, SLint y, SLKey mod)
void draw3DGLAll()
SLint _scrH
Screen height in pixels.
Definition: SLSceneView.h:261
void doMultiSampling(SLbool doMS)
Definition: SLSceneView.h:154
SLRaytracer _raytracer
Whitted style raytracer.
Definition: SLSceneView.h:284
SLbool _gotPainted
flag if this sceneview got painted
Definition: SLSceneView.h:234
virtual SLbool onMouseWheelPos(SLint wheelPos, SLKey mod)
SLbool _mouseDownM
Flag if middle mouse button is pressed.
Definition: SLSceneView.h:252
SLint scrHdiv2() const
Definition: SLSceneView.h:177
SLbool isSceneViewCameraActive()
Definition: SLSceneView.h:128
SLVNode _nodesBlended3D
Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D.
Definition: SLSceneView.h:281
SLVNode _nodesOverdrawn
Vector of helper nodes drawn over all others.
Definition: SLSceneView.h:282
void draw3DGLNodes(SLVNode &nodes, SLbool alphaBlended, SLbool depthSorted)
SLint viewportH() const
Definition: SLSceneView.h:184
cbOnWndUpdate onWndUpdate
C-Callback for app for intermediate window repaint.
Definition: SLSceneView.h:145
SLVNode _nodesOpaque2D
Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D.
Definition: SLSceneView.h:278
virtual SLbool onCharInput(SLuint c)
void doDepthTest(SLbool doDT)
Definition: SLSceneView.h:155
SLVNode _nodesBlended2D
Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D.
Definition: SLSceneView.h:279
SLbool doDepthTest() const
Definition: SLSceneView.h:191
SLbool _doMultiSampling
Flag if multisampling is on.
Definition: SLSceneView.h:238
SLRenderType _renderType
rendering type (GL,RT,PT)
Definition: SLSceneView.h:235
SLGLOculusFB _oculusFB
Oculus framebuffer.
Definition: SLSceneView.h:273
void draw3DGLLines(SLVNode &nodes)
SLVNode & nodesOpaque3D()
Definition: SLSceneView.h:193
void startPathtracing(SLint maxDepth, SLint samples)
Starts the path tracer. maxDepth is only a safety net against an.
SLVNode & nodesBlended2D()
Definition: SLSceneView.h:196
void onResize(SLint width, SLint height)
SLNodeStats & stats3D()
Definition: SLSceneView.h:209
SLfloat scrWdivH() const
Definition: SLSceneView.h:178
cbOnSelectNodeMesh onSelectedNodeMesh
C-Callback for app on node selection.
Definition: SLSceneView.h:146
SLbool _mouseDownL
Flag if left mouse button is pressed.
Definition: SLSceneView.h:250
void switchToSceneViewCamera()
virtual void postSceneLoad()
Definition: SLSceneView.h:97
std::unordered_set< SLMaterial * > & visibleMaterials3D()
Definition: SLSceneView.h:213
SLint scrW() const
Definition: SLSceneView.h:174
SLRecti _viewportRect
rectangle of viewport
Definition: SLSceneView.h:268
AvgFloat & draw2DTimesMS()
Definition: SLSceneView.h:206
SLVNode _nodesOpaque3D
Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D.
Definition: SLSceneView.h:280
SLGLVertexArrayExt _vaoTouch
Buffer for touch pos. rendering.
Definition: SLSceneView.h:257
SLUiInterface * _gui
new tighter imgui wrapper
Definition: SLSceneView.h:231
SLbool doFrustumCulling() const
Definition: SLSceneView.h:188
SLViewportAlign _viewportAlign
alignment of viewport
Definition: SLSceneView.h:267
SLbool _doFrustumCulling
Flag if view frustum culling is on.
Definition: SLSceneView.h:239
SLfloat _draw3DTimeMS
time for 3D drawing in ms
Definition: SLSceneView.h:247
SLint _scrWdiv2
Screen half width in pixels.
Definition: SLSceneView.h:262
void draw2DGLNodes()
SLbool _doWaitOnIdle
Flag for Event waiting.
Definition: SLSceneView.h:241
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:240
SLint _scrHdiv2
Screen half height in pixels.
Definition: SLSceneView.h:263
void camera(SLCamera *camera)
Definition: SLSceneView.h:149
AvgFloat _shadowMapTimesMS
Averaged time for drawing the shadow maps in ms.
Definition: SLSceneView.h:298
SLGLOculusFB * oculusFB()
Definition: SLSceneView.h:201
SLstring windowTitle()
SLNodeStats _stats2D
Statistic numbers for 2D nodes.
Definition: SLSceneView.h:232
SLbool _mouseDownR
Flag if right mouse button is pressed.
Definition: SLSceneView.h:251
void init(SLstring name, SLint screenWidth, SLint screenHeight, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, SLUiInterface *gui, const string &configPath)
Definition: SLSceneView.cpp:67
SLbool doMultiSampling() const
Definition: SLSceneView.h:190
SLint viewportW() const
Definition: SLSceneView.h:183
SLPathtracer * pathtracer()
Definition: SLSceneView.h:199
void viewportSameAsVideo(bool sameAsVideo)
Definition: SLSceneView.h:159
void startRaytracing(SLint maxDepth)
SLbool drawBit(SLuint bit)
Definition: SLSceneView.h:203
void initSceneViewCamera(const SLVec3f &dir=-SLVec3f::AXISZ, SLProjType proj=P_monoPerspective)
void renderType(SLRenderType rt)
Definition: SLSceneView.h:158
AvgFloat & cullTimesMS()
Definition: SLSceneView.h:205
virtual SLbool onKeyRelease(SLKey key, SLKey mod)
SLbool doAlphaSorting() const
Definition: SLSceneView.h:189
SLbool draw3DCT()
SLRenderType renderType() const
Definition: SLSceneView.h:200
SLbool _viewportSameAsVideo
Adapt viewport aspect to the input video.
Definition: SLSceneView.h:269
SLbool _doDepthTest
Flag if depth test is turned on.
Definition: SLSceneView.h:237
SLbool _isFirstFrame
Flag if it is the first frame rendering.
Definition: SLSceneView.h:242
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:54
SLint dpi() const
Definition: SLSceneView.h:179
SLSceneView(SLScene *s, int dpi, SLInputManager &inputManager)
SLSceneView default constructor.
Definition: SLSceneView.cpp:40
void doAlphaSorting(SLbool doAS)
Definition: SLSceneView.h:157
AvgFloat _cullTimesMS
Averaged time for culling in ms.
Definition: SLSceneView.h:299
SLbool draw3DRT()
SLint scrH() const
Definition: SLSceneView.h:175
void onInitialize()
SLVNode & nodesBlended3D()
Definition: SLSceneView.h:194
virtual SLbool onMouseWheel(SLint delta, SLKey mod)
SLGLVertexArrayExt _vaoCursor
Virtual cursor for stereo rendering.
Definition: SLSceneView.h:258
SLint _touchDowns
finger touch down count
Definition: SLSceneView.h:254
SLbool onPaint()
SLVec2i _touch[3]
up to 3 finger touch coordinates
Definition: SLSceneView.h:255
SLInputManager & _inputManager
Definition: SLSceneView.h:296
SLCamera _sceneViewCamera
Default camera for this SceneView (default cam not in scenegraph)
Definition: SLSceneView.h:230
AvgFloat _draw2DTimesMS
Averaged time for 2D drawing in ms.
Definition: SLSceneView.h:301
SLfloat _cullTimeMS
time for culling in ms
Definition: SLSceneView.h:246
SLVec2i viewportRatio() const
Definition: SLSceneView.h:181
SLRaytracer * raytracer()
Definition: SLSceneView.h:198
SLNodeStats & stats2D()
Definition: SLSceneView.h:208
SLVec2i _viewportRatio
ratio of viewport
Definition: SLSceneView.h:266
int _dpi
dots per inch of screen
Definition: SLSceneView.h:265
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:197
SLScene * _s
Pointer to the scene observed by this scene view.
Definition: SLSceneView.h:228
SLfloat _shadowMapTimeMS
time for drawing the shadow maps in ms
Definition: SLSceneView.h:245
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:150
AvgFloat _draw3DTimesMS
Averaged time for 3D drawing in ms.
Definition: SLSceneView.h:300
virtual SLbool onMouseDown(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
void scrW(SLint scrW)
Definition: SLSceneView.h:151
SLViewportAlign viewportAlign() const
Definition: SLSceneView.h:185
SLScene * s()
Definition: SLSceneView.h:171
SLfloat viewportWdivH() const
Definition: SLSceneView.h:182
void doFrustumCulling(SLbool doFC)
Definition: SLSceneView.h:156
SLbool viewportSameAsVideo() const
Definition: SLSceneView.h:186
SLCamera * camera()
Definition: SLSceneView.h:172
SLint scrWdiv2() const
Definition: SLSceneView.h:176
virtual SLbool onTouch2Up(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
SLCamera * _camera
Pointer to the _active camera.
Definition: SLSceneView.h:229
void doWaitOnIdle(SLbool doWI)
Definition: SLSceneView.h:153
void screenCaptureIsRequested(bool doScreenCap)
Definition: SLSceneView.h:160
SLDrawBits _drawBits
Sceneview level drawing flags.
Definition: SLSceneView.h:243
SLbool _stopRT
Flag to stop the RT.
Definition: SLSceneView.h:285
void scrH(SLint scrH)
Definition: SLSceneView.h:152
std::unordered_set< SLMaterial * > & visibleMaterials2D()
Definition: SLSceneView.h:212
SLCamera * sceneViewCamera()
Definition: SLSceneView.h:173
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:187
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:38
void print() const
Prints all statistic informations on the std out stream.
Definition: SLNode.h:74