SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
SceneView class represents a dynamic real time 3D view onto the scene. More...
#include <SLSceneView.h>
Public Attributes | |
cbOnWndUpdate | onWndUpdate |
C-Callback for app for intermediate window repaint. More... | |
cbOnSelectNodeMesh | onSelectedNodeMesh |
C-Callback for app on node selection. More... | |
Protected Attributes | |
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... | |
Friends | |
class | SLNode |
class | SLRaytracer |
class | SLOptixRaytracer |
class | SLPathtracer |
SceneView class represents a dynamic real time 3D view onto the scene.
The SLSceneView class has a pointer to an active camera that is used to generate the 3D view into a window of the clients GUI system. OpenGL ES3.0 or newer is used the default renderer for framebuffer rendering. Alternatively the sceneview can be rendered with a software ray tracing or path tracing renderer. All mouse, touch, keyboard, resize and paint events of the GUI system are handled in this class by the appropriate event handler methods. If your app need special event handling you can subclass this class and override the virtual function. If the scene contains itself no camera node the sceneview provides its own camera object.
Definition at line 68 of file SLSceneView.h.
SLSceneView::SLSceneView | ( | SLScene * | s, |
int | dpi, | ||
SLInputManager & | inputManager | ||
) |
SLSceneView default constructor.
The default constructor adds the this pointer to the sceneView vector in SLScene. If an in between element in the vector is zero (from previous sceneviews) it will be replaced. The sceneviews _index is the index in the sceneview vector. It never changes throughout the life of a sceneview.
Definition at line 37 of file SLSceneView.cpp.
|
override |
Definition at line 51 of file SLSceneView.cpp.
|
inline |
Definition at line 168 of file SLSceneView.h.
Definition at line 145 of file SLSceneView.h.
|
inline |
Definition at line 201 of file SLSceneView.h.
|
inline |
Definition at line 185 of file SLSceneView.h.
Definition at line 153 of file SLSceneView.h.
|
inline |
Definition at line 187 of file SLSceneView.h.
Definition at line 151 of file SLSceneView.h.
|
inline |
Definition at line 184 of file SLSceneView.h.
Definition at line 152 of file SLSceneView.h.
|
inline |
Definition at line 186 of file SLSceneView.h.
Definition at line 150 of file SLSceneView.h.
|
inline |
Definition at line 188 of file SLSceneView.h.
Definition at line 149 of file SLSceneView.h.
|
inline |
Definition at line 175 of file SLSceneView.h.
void SLSceneView::draw2DGL | ( | ) |
SLSceneView::draw2DGL draws all 2D stuff in ortho projection. So far no update is done to the 2D scenegraph.
Definition at line 1065 of file SLSceneView.cpp.
void SLSceneView::draw2DGLNodes | ( | ) |
SLSceneView::draw2DGLNodes draws 2D nodes from root2D in orthographic projection
Definition at line 1137 of file SLSceneView.cpp.
|
inline |
Definition at line 202 of file SLSceneView.h.
SLbool SLSceneView::draw3DCT | ( | ) |
Draws the 3D scene with OpenGL.
This is the main routine for updating and drawing the 3D scene for one frame. The following steps are processed:
Definition at line 638 of file SLSceneView.cpp.
void SLSceneView::draw3DGLAll | ( | ) |
SLSceneView::draw3DGLAll renders by material sorted to avoid expensive material switches on the GPU. During the cull traversal all materials that are seen in the view frustum get collected in _visibleMaterials. All nodes with their meshes get collected in SLMaterial::_nodesVisible3D.
The 3D rendering has then the following steps: 1) Draw nodes with meshes with opaque materials and all helper lines sorted by material
2) Draw remaining opaque nodes (SLCameras, needs redesign)
3) Draw nodes with meshes with blended materials sorted by material and sorted back to front
4) Draw remaining blended nodes (SLText, needs redesign)
5) Draw helpers in overlay mode (not depth buffered)
6) Draw visualization lines of animation curves
Definition at line 808 of file SLSceneView.cpp.
SLSceneView::draw3DGLLines draws the AABB from the passed node vector directly with their world coordinates after the view transform. The lines must be drawn without blending. Colors: Red : AABB of nodes with meshes Pink : AABB of nodes without meshes (only child nodes) Yellow: AABB of selected node
Definition at line 909 of file SLSceneView.cpp.
SLSceneView::draw3DGLLinesOverlay draws the nodes axis and skeleton joints as overlay
Definition at line 952 of file SLSceneView.cpp.
SLSceneView::draw3DGLNodes draws the nodes meshes from the passed node vector directly with their world transform after the view transform.
Definition at line 863 of file SLSceneView.cpp.
SLbool SLSceneView::draw3DPT | ( | ) |
SLSceneView::updateAndRT3D starts the raytracing or refreshes the current RT image during rendering. The function returns true if an animation was done prior to the rendering start.
Definition at line 1936 of file SLSceneView.cpp.
SLbool SLSceneView::draw3DRT | ( | ) |
SLSceneView::updateAndRT3D starts the raytracing or refreshes the current RT image during rendering. The function returns true if an animation was done prior to the rendering start.
Definition at line 1883 of file SLSceneView.cpp.
|
inline |
Definition at line 203 of file SLSceneView.h.
Definition at line 199 of file SLSceneView.h.
|
inline |
Definition at line 198 of file SLSceneView.h.
|
inline |
Definition at line 183 of file SLSceneView.h.
void SLSceneView::init | ( | SLstring | name, |
SLint | screenWidth, | ||
SLint | screenHeight, | ||
void * | onWndUpdateCallback, | ||
void * | onSelectNodeMeshCallback, | ||
SLUiInterface * | gui, | ||
const string & | configPath | ||
) |
SLSceneView::init initializes default values for an empty scene
name | Name of the sceneview |
screenWidth | Width of the OpenGL frame buffer. |
screenHeight | Height of the OpenGL frame buffer. |
onWndUpdateCallback | Callback for ray tracing update |
onSelectNodeMeshCallback | Callback on node and mesh selection |
gui | Interface for the external Gui build function |
configPath | Path to the config file |
Definition at line 64 of file SLSceneView.cpp.
void SLSceneView::initSceneViewCamera | ( | const SLVec3f & | dir = -SLVec3f::AXISZ , |
SLProjType | proj = P_monoPerspective |
||
) |
SLSceneView::onInitialize is called by the window system before the first rendering. It applies all scene rendering attributes with the according OpenGL function.
Definition at line 163 of file SLSceneView.cpp.
|
inline |
Definition at line 128 of file SLSceneView.h.
|
inline |
Definition at line 192 of file SLSceneView.h.
|
inline |
Definition at line 190 of file SLSceneView.h.
|
inline |
Definition at line 191 of file SLSceneView.h.
|
inline |
Definition at line 189 of file SLSceneView.h.
|
inline |
Definition at line 193 of file SLSceneView.h.
|
inline |
Definition at line 197 of file SLSceneView.h.
SLSceneView::onCharInput get called whenever a new charcter comes in
Definition at line 1787 of file SLSceneView.cpp.
|
virtual |
SLSceneView::onDoubleClick gets called when a mouse double click or finger double tab occurs.
Definition at line 1487 of file SLSceneView.cpp.
void SLSceneView::onInitialize | ( | ) |
SLSceneView::onInitialize is called by the window system before the first rendering. It applies all scene rendering attributes with the according OpenGL function.
Definition at line 378 of file SLSceneView.cpp.
SLSceneView::onKeyPress gets get called whenever a key is pressed. Before passing the command to the eventhandlers the main key commands are handled by forwarding them to onCommand.
Reimplemented in AppDemoSceneView, and AppNodeSceneView.
Definition at line 1655 of file SLSceneView.cpp.
SLSceneView::onKeyRelease get called whenever a key is released.
Reimplemented in AppDemoSceneView, and AppNodeSceneView.
Definition at line 1752 of file SLSceneView.cpp.
|
virtual |
SLSceneView::onMouseDown gets called whenever a mouse button gets pressed and dispatches the event to the currently attached event handler object.
Reimplemented in AppDemoSceneView.
Definition at line 1240 of file SLSceneView.cpp.
SLSceneView::onMouseMove gets called whenever the mouse is moved.
Definition at line 1364 of file SLSceneView.cpp.
|
virtual |
SLSceneView::onMouseUp gets called whenever a mouse button gets released.
Definition at line 1292 of file SLSceneView.cpp.
SLSceneView::onMouseWheel gets called whenever the mouse wheel is turned. The parameter delta is positive/negative depending on the wheel direction
Definition at line 1449 of file SLSceneView.cpp.
SLSceneView::onMouseWheel gets called whenever the mouse wheel is turned. The parameter wheelPos is an increasing or decreeing counter number.
Definition at line 1437 of file SLSceneView.cpp.
SLbool SLSceneView::onPaint | ( | ) |
SLSceneView::onPaint is called by window system whenever the window and therefore the scene needs to be painted. Depending on the renderer it calls first SLSceneView::draw3DGL, SLSceneView::draw3DRT or SLSceneView::draw3DPT and then SLSceneView::draw2DGL for all UI in 2D. The method returns true if either the 2D or 3D graph was updated or waitEvents is false.
Definition at line 500 of file SLSceneView.cpp.
SLSceneView::onResize is called by the window system before the first rendering and whenever the window changes its size.
Definition at line 459 of file SLSceneView.cpp.
|
inlinevirtual |
Definition at line 94 of file SLSceneView.h.
SLSceneView::onTouch2Down gets called whenever two fingers touch a handheld screen.
Definition at line 1556 of file SLSceneView.cpp.
SLSceneView::onTouch2Move gets called whenever two fingers touch a handheld screen.
Definition at line 1589 of file SLSceneView.cpp.
SLSceneView::onTouch2Up gets called whenever two fingers lift off a handheld screen.
Definition at line 1623 of file SLSceneView.cpp.
|
inline |
Definition at line 195 of file SLSceneView.h.
|
inlinevirtual |
Definition at line 96 of file SLSceneView.h.
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Definition at line 132 of file SLSceneView.h.
|
inline |
Definition at line 194 of file SLSceneView.h.
|
inline |
Definition at line 196 of file SLSceneView.h.
|
inline |
Definition at line 154 of file SLSceneView.h.
|
inline |
Definition at line 167 of file SLSceneView.h.
void SLSceneView::saveFrameBufferAsImage | ( | SLstring | pathFilename, |
cv::Size | targetSize = cv::Size(-1, -1) |
||
) |
Saves after n wait frames the front frame buffer as a PNG image.
Definition at line 2051 of file SLSceneView.cpp.
Definition at line 146 of file SLSceneView.h.
|
inline |
Definition at line 169 of file SLSceneView.h.
|
inline |
Definition at line 206 of file SLSceneView.h.
|
inline |
Definition at line 156 of file SLSceneView.h.
|
inline |
Definition at line 171 of file SLSceneView.h.
Definition at line 148 of file SLSceneView.h.
|
inline |
Definition at line 173 of file SLSceneView.h.
|
inline |
Definition at line 170 of file SLSceneView.h.
Definition at line 147 of file SLSceneView.h.
|
inline |
Definition at line 172 of file SLSceneView.h.
|
inline |
Definition at line 174 of file SLSceneView.h.
void SLSceneView::setViewportFromRatio | ( | const SLVec2i & | vpRatio, |
SLViewportAlign | vpAlignment, | ||
SLbool | vpSameAsVideo | ||
) |
|
inline |
Definition at line 200 of file SLSceneView.h.
Starts the ray tracing & sets the RT menu
Definition at line 1871 of file SLSceneView.cpp.
|
inline |
Definition at line 204 of file SLSceneView.h.
|
inline |
Definition at line 205 of file SLSceneView.h.
void SLSceneView::switchToNextCameraInScene | ( | ) |
Sets the active camera to the next in the scene.
Definition at line 290 of file SLSceneView.cpp.
void SLSceneView::switchToSceneViewCamera | ( | ) |
SLSceneView::switchToSceneViewCamera the general idea for this function is to switch to the editor camera from a scene camera. It could provide functionality to stay at the position of the previous camera, or to be reset to the init position etc..
Definition at line 274 of file SLSceneView.cpp.
void SLSceneView::unInit | ( | ) |
Definition at line 128 of file SLSceneView.cpp.
|
inline |
Definition at line 181 of file SLSceneView.h.
|
inline |
Definition at line 180 of file SLSceneView.h.
|
inline |
Definition at line 177 of file SLSceneView.h.
|
inline |
Definition at line 176 of file SLSceneView.h.
|
inline |
Definition at line 182 of file SLSceneView.h.
|
inline |
Definition at line 155 of file SLSceneView.h.
|
inline |
Definition at line 179 of file SLSceneView.h.
|
inline |
Definition at line 178 of file SLSceneView.h.
|
inline |
Definition at line 208 of file SLSceneView.h.
|
inline |
Definition at line 209 of file SLSceneView.h.
SLstring SLSceneView::windowTitle | ( | ) |
|
friend |
Definition at line 70 of file SLSceneView.h.
|
friend |
Definition at line 72 of file SLSceneView.h.
|
friend |
Definition at line 73 of file SLSceneView.h.
|
friend |
Definition at line 71 of file SLSceneView.h.
|
protected |
Pointer to the _active camera.
Definition at line 225 of file SLSceneView.h.
|
protected |
time for culling in ms
Definition at line 242 of file SLSceneView.h.
|
protected |
Averaged time for culling in ms.
Definition at line 295 of file SLSceneView.h.
|
protected |
Flag if alpha sorting in blending is on.
Definition at line 236 of file SLSceneView.h.
|
protected |
Flag if depth test is turned on.
Definition at line 233 of file SLSceneView.h.
|
protected |
Flag if view frustum culling is on.
Definition at line 235 of file SLSceneView.h.
|
protected |
Flag if multisampling is on.
Definition at line 234 of file SLSceneView.h.
|
protected |
Flag for Event waiting.
Definition at line 237 of file SLSceneView.h.
|
protected |
dots per inch of screen
Definition at line 261 of file SLSceneView.h.
|
protected |
time for 2D drawing in ms
Definition at line 244 of file SLSceneView.h.
|
protected |
Averaged time for 2D drawing in ms.
Definition at line 297 of file SLSceneView.h.
|
protected |
time for 3D drawing in ms
Definition at line 243 of file SLSceneView.h.
|
protected |
Averaged time for 3D drawing in ms.
Definition at line 296 of file SLSceneView.h.
|
protected |
Sceneview level drawing flags.
Definition at line 239 of file SLSceneView.h.
|
protected |
flag if this sceneview got painted
Definition at line 230 of file SLSceneView.h.
|
protected |
new tighter imgui wrapper
Definition at line 227 of file SLSceneView.h.
|
protected |
Definition at line 292 of file SLSceneView.h.
|
protected |
Flag if it is the first frame rendering.
Definition at line 238 of file SLSceneView.h.
|
protected |
Flag if left mouse button is pressed.
Definition at line 246 of file SLSceneView.h.
|
protected |
Flag if middle mouse button is pressed.
Definition at line 248 of file SLSceneView.h.
|
protected |
Flag if right mouse button is pressed.
Definition at line 247 of file SLSceneView.h.
|
protected |
mouse modifier key on key down
Definition at line 249 of file SLSceneView.h.
|
protected |
Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D.
Definition at line 275 of file SLSceneView.h.
|
protected |
Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D.
Definition at line 277 of file SLSceneView.h.
|
protected |
Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D.
Definition at line 274 of file SLSceneView.h.
|
protected |
Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D.
Definition at line 276 of file SLSceneView.h.
|
protected |
Vector of helper nodes drawn over all others.
Definition at line 278 of file SLSceneView.h.
|
protected |
Oculus framebuffer.
Definition at line 269 of file SLSceneView.h.
|
protected |
Pathtracer.
Definition at line 282 of file SLSceneView.h.
|
protected |
Whitted style raytracer.
Definition at line 280 of file SLSceneView.h.
|
protected |
rendering type (GL,RT,PT)
Definition at line 231 of file SLSceneView.h.
|
protected |
Pointer to the scene observed by this scene view.
Definition at line 224 of file SLSceneView.h.
|
protected |
Default camera for this SceneView (default cam not in scenegraph)
Definition at line 226 of file SLSceneView.h.
|
protected |
Flag if screen capture is requested.
Definition at line 266 of file SLSceneView.h.
|
protected |
Frames to delay the screen capture.
Definition at line 267 of file SLSceneView.h.
|
protected |
Screen height in pixels.
Definition at line 257 of file SLSceneView.h.
|
protected |
Screen half height in pixels.
Definition at line 259 of file SLSceneView.h.
|
protected |
Screen width in pixels.
Definition at line 256 of file SLSceneView.h.
|
protected |
Screen half width in pixels.
Definition at line 258 of file SLSceneView.h.
|
protected |
Screen side aspect ratio.
Definition at line 260 of file SLSceneView.h.
|
protected |
time for drawing the shadow maps in ms
Definition at line 241 of file SLSceneView.h.
|
protected |
Averaged time for drawing the shadow maps in ms.
Definition at line 294 of file SLSceneView.h.
|
protected |
Statistic numbers for 2D nodes.
Definition at line 228 of file SLSceneView.h.
|
protected |
Statistic numbers for 3D nodes.
Definition at line 229 of file SLSceneView.h.
|
protected |
Flag to stop the PT.
Definition at line 283 of file SLSceneView.h.
|
protected |
Flag to stop the RT.
Definition at line 281 of file SLSceneView.h.
|
protected |
up to 3 finger touch coordinates
Definition at line 251 of file SLSceneView.h.
|
protected |
finger touch down count
Definition at line 250 of file SLSceneView.h.
|
protected |
Virtual cursor for stereo rendering.
Definition at line 254 of file SLSceneView.h.
|
protected |
Buffer for touch pos. rendering.
Definition at line 253 of file SLSceneView.h.
|
protected |
alignment of viewport
Definition at line 263 of file SLSceneView.h.
|
protected |
ratio of viewport
Definition at line 262 of file SLSceneView.h.
|
protected |
rectangle of viewport
Definition at line 264 of file SLSceneView.h.
|
protected |
Adapt viewport aspect to the input video.
Definition at line 265 of file SLSceneView.h.
|
protected |
visible materials 2D per frame
Definition at line 272 of file SLSceneView.h.
|
protected |
visible materials 3D per frame
Definition at line 271 of file SLSceneView.h.
cbOnSelectNodeMesh SLSceneView::onSelectedNodeMesh |
C-Callback for app on node selection.
Definition at line 142 of file SLSceneView.h.
cbOnWndUpdate SLSceneView::onWndUpdate |
C-Callback for app for intermediate window repaint.
Definition at line 141 of file SLSceneView.h.