26 #    define STB_IMAGE_WRITE_IMPLEMENTATION 
   27 #    include "stb_image_write.h" 
   41     _inputManager(inputManager),
 
   42     _shadowMapTimesMS(60, 0.0f),
 
   43     _cullTimesMS(60, 0.0f),
 
   44     _draw3DTimesMS(60, 0.0f),
 
   45     _draw2DTimesMS(60, 0.0f),
 
   46     _screenCaptureIsRequested(false),
 
   47     _screenCaptureWaitFrames(0)
 
   67                        void*          onWndUpdateCallback,
 
   68                        void*          onSelectNodeMeshCallback,
 
   70                        const string&  configPath)
 
  113 #if defined(SL_OS_ANDROID) || defined(SL_OS_MACIOS) || defined(SL_EMSCRIPTEN) 
  146         material->nodesVisible2D().clear();
 
  150         material->nodesVisible3D().clear();
 
  195         vsCorners[0] = 
SLVec4f(minX, minY, minZ);
 
  196         vsCorners[1] = 
SLVec4f(maxX, minY, minZ);
 
  197         vsCorners[2] = 
SLVec4f(minX, maxY, minZ);
 
  198         vsCorners[3] = 
SLVec4f(maxX, maxY, minZ);
 
  199         vsCorners[4] = 
SLVec4f(minX, minY, maxZ);
 
  200         vsCorners[5] = 
SLVec4f(maxX, minY, maxZ);
 
  201         vsCorners[6] = 
SLVec4f(minX, maxY, maxZ);
 
  202         vsCorners[7] = 
SLVec4f(maxX, maxY, maxZ);
 
  204         SLVec3f vsMin(FLT_MAX, FLT_MAX, FLT_MAX);
 
  205         SLVec3f vsMax(FLT_MIN, FLT_MIN, FLT_MIN);
 
  209         for (
auto& vsCorner : vsCorners)
 
  211             vsCorner = vm * vsCorner;
 
  213             vsMin.
x = std::min(vsMin.
x, vsCorner.x);
 
  214             vsMin.
y = std::min(vsMin.
y, vsCorner.y);
 
  215             vsMin.
z = std::min(vsMin.
z, vsCorner.z);
 
  217             vsMax.
x = std::max(vsMax.
x, vsCorner.x);
 
  218             vsMax.
y = std::max(vsMax.
y, vsCorner.y);
 
  219             vsMax.
z = std::max(vsMax.
z, vsCorner.z);
 
  236             distX = vsMax.
x / (ar * halfTan);
 
  237             distY = vsMax.
y / halfTan;
 
  242             distX = (vsMax.
x - vsMin.
x) * 0.5f / (ar * halfTan);
 
  243             distY = (vsMax.
y - vsMin.
y) * 0.5f / halfTan;
 
  249         SLfloat dist = std::max(distX, distY);
 
  281         SLVec3f forward(-currentWM.
m(8), -currentWM.
m(9), -currentWM.
m(10));
 
  297     if (nextCam == 
nullptr)
 
  313     assert(
_scrW > 0 && 
_scrH > 0 && 
"SLSceneView::setViewportFromRatio: Invalid screen size");
 
  330     SLfloat vpWdivH = (float)vpRatio.
x / (
float)vpRatio.
y;
 
  345             default: vpRect.
x = (
_scrW - vpRect.
width) / 2; 
break;
 
  370         SL_EXIT_MSG(
"SLSceneView::viewport: Viewport is bigger than the screen!");
 
  400     _optixRaytracer.setupOptix();
 
  401     _optixPathtracer.setupOptix();
 
  414         _s->
root3D()->updateMeshAccelStructs();
 
  424             SL_LOG_DEBUG(
"sv->onInitialize : No Lights found in scene!");
 
  462     if (width == 0 || height == 0) 
return;
 
  511     SLbool sceneHasChanged    = 
false;
 
  512     SLbool viewConsumedEvents = 
false;
 
  535     SLbool camUpdated = 
false;
 
  554             case RT_optix_rt: camUpdated = draw3DOptixRT(); 
break;
 
  555             case RT_optix_pt: camUpdated = draw3DOptixPT(); 
break;
 
  582     return !
_doWaitOnIdle || camUpdated || sceneHasChanged || viewConsumedEvents;
 
  655         if (light->createsShadows())
 
  656             light->renderShadowMap(
this, 
_s->
root3D());
 
  734         material->nodesVisible3D().clear();
 
  754         _s->
skybox()->drawAroundCamera(
this);
 
  780             _s->
skybox()->drawAroundCamera(
this);
 
  815         if (!material->hasAlpha())
 
  831         if (material->hasAlpha())
 
  854     stateGL->
blend(
false);
 
  869     if (nodes.empty()) 
return;
 
  873     stateGL->
blend(alphaBlended);
 
  880         std::sort(nodes.begin(), nodes.end(), [](
SLNode* a, 
SLNode* b)
 
  882                       if (!a) return false;
 
  884                       return a->aabb()->sqrViewDist() > b->aabb()->sqrViewDist(); });
 
  888     for (
auto* node : nodes)
 
  894         node->drawMesh(
this);
 
  913     if (nodes.empty()) 
return;
 
  916     stateGL->
blend(
false);
 
  923     for (
auto* node : nodes)
 
  938             if (node->isSelected())
 
  959     for (
auto* node : nodes)
 
  969                 stateGL->
blend(
false);     
 
  978                     node->aabb()->drawAxisWS();
 
  989                         for (
auto joint : skeleton->
joints())
 
  992                             SLMat4f wm = node->updateAndGetWM();
 
  993                             wm *= joint->updateAndGetWM();
 
  999                                 parentWM = node->parent()->updateAndGetWM();
 
 1000                                 parentWM *= joint->parent()->updateAndGetWM();
 
 1001                                 joint->aabb()->updateBoneWS(parentWM, 
false, wm);
 
 1004                                 joint->aabb()->updateBoneWS(parentWM, 
true, wm);
 
 1006                             joint->aabb()->drawBoneWS();
 
 1013                 node->aabb()->calculateRectSS();
 
 1036                 if (node->mesh() && node->mesh()->mat())
 
 1038                     SLMesh* mesh     = node->mesh();
 
 1042                     stateGL->
blend(hasAlpha);
 
 1051                     node->drawMesh(
this);
 
 1086             material->nodesVisible2D().clear();
 
 1149     stateGL->
blend(
true);        
 
 1157         for (
auto* node : material->nodesVisible2D())
 
 1163             node->drawMesh(
this);
 
 1175         node->drawMesh(
this);
 
 1187             SLVVec3f centerRombusPoints = {{-cs, 0, 0},
 
 1193             SLCol4f yelloAlpha(1.0f, 1.0f, 0.0f, 0.5f);
 
 1211             SLint   circlePoints = 60;
 
 1213             for (
SLint i = 0; i < circlePoints; ++i)
 
 1217                 rombusAndCirclePoints.push_back(
SLVec3f(c.
x, c.
y, 0));
 
 1221             SLCol4f yelloAlpha(1.0f, 1.0f, 0.0f, 0.5f);
 
 1228     stateGL->
blend(
false);    
 
 1273         SLbool eventConsumed = 
false;
 
 1276             if (eh->onMouseDown(button, x, y, 
mod))
 
 1277                 eventConsumed = 
true;
 
 1339         SLbool eventConsumed = 
false;
 
 1342             if (eh->onMouseUp(button, x, y, 
mod))
 
 1343                 eventConsumed = 
true;
 
 1418     SLbool eventConsumed = 
false;
 
 1421         if (eh->onMouseMove(btn, x, y, 
_mouseMod))
 
 1422             eventConsumed = 
true;
 
 1439     static SLint lastMouseWheelPos = 0;
 
 1440     SLint        delta             = wheelPos - lastMouseWheelPos;
 
 1441     lastMouseWheelPos              = wheelPos;
 
 1477         if (eh->onMouseWheel(delta, 
mod))
 
 1507         SLRay pickRay(
this);
 
 1520         if (pickRay.
length < FLT_MAX)
 
 1545             if (eh->onDoubleClick(button, x, y, 
mod))
 
 1579         if (eh->onTouch2Down(x1, y1, x2, y2))
 
 1612             if (eh->onTouch2Move(x1, y1, x2, y2))
 
 1644         if (eh->onTouch2Up(x1, y1, x2, y2))
 
 1682     if (key==
'R' && 
mod==
K_shift) {startOptixRaytracing(5);}
 
 1683     if (key==
'P' && 
mod==
K_shift) {startOptixPathtracing(5, 100);}
 
 1742             if (eh->onKeyPress(key, 
mod))
 
 1777             if (eh->onKeyRelease(key, 
mod))
 
 1810     profiling = 
" *** PROFILING *** ";
 
 1823                          "Ray Tracing: %s (fps: %4.1f, Threads: %d)",
 
 1832                          "Ray Tracing: %s (Threads: %d)",
 
 1841                      "Path Tracing: %s (Threads: %d)",
 
 1849                 format = 
"OpenGL Renderer: %s (fps: %4.0f, %u nodes of %u rendered)";
 
 1851                 format = 
"OpenGL Renderer: %s (fps: %4.1f, %u nodes of %u rendered)";
 
 1863         snprintf(title, 
sizeof(title), 
"Scene is loading ...");
 
 1865     return profiling + 
SLstring(title) + profiling;
 
 1897             _s->
root3D()->updateMeshAccelStructs();
 
 1950             _s->
root3D()->updateMeshAccelStructs();
 
 1971 void SLSceneView::startOptixRaytracing(
SLint maxDepth)
 
 1974     _stopOptixRT = 
false;
 
 1975     _optixRaytracer.maxDepth(maxDepth);
 
 1976     _optixRaytracer.setupScene(
this, 
s()->assetManager());
 
 1979 SLbool SLSceneView::draw3DOptixRT()
 
 1984     if (_optixRaytracer.state() == 
rtReady)
 
 1988         _optixRaytracer.updateScene(
this);
 
 1990         if (_optixRaytracer.doDistributed())
 
 1991             _optixRaytracer.renderDistrib();
 
 1993             _optixRaytracer.renderClassic();
 
 1997     _optixRaytracer.renderImage(
false);
 
 2009 void SLSceneView::startOptixPathtracing(
SLint maxDepth, 
SLint samples)
 
 2012     _stopOptixPT = 
false;
 
 2013     _optixPathtracer.maxDepth(maxDepth);
 
 2014     _optixPathtracer.samples(samples);
 
 2015     _optixPathtracer.setupScene(
this, 
s()->assetManager());
 
 2018 SLbool SLSceneView::draw3DOptixPT()
 
 2023     if (_optixPathtracer.state() == 
rtReady)
 
 2028         _optixPathtracer.updateScene(
this);
 
 2029         _optixPathtracer.render();
 
 2033     _optixPathtracer.renderImage(
false);
 
 2052                                          cv::Size targetSize)
 
 2059 #ifndef SL_EMSCRIPTEN 
 2060         GLsizei nrChannels = 3;
 
 2062         GLsizei nrChannels = 4;
 
 2065         GLsizei stride = nrChannels * fbW;
 
 2066         stride += (stride % 4) ? (4 - stride % 4) : 0;
 
 2067         GLsizei       bufferSize = stride * fbH;
 
 2068         vector<uchar> buffer(bufferSize);
 
 2072 #ifndef SL_EMSCRIPTEN 
 2073         CVMat rgbImg = 
CVMat(fbH, fbW, CV_8UC3, (
void*)buffer.data(), stride);
 
 2074         cv::cvtColor(rgbImg, rgbImg, cv::COLOR_BGR2RGB);
 
 2079                              (
void*)buffer.data(),
 
 2081         cv::cvtColor(rgbImg, rgbImg, cv::COLOR_RGBA2RGB);
 
 2083         stride     = nrChannels * fbW;
 
 2086         cv::flip(rgbImg, rgbImg, 0);
 
 2087         if (targetSize.width > 0 && targetSize.height > 0)
 
 2088             cv::resize(rgbImg, rgbImg, targetSize);
 
 2090 #ifndef SL_EMSCRIPTEN 
 2091         vector<int> compression_params;
 
 2092         compression_params.push_back(cv::IMWRITE_PNG_COMPRESSION);
 
 2093         compression_params.push_back(6);
 
 2097             imwrite(pathFilename, rgbImg, compression_params);
 
 2098             string msg = 
"Screenshot saved to: " + pathFilename;
 
 2101         catch (std::runtime_error& ex)
 
 2103             string msg = 
"SLSceneView::saveFrameBufferAsImage: Exception: ";
 
 2108         auto writer = [](
void* context, 
void* data, 
int size)
 
 2111             stream->
write(data, size);
 
 2117         stbi_write_png_to_func(writer,
 
 2127 #if !defined(SL_OS_ANDROID) && !defined(SL_OS_MACIOS) && !defined(SL_EMSCRIPTEN) 
static SLint dpi
Dot per inch resolution of screen.
 
#define PROFILE_FUNCTION()
 
#define SL_LOG_DEBUG(...)
 
#define SL_EXIT_MSG(message)
 
#define SL_DB_ONLYEDGES
Draw only hard edges.
 
#define SL_DB_NORMALS
Draw the vertex normals.
 
#define SL_DB_SKELETON
Draw the skeletons joints.
 
#define SL_DB_WITHEDGES
Draw faces with hard edges.
 
#define SL_DB_AXIS
Draw the coordinate axis of a node.
 
#define SL_DB_BRECT
Draw the bounding rectangle of a node.
 
#define SL_DB_OVERDRAW
Draw node over all other nodes.
 
#define SL_DB_VOXELS
Draw the voxels of the uniform grid.
 
#define SL_DB_GPU_SKINNING
Perform skinning on the GPU.
 
#define SL_DB_CULLOFF
Turn off face culling.
 
#define SL_DB_MESHWIRED
Draw polygons as wired mesh.
 
#define SL_DB_BBOX
Draw the bounding boxes of a node.
 
@ CA_turntableYUp
Orbiting around central object w. turntable rotation around y & right axis.
 
@ CA_trackball
Orbiting around central object w. one rotation around one axis.
 
@ CA_turntableZUp
Orbiting around central object w. turntable rotation around z & right axis.
 
SLProjType
Enumeration for different camera projections.
 
@ P_monoPerspective
standard mono pinhole perspective projection
 
@ P_stereoSideBySideD
side-by-side distorted for Oculus Rift like glasses
 
@ P_stereoLineByLine
line-by-line
 
@ P_monoOrthographic
standard mono orthographic projection
 
@ RT_optix_pt
Path Tracing with OptiX.
 
@ RT_optix_rt
Ray Tracing with OptiX.
 
SLMouseButton
Mouse button codes.
 
SLViewportAlign
Mouse button codes.
 
SLKey
Keyboard key codes enumeration.
 
Wrapper Class around the external ImGui GUI-framework.
 
deque< SLNode * > SLVNode
SLVNode typedef for a vector of SLNodes.
 
SLRect< SLint, SLVec2i > SLRecti
 
void(SL_STDCALL * cbOnSelectNodeMesh)(SLNode *, SLMesh *)
Callback function typedef for select node.
 
SLbool(SL_STDCALL * cbOnWndUpdate)()
Callback function typedef for GUI window updateRec.
 
vector< SLVec3f > SLVVec3f
 
SLVec3< SLfloat > SLVec3f
 
SLVec4< SLfloat > SLVec4f
 
Defines an axis aligned bounding box.
 
void minWS(const SLVec3f &minC)
 
void maxWS(const SLVec3f &maxC)
 
void drawVisuals(SLSceneView *sv)
Draws the animation visualizations.
 
SLAnimSkeleton keeps track of a skeletons joints and animations.
 
const SLVJoint & joints() const
 
void render(SLint widthPX, SLint heightPX)
Draws the background as 2D rectangle with OpenGL buffers.
 
void colors(const SLCol4f &uniformColor)
Sets a uniform background color.
 
Active or visible camera node class.
 
SLbool onTouch2Down(SLint x1, SLint y1, SLint x2, SLint y2) override
 
SLbool onKeyRelease(SLKey key, SLKey mod) override
 
SLfloat trackballSize() const
 
void setViewport(SLSceneView *sv, SLEyeType eye)
Sets the viewport transform depending on the projection.
 
SLbool onMouseUp(SLMouseButton button, SLint x, SLint y, SLKey mod) override
Gets called whenever the mouse button is released.
 
void stereoEyeSeparation(const SLfloat es)
 
SLfloat fovV() const
Vertical field of view.
 
void clipFar(const SLfloat cFar)
 
void clipNear(const SLfloat cNear)
 
void focalDist(const SLfloat f)
 
void maxSpeed(const SLfloat ms)
 
SLbool onMouseMove(SLMouseButton button, SLint x, SLint y, SLKey mod) override
Gets called whenever the mouse is moved.
 
void setView(SLSceneView *sv, SLEyeType eye)
 
void projType(SLProjType p)
 
void eyeToPixelRay(SLfloat x, SLfloat y, SLRay *ray)
eyeToPixelRay returns the a ray from the eye to the center of a pixel.
 
virtual SLbool camUpdate(SLSceneView *sv, SLfloat timeMS)
 
void setFrustumPlanes()
SLCamera::setFrustumPlanes set the 6 plane from the view frustum.
 
SLBackground & background()
 
SLbool onTouch2Up(SLint x1, SLint y1, SLint x2, SLint y2) override
 
SLbool onMouseDown(SLMouseButton button, SLint x, SLint y, SLKey mod) override
Gets called whenever a mouse button gets pressed.
 
void setProjection(SLSceneView *sv, SLEyeType eye)
 
SLbool onTouch2Move(SLint x1, SLint y1, SLint x2, SLint y2) override
 
SLbool onKeyPress(SLKey key, SLKey mod) override
 
SLbool onMouseWheel(SLint delta, SLKey mod) override
 
void camAnim(SLCamAnim ca)
 
void toggle(SLuint bit)
Toggles the specified bit.
 
void allOff()
Turns all bits off.
 
virtual SLbool onDoubleClick(const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
void updateSize(SLint scrWidth, SLint scrHeight)
 
void bindFramebuffer(SLint scrWidth, SLint scrHeight)
 
SLfloat resolutionScale()
 
void renderDistortion(SLint width, SLint height, SLuint tex, const SLCol4f &background)
 
void renderResolution(SLint width, SLint height)
 
Singleton class holding all OpenGL states.
 
void clearColor(const SLCol4f &c)
 
SLMat4f modelMatrix
Init all states.
 
void depthMask(SLbool state)
 
void viewport(SLint x, SLint y, SLsizei width, SLsizei height)
 
void multiSample(SLbool state)
 
static SLGLState * instance()
Public static instance getter for singleton pattern.
 
SLMat4f viewMatrix
matrix for the active cameras view transform
 
void unbindAnythingAndFlush()
finishes all GL commands
 
void colorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a)
 
void onInitialize(const SLCol4f &clearColor)
On init GL.
 
SLMat4f projectionMatrix
matrix for projection transform
 
void polygonLine(SLbool state)
 
void readPixels(void *buffer)
Reads the front framebuffer pixels into the passed buffer.
 
void clearColorDepthBuffer()
 
void depthTest(SLbool state)
 
void deleteData(SLbool deleteAlsoOnGPU)
Delete all data (CVImages and GPU textures)
 
void generateVertexPos(SLVVec2f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
 
void drawArrayAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat lineOrPointSize=1.0f, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the array as the specified primitive with the color.
 
void clearAttribs()
Clears the attribute definition.
 
static SLuint totalDrawCalls
 
static SLuint totalPrimitivesRendered
static total no. of draw calls
 
Interface for accessing external data using streams.
 
virtual size_t write(const void *buffer, size_t size)
 
Abstract Light class for OpenGL light sources.
 
SLVec3< T > translation() const
 
void ortho(T l, T r, T b, T t, T n, T f)
Defines a orthographic projection matrix with a field of view angle.
 
void identity()
Sets the identity matrix.
 
void translate(T tx, T ty, T tz=0)
 
SLbool hasAlpha()
Returns true if there is any transparency in diffuse alpha or textures.
 
An SLMesh object is a triangulated mesh, drawn with one draw call.
 
SLNode represents a node in a hierarchical scene graph.
 
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
 
virtual void needUpdate()
 
const SLMat4f & updateAndGetWM() const
 
const SLMat4f & updateAndGetWMI() const
 
void lookAt(SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
 
virtual SLAABBox & updateAABBRec(SLbool updateAlsoAABBinOS)
 
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
 
Base class for all other classes.
 
void name(const SLstring &Name)
 
SLstring _name
name of an object
 
const SLstring & name() const
 
SLbool render(SLSceneView *sv)
 
Ray class with ray and intersection properties.
 
SLMesh * hitMesh
Points to the intersected mesh.
 
SLfloat length
length from origin to an intersection
 
SLNode * hitNode
Points to the intersected node.
 
SLbool renderClassic(SLSceneView *sv)
 
void doContinuous(SLbool cont)
 
void state(SLRTState state)
 
static SLuint numThreads()
 
SLbool renderDistrib(SLSceneView *sv)
 
virtual void renderImage(bool updateTextureGL)
 
void maxDepth(SLint depth)
 
void aaSamples(SLint samples)
 
void doDistributed(SLbool distrib)
 
void set(const T X, const T Y, const T WIDTH, const T HEIGHT)
 
SLbool contains(T X, T Y)
 
void drawGL(const SLCol4f &color)
 
The SLScene class represents the top level instance holding the scene structure.
 
bool onUpdate(bool renderTypeIsRT, bool voxelsAreShown, bool forceCPUSkinning)
Updates animations and AABBs.
 
void deselectAllNodesAndMeshes()
Deselects all nodes and its meshes.
 
SLCamera * nextCameraInScene(SLCamera *activeSVCam)
Returns the next camera in the scene if there is one.
 
SLVEventHandler & eventHandlers()
 
void root2D(SLNode *root2D)
 
SLAnimManager & animManager()
 
void selectNodeMesh(SLNode *nodeToSelect, SLMesh *meshToSelect)
Handles the full mesh selection from double-clicks.
 
SLfloat elapsedTimeMS() const
 
void skybox(SLSkybox *skybox)
 
void root3D(SLNode *root3D)
 
SLNode * singleNodeSelected()
Returns the node if only one is selected. See also SLMesh::selectNodeMesh.
 
SLVNode & selectedNodes()
 
void stopAnimations(SLbool stop)
 
SLKey _mouseMod
mouse modifier key on key down
 
SLfloat _draw2DTimeMS
time for 2D drawing in ms
 
SLbool _screenCaptureIsRequested
Flag if screen capture is requested.
 
SLPathtracer _pathtracer
Pathtracer.
 
std::unordered_set< SLMaterial * > _visibleMaterials2D
visible materials 2D per frame
 
SLint _scrW
Screen width in pixels.
 
void draw3DGLLinesOverlay(SLVNode &nodes)
 
void switchToNextCameraInScene()
Sets the active camera to the next in the scene.
 
std::unordered_set< SLMaterial * > _visibleMaterials3D
visible materials 3D per frame
 
SLbool doWaitOnIdle() const
 
SLbool _stopPT
Flag to stop the PT.
 
SLNodeStats _stats3D
Statistic numbers for 3D nodes.
 
SLfloat _scrWdivH
Screen side aspect ratio.
 
SLint _screenCaptureWaitFrames
Frames to delay the screen capture.
 
virtual SLbool onDoubleClick(SLMouseButton button, SLint x, SLint y, SLKey mod)
 
SLint _scrH
Screen height in pixels.
 
SLRaytracer _raytracer
Whitted style raytracer.
 
SLbool _gotPainted
flag if this sceneview got painted
 
virtual SLbool onMouseWheelPos(SLint wheelPos, SLKey mod)
 
SLbool _mouseDownM
Flag if middle mouse button is pressed.
 
SLVNode _nodesBlended3D
Vector of visible blended nodes not in _visibleMaterials3D rendered in 3D.
 
SLVNode _nodesOverdrawn
Vector of helper nodes drawn over all others.
 
void draw3DGLNodes(SLVNode &nodes, SLbool alphaBlended, SLbool depthSorted)
 
cbOnWndUpdate onWndUpdate
C-Callback for app for intermediate window repaint.
 
SLVNode _nodesOpaque2D
Vector of visible opaque nodes not in _visibleMaterials2D rendered in 2D.
 
virtual SLbool onCharInput(SLuint c)
 
SLVNode _nodesBlended2D
Vector of visible blended nodes not in _visibleMaterials2D rendered in 2D.
 
SLbool doDepthTest() const
 
SLbool _doMultiSampling
Flag if multisampling is on.
 
SLRenderType _renderType
rendering type (GL,RT,PT)
 
SLGLOculusFB _oculusFB
Oculus framebuffer.
 
void draw3DGLLines(SLVNode &nodes)
 
void startPathtracing(SLint maxDepth, SLint samples)
 
void onResize(SLint width, SLint height)
 
cbOnSelectNodeMesh onSelectedNodeMesh
C-Callback for app on node selection.
 
SLbool _mouseDownL
Flag if left mouse button is pressed.
 
void switchToSceneViewCamera()
 
SLRecti _viewportRect
rectangle of viewport
 
SLVNode _nodesOpaque3D
Vector of visible opaque nodes not in _visibleMaterials3D rendered in 3D.
 
SLGLVertexArrayExt _vaoTouch
Buffer for touch pos. rendering.
 
SLUiInterface * _gui
new tighter imgui wrapper
 
SLbool doFrustumCulling() const
 
SLViewportAlign _viewportAlign
alignment of viewport
 
SLbool _doFrustumCulling
Flag if view frustum culling is on.
 
SLfloat _draw3DTimeMS
time for 3D drawing in ms
 
SLint _scrWdiv2
Screen half width in pixels.
 
SLbool _doWaitOnIdle
Flag for Event waiting.
 
virtual SLbool onMouseMove(SLint x, SLint y)
 
SLbool _doAlphaSorting
Flag if alpha sorting in blending is on.
 
SLint _scrHdiv2
Screen half height in pixels.
 
AvgFloat _shadowMapTimesMS
Averaged time for drawing the shadow maps in ms.
 
SLNodeStats _stats2D
Statistic numbers for 2D nodes.
 
SLbool _mouseDownR
Flag if right mouse button is pressed.
 
void init(SLstring name, SLint screenWidth, SLint screenHeight, void *onWndUpdateCallback, void *onSelectNodeMeshCallback, SLUiInterface *gui, const string &configPath)
 
SLbool doMultiSampling() const
 
void startRaytracing(SLint maxDepth)
 
SLbool drawBit(SLuint bit)
 
void initSceneViewCamera(const SLVec3f &dir=-SLVec3f::AXISZ, SLProjType proj=P_monoPerspective)
 
virtual SLbool onKeyRelease(SLKey key, SLKey mod)
 
SLbool doAlphaSorting() const
 
SLbool _viewportSameAsVideo
Adapt viewport aspect to the input video.
 
SLbool _doDepthTest
Flag if depth test is turned on.
 
SLbool _isFirstFrame
Flag if it is the first frame rendering.
 
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(SLScene *s, int dpi, SLInputManager &inputManager)
SLSceneView default constructor.
 
AvgFloat _cullTimesMS
Averaged time for culling in ms.
 
virtual SLbool onMouseWheel(SLint delta, SLKey mod)
 
SLint _touchDowns
finger touch down count
 
SLVec2i _touch[3]
up to 3 finger touch coordinates
 
SLInputManager & _inputManager
 
SLCamera _sceneViewCamera
Default camera for this SceneView (default cam not in scenegraph)
 
AvgFloat _draw2DTimesMS
Averaged time for 2D drawing in ms.
 
SLfloat _cullTimeMS
time for culling in ms
 
SLRaytracer * raytracer()
 
SLVec2i _viewportRatio
ratio of viewport
 
virtual SLbool onTouch2Move(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
 
virtual SLbool onMouseUp(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
 
SLScene * _s
Pointer to the scene observed by this scene view.
 
SLfloat _shadowMapTimeMS
time for drawing the shadow maps in ms
 
void setViewportFromRatio(const SLVec2i &vpRatio, SLViewportAlign vpAlignment, SLbool vpSameAsVideo)
Sets the viewport ratio and the viewport rectangle.
 
virtual SLbool onKeyPress(SLKey key, SLKey mod)
 
AvgFloat _draw3DTimesMS
Averaged time for 3D drawing in ms.
 
virtual SLbool onMouseDown(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
 
virtual SLbool onTouch2Up(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
 
SLCamera * _camera
Pointer to the _active camera.
 
SLDrawBits _drawBits
Sceneview level drawing flags.
 
SLbool _stopRT
Flag to stop the RT.
 
SLbool draw3DGL(SLfloat elapsedTimeSec)
Draws the 3D scene with OpenGL.
 
virtual SLbool onTouch2Down(SLint scrX1, SLint scrY1, SLint scrX2, SLint scrY2)
 
static SLuint drawCalls
NO. of draw calls for shadow mapping.
 
Interface for ui integration in SLSceneView.
 
virtual void onMouseDown(SLMouseButton button, SLint x, SLint y)
forward user input to ui
 
virtual void onPaint(const SLRecti &viewport)
ui render call (called by SLSceneView draw2DGL)
 
virtual void onMouseMove(SLint xPos, SLint yPos)
forward user input to ui
 
virtual void init(const string &configPath)
initialization (called by SLSceneView init)
 
virtual void onKeyPress(SLKey key, SLKey mod)
forward user input to ui
 
virtual void renderExtraFrame(SLScene *s, SLSceneView *sv, SLint mouseX, SLint mouseY)
 
virtual bool doNotDispatchKeyboard()
inform if user keyboard input was consumed by the ui
 
virtual void onResize(const SLRecti &viewportRect)
inform the ui about scene view size change
 
virtual void onMouseWheel(SLfloat yoffset)
forward user input to ui
 
virtual void onKeyRelease(SLKey key, SLKey mod)
forward user input to ui
 
virtual bool doNotDispatchMouse()
inform if user mouse input was consumed by the ui
 
virtual void onMouseUp(SLMouseButton button, SLint x, SLint y)
forward user input to ui
 
virtual void onInitNewFrame(SLScene *s, SLSceneView *sv)
prepare the ui for a new rendering, e.g. update visual ui representation (called by SLSceneView onPai...
 
virtual void onCharInput(SLuint c)
forward user input to ui
 
virtual void drawMouseCursor(bool doDraw)
Turns on or off the mouse cursor drawing.
 
void set(const T X, const T Y)
 
void fromPolar(T r, T phiRAD)
Calculates the vector from polar coords r & phi in radians (-pi < phi < pi)
 
void init(int numValues, T initValue)
Initializes the average value array to a given value.
 
void set(T value)
Sets the current value in the value array and builds the average.
 
void close(SLIOStream *stream)
Closes and deletes a stream.
 
SLIOStream * open(std::string path, SLIOStreamKind kind, SLIOStreamMode mode)
Opens a file stream for I/O operations.
 
static const float DEG2RAD
 
void exitMsg(const char *tag, const char *msg, const int line, const char *file)
Terminates the application with a message. No leak checking.
 
SLuint numNodesOpaque
NO. of visible opaque nodes.
 
SLuint numNodes
NO. of children nodes.
 
void clear()
Resets all counters to zero.
 
SLuint numNodesBlended
NO. of visible blended nodes.