SLProject 4.0.000
|
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 |
ImGui instance. 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.
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.
|
override |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void SLSceneView::draw2DGL | ( | ) |
SLSceneView::draw2DGL draws all 2D stuff in ortho projection. So far no update is done to the 2D scenegraph.
void SLSceneView::draw2DGLNodes | ( | ) |
SLSceneView::draw2DGLNodes draws 2D nodes from root2D in orthographic projection
|
inline |
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:
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
void SLSceneView::draw3DGLLines | ( | SLVNode & | nodes | ) |
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
void SLSceneView::draw3DGLLinesOverlay | ( | SLVNode & | nodes | ) |
SLSceneView::draw3DGLLinesOverlay draws the nodes axis and skeleton joints as overlay
SLSceneView::draw3DGLNodes draws the nodes meshes from the passed node vector directly with their world transform after the view transform.
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.
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.
|
inline |
|
inline |
|
inline |
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 |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
SLSceneView::onCharInput get called whenever a new charcter comes in
|
virtual |
SLSceneView::onDoubleClick gets called when a mouse double click or finger double tab occurs.
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.
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.
SLSceneView::onKeyRelease get called whenever a key is released.
|
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.
SLSceneView::onMouseMove gets called whenever the mouse is moved.
|
virtual |
SLSceneView::onMouseUp gets called whenever a mouse button gets released.
SLSceneView::onMouseWheel gets called whenever the mouse wheel is turned. The parameter delta is positive/negative depending on the wheel direction
SLSceneView::onMouseWheel gets called whenever the mouse wheel is turned. The parameter wheelPos is an increasing or decreeing counter number.
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.
SLSceneView::onResize is called by the window system before the first rendering and whenever the window changes its size.
|
inlinevirtual |
SLSceneView::onTouch2Down gets called whenever two fingers touch a handheld screen.
SLSceneView::onTouch2Move gets called whenever two fingers touch a handheld screen.
SLSceneView::onTouch2Up gets called whenever two fingers lift off a handheld screen.
|
inline |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void SLSceneView::setViewportFromRatio | ( | const SLVec2i & | vpRatio, |
SLViewportAlign | vpAlignment, | ||
SLbool | vpSameAsVideo | ||
) |
Sets the viewport ratio and the viewport rectangle.
|
inline |
void SLSceneView::startRaytracing | ( | SLint | maxDepth | ) |
Starts the ray tracing & sets the RT menu
|
inline |
|
inline |
void SLSceneView::switchToNextCameraInScene | ( | ) |
Sets the active camera to the next in the scene.
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..
void SLSceneView::unInit | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
SLstring SLSceneView::windowTitle | ( | ) |
Returns the window title with name & FPS
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Pointer to the _active camera.
|
protected |
time for culling in ms
|
protected |
Averaged time for culling in ms.
|
protected |
Flag if alpha sorting in blending is on.
|
protected |
Flag if depth test is turned on.
|
protected |
Flag if view frustum culling is on.
|
protected |
Flag if multisampling is on.
|
protected |
Flag for Event waiting.
|
protected |
dots per inch of screen
|
protected |
time for 2D drawing in ms
|
protected |
Averaged time for 2D drawing in ms.
|
protected |
time for 3D drawing in ms
|
protected |
Averaged time for 3D drawing in ms.
|
protected |
Sceneview level drawing flags.
|
protected |
flag if this sceneview got painted
|
protected |
ImGui instance.
|
protected |
|
protected |
Flag if it is the first frame rendering.
|
protected |
Flag if left mouse button is pressed.
|
protected |
Flag if middle mouse button is pressed.
|
protected |
Flag if right mouse button is pressed.
|
protected |
mouse modifier key on key down
|
protected |
Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D.
|
protected |
Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D.
|
protected |
Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D.
|
protected |
Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D.
|
protected |
Vector of helper nodes drawn over all others.
|
protected |
Oculus framebuffer.
|
protected |
Pathtracer.
|
protected |
Whitted style raytracer.
|
protected |
rendering type (GL,RT,PT)
|
protected |
Pointer to the scene observed by this scene view.
|
protected |
Default camera for this SceneView (default cam not in scenegraph)
|
protected |
Flag if screen capture is requested.
|
protected |
Frames to delay the screen capture.
|
protected |
Screen height in pixels.
|
protected |
Screen half height in pixels.
|
protected |
Screen width in pixels.
|
protected |
Screen half width in pixels.
|
protected |
Screen side aspect ratio.
|
protected |
time for drawing the shadow maps in ms
|
protected |
Averaged time for drawing the shadow maps in ms.
|
protected |
Statistic numbers for 2D nodes.
|
protected |
Statistic numbers for 3D nodes.
|
protected |
Flag to stop the PT.
|
protected |
Flag to stop the RT.
|
protected |
up to 3 finger touch coordinates
|
protected |
finger touch down count
|
protected |
Virtual cursor for stereo rendering.
|
protected |
Buffer for touch pos. rendering.
|
protected |
alignment of viewport
|
protected |
ratio of viewport
|
protected |
rectangle of viewport
|
protected |
Adapt viewport aspect to the input video.
|
protected |
visible materials 2D per frame
|
protected |
visible materials 3D per frame
cbOnSelectNodeMesh SLSceneView::onSelectedNodeMesh |
C-Callback for app on node selection.
cbOnWndUpdate SLSceneView::onWndUpdate |
C-Callback for app for intermediate window repaint.