SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoSceneView Class Reference

#include <AppDemoSceneView.h>

Inheritance diagram for AppDemoSceneView:
[legend]

Public Member Functions

 AppDemoSceneView (SLScene *s, int dpi, SLInputManager &inputManager)
 
SLbool onKeyPress (SLKey key, SLKey mod) final
 
SLbool onKeyRelease (SLKey key, SLKey mod) final
 
SLbool onMouseDown (SLMouseButton button, SLint x, SLint y, SLKey mod) final
 
- Public Member Functions inherited from SLSceneView
 SLSceneView (SLScene *s, int dpi, SLInputManager &inputManager)
 SLSceneView default constructor. More...
 
 ~SLSceneView () override
 
void init (SLstring name, SLint screenWidth, SLint screenHeight, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, SLUiInterface *gui, const string &configPath)
 
void unInit ()
 
void onInitialize ()
 
SLbool onPaint ()
 
void onResize (SLint width, SLint height)
 
virtual void onStartup ()
 
virtual void preDraw ()
 
virtual void postDraw ()
 
virtual void postSceneLoad ()
 
virtual SLbool onMouseUp (SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
 
virtual SLbool onMouseMove (SLint x, SLint y)
 
virtual SLbool onMouseWheelPos (SLint wheelPos, SLKey mod)
 
virtual SLbool onMouseWheel (SLint delta, SLKey mod)
 
virtual SLbool onTouch2Down (SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
 
virtual SLbool onTouch2Move (SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
 
virtual SLbool onTouch2Up (SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
 
virtual SLbool onDoubleClick (SLMouseButton button, SLint x, SLint y, SLKey mod)
 
virtual SLbool onCharInput (SLuint c)
 
SLbool draw3DGL (SLfloat elapsedTimeSec)
 Draws the 3D scene with OpenGL. More...
 
void draw3DGLAll ()
 
void draw3DGLNodes (SLVNode &nodes, SLbool alphaBlended, SLbool depthSorted)
 
void draw3DGLLines (SLVNode &nodes)
 
void draw3DGLLinesOverlay (SLVNode &nodes)
 
void draw2DGL ()
 
void draw2DGLNodes ()
 
SLbool draw3DRT ()
 
SLbool draw3DPT ()
 
SLbool draw3DCT ()
 
void initSceneViewCamera (const SLVec3f &dir=-SLVec3f::AXISZ, SLProjType proj=P_monoPerspective)
 
void switchToSceneViewCamera ()
 
void switchToNextCameraInScene ()
 Sets the active camera to the next in the scene. More...
 
SLbool isSceneViewCameraActive ()
 
SLstring windowTitle ()
 
void printStats ()
 
void startRaytracing (SLint maxDepth)
 
void startPathtracing (SLint maxDepth, SLint samples)
 
void setViewportFromRatio (const SLVec2i &vpRatio, SLViewportAlign vpAlignment, SLbool vpSameAsVideo)
 Sets the viewport ratio and the viewport rectangle. More...
 
void saveFrameBufferAsImage (SLstring pathFilename, cv::Size targetSize=cv::Size(-1, -1))
 Saves after n wait frames the front frame buffer as a PNG image. More...
 
void camera (SLCamera *camera)
 
void scene (SLScene *scene)
 
void scrW (SLint scrW)
 
void scrH (SLint scrH)
 
void doWaitOnIdle (SLbool doWI)
 
void doMultiSampling (SLbool doMS)
 
void doDepthTest (SLbool doDT)
 
void doFrustumCulling (SLbool doFC)
 
void doAlphaSorting (SLbool doAS)
 
void renderType (SLRenderType rt)
 
void viewportSameAsVideo (bool sameAsVideo)
 
void screenCaptureIsRequested (bool doScreenCap)
 
SLScenes ()
 
SLCameracamera ()
 
SLCamerasceneViewCamera ()
 
SLint scrW () const
 
SLint scrH () const
 
SLint scrWdiv2 () const
 
SLint scrHdiv2 () const
 
SLfloat scrWdivH () const
 
SLint dpi () const
 
SLRecti viewportRect () const
 
SLVec2i viewportRatio () const
 
SLfloat viewportWdivH () const
 
SLint viewportW () const
 
SLint viewportH () const
 
SLViewportAlign viewportAlign () const
 
SLbool viewportSameAsVideo () const
 
SLUiInterfacegui ()
 
SLbool doFrustumCulling () const
 
SLbool doAlphaSorting () const
 
SLbool doMultiSampling () const
 
SLbool doDepthTest () const
 
SLbool doWaitOnIdle () const
 
SLVNodenodesOpaque3D ()
 
SLVNodenodesBlended3D ()
 
SLVNodenodesOpaque2D ()
 
SLVNodenodesBlended2D ()
 
SLVNodenodesOverdrawn ()
 
SLRaytracerraytracer ()
 
SLPathtracerpathtracer ()
 
SLRenderType renderType () const
 
SLGLOculusFBoculusFB ()
 
SLDrawBitsdrawBits ()
 
SLbool drawBit (SLuint bit)
 
AvgFloatshadowMapTimeMS ()
 
AvgFloatcullTimesMS ()
 
AvgFloatdraw2DTimesMS ()
 
AvgFloatdraw3DTimesMS ()
 
SLNodeStatsstats2D ()
 
SLNodeStatsstats3D ()
 
SLbool screenCaptureIsRequested ()
 
std::unordered_set< SLMaterial * > & visibleMaterials2D ()
 
std::unordered_set< SLMaterial * > & visibleMaterials3D ()
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Public Attributes

SLbool grab = false
 
- Public Attributes inherited from SLSceneView
cbOnWndUpdate onWndUpdate
 C-Callback for app for intermediate window repaint. More...
 
cbOnSelectNodeMesh onSelectedNodeMesh
 C-Callback for app on node selection. More...
 

Additional Inherited Members

- Protected Attributes inherited from SLSceneView
SLScene_s
 Pointer to the scene observed by this scene view. More...
 
SLCamera_camera
 Pointer to the _active camera. More...
 
SLCamera _sceneViewCamera
 Default camera for this SceneView (default cam not in scenegraph) More...
 
SLUiInterface_gui = nullptr
 new tighter imgui wrapper More...
 
SLNodeStats _stats2D
 Statistic numbers for 2D nodes. More...
 
SLNodeStats _stats3D
 Statistic numbers for 3D nodes. More...
 
SLbool _gotPainted
 flag if this sceneview got painted More...
 
SLRenderType _renderType
 rendering type (GL,RT,PT) More...
 
SLbool _doDepthTest
 Flag if depth test is turned on. More...
 
SLbool _doMultiSampling
 Flag if multisampling is on. More...
 
SLbool _doFrustumCulling
 Flag if view frustum culling is on. More...
 
SLbool _doAlphaSorting
 Flag if alpha sorting in blending is on. More...
 
SLbool _doWaitOnIdle
 Flag for Event waiting. More...
 
SLbool _isFirstFrame
 Flag if it is the first frame rendering. More...
 
SLDrawBits _drawBits
 Sceneview level drawing flags. More...
 
SLfloat _shadowMapTimeMS
 time for drawing the shadow maps in ms More...
 
SLfloat _cullTimeMS
 time for culling in ms More...
 
SLfloat _draw3DTimeMS
 time for 3D drawing in ms More...
 
SLfloat _draw2DTimeMS
 time for 2D drawing in ms More...
 
SLbool _mouseDownL
 Flag if left mouse button is pressed. More...
 
SLbool _mouseDownR
 Flag if right mouse button is pressed. More...
 
SLbool _mouseDownM
 Flag if middle mouse button is pressed. More...
 
SLKey _mouseMod
 mouse modifier key on key down More...
 
SLint _touchDowns
 finger touch down count More...
 
SLVec2i _touch [3]
 up to 3 finger touch coordinates More...
 
SLGLVertexArrayExt _vaoTouch
 Buffer for touch pos. rendering. More...
 
SLGLVertexArrayExt _vaoCursor
 Virtual cursor for stereo rendering. More...
 
SLint _scrW
 Screen width in pixels. More...
 
SLint _scrH
 Screen height in pixels. More...
 
SLint _scrWdiv2
 Screen half width in pixels. More...
 
SLint _scrHdiv2
 Screen half height in pixels. More...
 
SLfloat _scrWdivH
 Screen side aspect ratio. More...
 
int _dpi
 dots per inch of screen More...
 
SLVec2i _viewportRatio
 ratio of viewport More...
 
SLViewportAlign _viewportAlign
 alignment of viewport More...
 
SLRecti _viewportRect
 rectangle of viewport More...
 
SLbool _viewportSameAsVideo
 Adapt viewport aspect to the input video. More...
 
SLbool _screenCaptureIsRequested
 Flag if screen capture is requested. More...
 
SLint _screenCaptureWaitFrames
 Frames to delay the screen capture. More...
 
SLGLOculusFB _oculusFB
 Oculus framebuffer. More...
 
std::unordered_set< SLMaterial * > _visibleMaterials3D
 visible materials 3D per frame More...
 
std::unordered_set< SLMaterial * > _visibleMaterials2D
 visible materials 2D per frame More...
 
SLVNode _nodesOpaque2D
 Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D. More...
 
SLVNode _nodesBlended2D
 Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D. More...
 
SLVNode _nodesOpaque3D
 Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D. More...
 
SLVNode _nodesBlended3D
 Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D. More...
 
SLVNode _nodesOverdrawn
 Vector of helper nodes drawn over all others. More...
 
SLRaytracer _raytracer
 Whitted style raytracer. More...
 
SLbool _stopRT
 Flag to stop the RT. More...
 
SLPathtracer _pathtracer
 Pathtracer. More...
 
SLbool _stopPT
 Flag to stop the PT. More...
 
SLInputManager_inputManager
 
AvgFloat _shadowMapTimesMS
 Averaged time for drawing the shadow maps in ms. More...
 
AvgFloat _cullTimesMS
 Averaged time for culling in ms. More...
 
AvgFloat _draw3DTimesMS
 Averaged time for 3D drawing in ms. More...
 
AvgFloat _draw2DTimesMS
 Averaged time for 2D drawing in ms. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

The SLSceneView class is inherited because we override here the default event-handling for onMouseDown.

Definition at line 18 of file AppDemoSceneView.h.

Constructor & Destructor Documentation

◆ AppDemoSceneView()

AppDemoSceneView::AppDemoSceneView ( SLScene s,
int  dpi,
SLInputManager inputManager 
)

Definition at line 16 of file AppDemoSceneView.cpp.

19  : SLSceneView(s, dpi, inputManager)
20 {
21 }
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SLint dpi() const
Definition: SLSceneView.h:175
SLSceneView(SLScene *s, int dpi, SLInputManager &inputManager)
SLSceneView default constructor.
Definition: SLSceneView.cpp:37

Member Function Documentation

◆ onKeyPress()

SLbool AppDemoSceneView::onKeyPress ( SLKey  key,
SLKey  mod 
)
finalvirtual

This method overrides the same method from the base class SLSceneView. It runs some app-specific code if a certain key is pressed and calls the default implementation from SLSceneView if it doesn't consume the event.

Reimplemented from SLSceneView.

Definition at line 27 of file AppDemoSceneView.cpp.

28 {
29  // Keyboard shortcuts for next or previous sceneID loading
30  if (mod & K_alt && mod & K_shift)
31  {
33  if (key == '0' && sv)
34  {
36  return true;
37  }
38  else if (key == K_left && sv &&
39  AppCommon::sceneID > 0 &&
41  {
43  return true;
44  }
45  else if (key == K_right && sv &&
47  {
49  return true;
50  }
51  }
52 
53  return SLSceneView::onKeyPress(key, mod);
54 }
@ SID_MaxNoBenchmarks
@ SID_Empty
int SLSceneID
Scene identifier.
Definition: SLEnums.h:91
@ K_shift
Definition: SLEnums.h:62
@ K_right
Definition: SLEnums.h:26
@ K_alt
Definition: SLEnums.h:64
@ K_left
Definition: SLEnums.h:27
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
Definition: AppCommon.h:90
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
static SLSceneID sceneID
ID of currently loaded scene.
Definition: AppCommon.h:89
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
virtual SLbool onKeyPress(SLKey key, SLKey mod)
T mod(T a, T b)
Definition: Utils.h:250

◆ onKeyRelease()

SLbool AppDemoSceneView::onKeyRelease ( SLKey  key,
SLKey  mod 
)
finalvirtual

This method overrides the same method from the base class SLSceneView. It runs some app-specific code if a certain key is pressed and calls the default implementation from SLSceneView if it doesn't consume the event.

Reimplemented from SLSceneView.

Definition at line 60 of file AppDemoSceneView.cpp.

61 {
63  {
64  AppDemoGui::hideUI = false;
65  return true;
66  }
67 
68  return SLSceneView::onKeyRelease(key, mod);
69 }
static SLbool hideUI
Flag if menubar should be shown.
Definition: AppDemoGui.h:56
virtual SLbool onKeyRelease(SLKey key, SLKey mod)

◆ onMouseDown()

SLbool AppDemoSceneView::onMouseDown ( SLMouseButton  button,
SLint  x,
SLint  y,
SLKey  mod 
)
finalvirtual

This method overrides the same method from the base class SLSceneView. Most events such as all mouse and keyboard events from the OS are forwarded to SLSceneview. SLSceneview implements a default behaviour. If you want a different or additional behaviour for a certain eventhandler you have to sub- class SLSceneView and override the eventhandler. Because all video processing (capturing and calibration) is handled outside of the core SLProject we need to add an additional handling for mouse down withing the calibration routine.

Reimplemented from SLSceneView.

Definition at line 80 of file AppDemoSceneView.cpp.

84 {
85  // Call base class event-handler for default mouse and touchdown behaviour
86  bool baseClassResult = SLSceneView::onMouseDown(button, x, y, mod);
87 
88  // Grab image during calibration if calibration stream is running
91  {
92  grab = true;
93  }
94 
95  return baseClassResult;
96 }
@ SID_VideoCalibrateScnd
@ SID_VideoCalibrateMain
virtual SLbool onMouseDown(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)

Member Data Documentation

◆ grab

SLbool AppDemoSceneView::grab = false

Definition at line 27 of file AppDemoSceneView.h.


The documentation for this class was generated from the following files: