diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 0119ae2..0bfc013 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -46,7 +46,6 @@ function(sl_add_app) ${SL_PROJECT_ROOT}/apps/source/AppCommon.h ${SL_PROJECT_ROOT}/apps/source/SLScene.h ${SL_PROJECT_ROOT}/apps/source/SLInterface.h - ${SL_PROJECT_ROOT}/apps/source/Scene.h ${APP_HEADERS} ) @@ -54,7 +53,6 @@ function(sl_add_app) ${SL_PROJECT_ROOT}/apps/source/CVCapture.cpp ${SL_PROJECT_ROOT}/apps/source/AppCommon.cpp ${SL_PROJECT_ROOT}/apps/source/SLInterface.cpp - ${SL_PROJECT_ROOT}/apps/source/SLProjectScene.cpp ${APP_SOURCES} ) diff --git a/apps/source/AppCommon.cpp b/apps/source/AppCommon.cpp index 36144ee..1e4e0cc 100644 --- a/apps/source/AppCommon.cpp +++ b/apps/source/AppCommon.cpp @@ -11,6 +11,7 @@ * \remarks Please use clangformat to format the code. See more code style on * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style */ + #include #include #include diff --git a/apps/source/AppCommon.h b/apps/source/AppCommon.h index b4d117b..8c97cf1 100644 --- a/apps/source/AppCommon.h +++ b/apps/source/AppCommon.h @@ -3,14 +3,14 @@ * \brief The AppCommon class holds the top-level instances of the app-demo * \details For more info on how to create a new app with SLProject see: * https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App - * For more info about App framework see: + * For more info about App framework see: * https://cpvrlab.github.io/SLProject4/app-framework.html * \date February 2018 * \authors Marcus Hudritsch * \copyright http://opensource.org/licenses/GPL-3.0 * \remarks Please use clangformat to format the code. See more code style on * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style -*/ + */ #ifndef SLAPPCOMMON_H #define SLAPPCOMMON_H @@ -37,14 +37,14 @@ class SLUiInterface; using std::optional; //----------------------------------------------------------------------------- -//! Top level class for an SLProject application. +//! Top level class for the major global instances off an SLProject app. /*! The AppCommon holds static instances of top-level items such as the asset manager, the scene pointer, the vector of all sceneviews, the gui pointer, the camera calibration objects and the device rotation and location information.
- The static function createApp is called by the C-interface functions - slCreateApp and the function deleteApp by slTerminate. At the moment only + The static function createApp is called by the C-interface functions + slCreateApp and the function deleteApp by slTerminate. At the moment only one scene can be open at the time.
AppCommon holds two static video camera calibrations, one for a main camera @@ -55,38 +55,39 @@ class AppCommon { public: // Major owned instances of the app - static SLInputManager inputManager; //!< Input events manager - static SLAssetManager* assetManager; //!< asset manager is the owner of all assets - static SLAssetLoader* assetLoader; //!< responsible for async asset loading - static SLScene* scene; //!< scene pointer - static SLVSceneView sceneViews; //!< vector of sceneview pointers - static SLUiInterface* gui; //!< gui pointer - static SLDeviceRotation devRot; //!< Mobile device rotation from IMU - static SLDeviceLocation devLoc; //!< Mobile device location from GPS - static optional sceneToLoad; //!< scene id to load at start up + static SLInputManager inputManager; //!< Input events manager + static SLAssetManager* assetManager; //!< asset manager is the owner of all assets + static SLAssetLoader* assetLoader; //!< Asset-loader for async asset loading + static SLScene* scene; //!< Pointer to the one and only SLScene instance + static SLVSceneView sceneViews; //!< Vector of sceneview pointers + static SLUiInterface* gui; //!< Pointer to the GUI + static SLDeviceRotation devRot; //!< Mobile device rotation from IMU + static SLDeviceLocation devLoc; //!< Mobile device location from GPS static void createApp(SLstring appName); static void registerCoreAssetsLoad(); static void switchScene(SLSceneView* sv, SLSceneID sceneID); static void deleteApp(); - static SLstring name; //!< Application name - static SLstring appTag; //!< Tag string used in logging - static SLstring version; //!< SLProject version string - static SLstring asciiLabel; //!< SLProject ascii label string - static SLstring configuration; //!< Debug or Release configuration - static SLstring gitBranch; //!< Current GIT branch - static SLstring gitCommit; //!< Current GIT commit short hash id - static SLstring gitDate; //!< Current GIT commit date - static SLstring exePath; //!< executable root path - static SLstring configPath; //!< Default path for calibration files - static SLstring externalPath; //!< Default path for external file storage - static SLstring dataPath; //!< Path to data directory (it is set platform dependent) - static SLstring shaderPath; //!< Path to GLSL shader programs - static SLstring modelPath; //!< Path to 3D models - static SLstring texturePath; //!< Path to texture images - static SLstring fontPath; //!< Path to font images - static SLstring videoPath; //!< Path to video files + static SLstring name; //!< Application name + static SLstring appTag; //!< Tag string used in logging + static SLstring version; //!< SLProject version string + static SLstring asciiLabel; //!< SLProject ascii label string + static SLstring configuration; //!< Debug or Release configuration + static SLstring gitBranch; //!< Current GIT branch + static SLstring gitCommit; //!< Current GIT commit short hash id + static SLstring gitDate; //!< Current GIT commit date + static SLstring exePath; //!< executable root path + static SLstring configPath; //!< Default path for calibration files + static SLstring externalPath; //!< Default path for external file storage + static SLstring dataPath; //!< Path to data directory (it is set platform dependent) + static SLstring shaderPath; //!< Path to GLSL shader programs + static SLstring modelPath; //!< Path to 3D models + static SLstring texturePath; //!< Path to texture images + static SLstring fontPath; //!< Path to font images + static SLstring videoPath; //!< Path to video files + static SLSceneID sceneID; //!< ID of currently loaded scene + static optional sceneToLoad; //!< Scene id to load at start up // static methods for parallel job processing static void handleParallelJob(); @@ -97,8 +98,6 @@ class AppCommon static int jobProgressNum() { return _jobProgressNum; } static int jobProgressMax() { return _jobProgressMax; } - static SLSceneID sceneID; //!< ID of last loaded scene - static map deviceParameter; //!< Generic device parameter static deque> jobsToBeThreaded; //!< Queue of functions to be executed in a thread static deque> jobsToFollowInMain; //!< Queue of function to follow in the main thread diff --git a/docs/images/SLProject.mdj b/docs/images/SLProject.mdj index cf0aa35..e48ce9d 100644 --- a/docs/images/SLProject.mdj +++ b/docs/images/SLProject.mdj @@ -27979,7 +27979,7 @@ "top": 24, "width": 153, "height": 177, - "text": "Application code split in platform independent (C/C++) code (light gray boxes) and platform dependent code (C/C++, Java or Objective C) in dark gray boxes. Supported platforms are: GLFW (desktop OS), Emscripten (Web), iOS and Android." + "text": "Application code split in platform independent (C/C++) code (light brown boxes) and platform dependent code (C/C++, Java or Objective C) in dark brown boxes. Supported platforms are: GLFW (desktop OS), Emscripten (Web), iOS and Android." }, { "_type": "UMLClassView", @@ -28008,7 +28008,7 @@ "$ref": "AAAAAAFs2JHSOnGRR7w=" }, "visible": false, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 864, "top": -80, @@ -28020,7 +28020,7 @@ "_parent": { "$ref": "AAAAAAFs2JHSOnGRR7w=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;1", "left": 445, "top": 31, @@ -28035,7 +28035,7 @@ "$ref": "AAAAAAFs2JHSOnGRR7w=" }, "visible": false, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 864, "top": -80, @@ -28050,7 +28050,7 @@ "$ref": "AAAAAAFs2JHSOnGRR7w=" }, "visible": false, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 864, "top": -80, @@ -28058,7 +28058,7 @@ "horizontalAlignment": 1 } ], - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 440, "top": 24, @@ -28096,7 +28096,7 @@ "model": { "$ref": "AAAAAAFs2JQVNKp+XQI=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 54, @@ -28106,7 +28106,7 @@ "horizontalAlignment": 0 } ], - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 440, "top": 49, @@ -28132,7 +28132,7 @@ "model": { "$ref": "AAAAAAFs2JPjhKSGySk=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 77, @@ -28150,7 +28150,7 @@ "model": { "$ref": "AAAAAAFs2KUTYyly5Go=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 92, @@ -28168,7 +28168,7 @@ "model": { "$ref": "AAAAAAFs2JTCB7HVIC4=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 107, @@ -28186,7 +28186,7 @@ "model": { "$ref": "AAAAAAFs2JUlCbfNDpE=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 122, @@ -28204,7 +28204,7 @@ "model": { "$ref": "AAAAAAFs4d04ZM9d42Q=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 137, @@ -28222,7 +28222,7 @@ "model": { "$ref": "AAAAAAFs2JXTn8jGmqs=" }, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 445, "top": 152, @@ -28241,7 +28241,7 @@ "$ref": "AAAAAAFs2Ka1zkOazmQ=" }, "visible": false, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 701, "top": 167, @@ -28251,7 +28251,7 @@ "horizontalAlignment": 0 } ], - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 440, "top": 72, @@ -28268,7 +28268,7 @@ "$ref": "AAAAAAFs2JHSOnGOo7U=" }, "visible": false, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 432, "top": -40, @@ -28285,7 +28285,7 @@ "$ref": "AAAAAAFs2JHSOnGOo7U=" }, "visible": false, - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "left": 432, "top": -40, @@ -28293,7 +28293,7 @@ "height": 10 } ], - "fillColor": "#f6d678", + "fillColor": "#daac20", "font": "Arial;13;0", "containerChangeable": true, "left": 440, @@ -35201,7 +35201,6 @@ "propertyLabel": { "$ref": "AAAAAAGRE1Ge9wOL1sY=" }, - "showEndOrder": "hide", "tailRoleNameLabel": { "$ref": "AAAAAAGRE1Ge9wOMnTk=" }, diff --git a/docs/images/SLProject_UML_min.svg b/docs/images/SLProject_UML_min.svg index 8588943..bd5c8be 100644 --- a/docs/images/SLProject_UML_min.svg +++ b/docs/images/SLProject_UML_min.svg @@ -1 +1 @@ -SLScene_root3D: SLNode*_root2D: SLNode*_skybox: SLSkybox*_lights: SLVLight_animManager SLAnimManager_eventHandlers: SLVEventhandler_selectedNodes: SLVNode_selectedMeshes: SLVMeshinit()unInit()onUpdate()SLSceneView_camera: SLCamera*_raytracer: SLRaytracer_pathtracer: SLPathtracer_visibleMat2D: SLVMaterial_visibleMat3D: SLVMaterial_visibleNodes: SLVNodes_blendedNodes: SLVNodes_conetracer: SLGLConetraceronResize()onPaint()onMouseDown()onMouseMove()onMouseUp()onKeyPress()onKeyRelease()SLMeshP(ositions): SLVVec3fN(ormals): SLVVec3fUV[2]: SLVVec2fT(angents): SLVVec4fJi (Joint IDs): SLVVec4fJw (Joint weights) : SLVVec4fI16 (inices 16bit): SLVushortI32 (indices 32bit): SLVuint_accelStruct: SLAccelStruct_vao: SLGLVertexArray_mat: SLMaterial*draw()hit()calcNormals()calcTangents()transformSkin()computeHardEdgesIndices()generateVAO()SLMaterial_reflectionModel: SLReflMdl_ambient: SLCol4f_diffuse: SLCol4f_specular: SLCol4f_emissive: SLCol4f_shininess: float_roughness: float_metalness: float_translucency: float_textures[n]: SLVGLTextures_program: SLGLProgram*_skybox: SLSkybox*_nodesVisible3D: SLVNode_nodesVisible2D: SLVNodeactivate()passToUniforms()SLGLProgram_progID: SLuint_shaders: SLVGLShader_uniforms1f: SLVGLUniform_uniforms1i: SLVGLUniform_isLinked: booluseProgram()endUse()passLightsToUniforms()SLGLTexture_texID: SLuint_img[6]: CVImage_min_filter_mag_filter_texType: SLTextureType_tm: SLMat4f_bumpScale: floatbuild()bindActive()+1+1SLGLShader_shaderID: SLuint_type: SLShaderType_code: SLstring_file: SLstringload()createAndCompile()removeComments()preprocessPragmas()SLNode_parent: SLNode*_children: SLVNode_mesh: SLMesh*_om: SLMat4_wm: SLMat4_wmI: SLMat4f_wmN: SLMat4f_drawBits: SLDrawBits_aabb: SLAABBox_animation: SLAnimation*updateAndGetWM()cullRec()hitRec()drawRec()drawMesh()addChild()insertChild()deleteChild()findChild()+0..n+1SLCamera_fov: float_clipNear: float_clipFar: float_aspect: float_projection_vm: SLMat4f_viewport: SLRectisetView()setProjection()onMouseDown()onMouseMove()onMouseUp()+0..1SLAABBox_minWS_maxWSisHitInWS()SLMat4f_m[16]: floattranslate()rotate()scale()frustum()+1+1+0..nSLVec3fx: floaty: floatz: floatlength()normalize()+2..nSLSLGLState_modelViewMatrix_viewMatrix_projectionMatrix_modelViewMatrixStacklightStatesmaterialStatesfogStatesSLBox_min: SLVec3f_max: SLVec3fSLRevolver_revPoints: SLVVec3f_revAxis: SLVec3f_slices: int_stacks: intSLSpheric_radius: float_thetaStart: float_thetaEnd: floatSLCylinder_radius: float_height: floatSLCone_radius: float_height: floatSLRectangle_min: SLVec3f_max: SLVec3f_resX: int_resY: intSLPolygon_corners: SLVVec3f_texCoords: SLVVec2fSLAccelStructSLUniformGrid+1SLLightSpot_radius: floatSLLight_id: int_ambient: SLCol4f_diffuse: SLCol4f_specular: SLCol4f_spotCutoff: float+1..nSLJoint_id uint_skeleton SLSkeleton*_offsetMat SLMat4f_radius SLfloatSLAnimation_name SLstring_length SLfloat_nodeAnimTracksapply()applyToNode()SLSkeleton_root SLJoint*_joints SLVJoint_changed bool_animations_animationPlaysupdateAnimations()reset()SLAnimTrack_animation SLAnimation*_keyframes SLVKeyframegetKeyframesAtTime()SLNodeAnimTrack_animatedNode SLNode*_interpolCurve SLCurve*calcInterpolatedKeyframe()SLAnimManager_skeletons_animationNamesMap_animPlaybackNamesMapupdate()SLAnimPlayback_animation SLAnimation*_localTime SLfloat_weight SLfloat_playbackRate SLfloat_playbackDir SLushort_enabled SLbool_easing SLEasingCurve_looping SLAnimLoopingplayForward()playBackward()pause()skipToNextKeyframe()skipToPrevKeyframe()skipToStart()skipToEnd()advanceTime()SLKeyframe_animTrack SLAnimTrack*_time SLfloatSLTransformKeyframe_translation SLVec3f_rotation SLQuat4f_scale SLVec3f+1+1+1+2..n+0..n+1..n+1..n+1..n+1..n+1..n+2..n+3SLInputManager_devices: SLVInputEvent_sysEvents: SLQInputEventpollAndProcessEvents()CVImage_cvMat: cv::Mat_format: CVPixformat_bytesPerPixel: int_bytesPerLine: int_bytesPerImage: int_path: string_name: string+1..6SLLightRect_width: float_height: floatSLGLVertexArray_idVAO: uint_numVertices: uint_vbof: SLGLVertexBuffer_numIndices: uint_indexData_indexType: SLGLBufTypesetAttrib()setIndices()updateAttrib()generate()drawArrayAs()drawElementAs()SLGLVertexBuffer_id: uint_numVertices: uint_dataType: SLGLBufType_attribs: SLVVertexAttrib_outputInterleaved: bool_strideBytes: uint_sizeBytes: uint_usage: SLGLBufferUsageupdateAttrib()generate()bindAndEnableAttrib()disableAttrib()+1+1SLGLVertexAttribtype: SLGLAttributeTypeelementSize: intoffsetBytes: uintbufferSizeBytes: uintdataPointer: void*location: intconvertToHalf: bool+1..nSLSphereCVCapturelastFrame: cv::MatlastFrameGray: cv::Matformat: CVPixFormatcaptureSize: cv:SizecalibMainCam: CVCalibrationcalibScndCam: CVCalibrationactiveCalib: CVCalibration*_videoType: CVVideoType_captureDevice: cv::videoCaptureCVTrackedChessboard_edgeLengthM: float_boardPoints3D: CVVPoint3f_boardSize: cv::Size_solved: bool_rVec: cv::Mat_tVec: cv::MatCVTracked_isVisible: bool_drawDetection: bool_objectViewMat: cv::Matx44f_timer: HighResTimerCVCalibration_cameraMat: cv::Mat_distortion: cv::Mat_cameraFOVDeg: float_state: CVCalibState_boardSize: cv::Size_boardSquareMM: float_numImgsToCapture: int_numCaptured: int_reprojectionError: float_imagePoints: CVVVPoint2f_showUndistorted: bool_isMirrored: boolCVTrackedAruco_arucoID: intSLLightDirectCVTrackedFaces_marker: SLFeatureMarker2D_currentFrame: SLFrameData_prevFrame: SLFrameData_forceRelocation: bool_featureManagerAppDemoGUIbuild()buildMenuBar()buildSceneGraph()loadConfig()saveConfig()AppCommoninputManager: SLInputManagerassetManager: SLAssetManager*scene: SLScene*sceneViews: SLVSceneViewgui: SLImGui*devRot: SLDeviceRotationdevLoc: SLDeviceLocationcreateApp()+1+1AppDemoMainmain()createSceneView()createScene()onUpdate()+2CVTrackedFeatures_marker: SLFeatureMarker2D_currentFrame: SLFrameData_prevFrame: SLFrameData_forceRelocation: bool_featureMngr: CVFeatureMngrCVAppDemoVideovideoTexture: SLGLTexture*tracker: CVTracked*trackedNode: SLNode*onUpdateVideo()APPAppDemoSceneViewonMouseDown()onKeyPress()onKeyRelease()Application code split inplatform independent(C/C++) code (light grayboxes) and platformdependent code(C/C++, Java orObjective C) in darkgray boxes. Supportedplatforms are: GLFW(desktop OS),Emscripten (Web), iOSand Android.AppGLFWwindow: GLFWwindow*run()onResize()onPaint()onMouseButton()onMouseMove()onKeyPress()SLInterface C-InterfaceslCreateAppAndScene()slCreateSceneView()slUpdateScene()slResize()slPaintAllViews()slOnMouseDown()onKeyPress()UtilsUtilsAveragedProfilerCV contains classes that useOpenCV for video processing. No SL classes are used.SL (Scene Library) C++ classes contain thefunctionality scenegraph management and 3Drendering with OpenGL, ray or path tracing.Utils contains helpers used by SLand CV. No dependenciesExternalsOpenGLOpenCVassimpimguiglfwgl3w3D graphics API foracceleratedframebuffer renderingComputer Visionlibrary for imageand videoprocessing3D assets importand export libraryImmediate ModeGUI library forrealtime framebufferrenderingOpenGL contextand windowmanagement librarySimple OpenGLcore profile loadinglibrarySLRaytracerrenderClassic()renderDistrib()renderSlices()trace()shade()setPrimaryRay()sampleAAPixel()renderImage()saveImage()SLRayorigin: SLVec3fdir: SLVec3flength: floatdepth: intcontrib: floathitNode: SLNode*hitMesh: SLMesh*hitTriangle: uintreflect()refract()+1SLPathtracer+1Inherits fromSLSceneView ifspecific event handlingis needed.Video capturing for Android andiOS is handled within thetoplevel app code.SLLens_diameter: float_thickness: float_radiusBot: float_radiusTop: floatSLArrow_radius: float_length: float_headLen: float_headWidth: floatSLVec4fx: floaty: floatz: floatw: floatlength()SLVec2fx: floaty: floatlength()normalize()All UI is renderedwith OpenGL withImGUI once perframe.Top level main() functioncalls App::run.All external libraries areeither within the SLProjectrepository or areautomatically automaticallydownloaded by cmake,v4.2open source C++library for geometryprocessing researchand developmentlibiglSLAssetManager+meshes: SLVMesh+materials: SLVMaterial+textures: SLVGLTexture+programs: SLVGLProgramOwns top-levelinstances for apps+1..n+1SLGLProgramGenerated+buildProgramCode()+buildProgramName()Linear algebrasupport library foradvanced linalgoperationseigenProfilerZipUtilsPlatform dependent code.C-Interface for non-Cplatforms (iOS, Android)Major event handlerAll video code used fortracking.SLImGui+onInitNewFrame()+onPaint()+loadFonts()+onMouseDown()+onKeyPress()+1 \ No newline at end of file +SLScene_root3D: SLNode*_root2D: SLNode*_skybox: SLSkybox*_lights: SLVLight_animManager SLAnimManager_eventHandlers: SLVEventhandler_selectedNodes: SLVNode_selectedMeshes: SLVMeshinit()unInit()onUpdate()SLSceneView_camera: SLCamera*_raytracer: SLRaytracer_pathtracer: SLPathtracer_visibleMat2D: SLVMaterial_visibleMat3D: SLVMaterial_visibleNodes: SLVNodes_blendedNodes: SLVNodes_conetracer: SLGLConetraceronResize()onPaint()onMouseDown()onMouseMove()onMouseUp()onKeyPress()onKeyRelease()SLMeshP(ositions): SLVVec3fN(ormals): SLVVec3fUV[2]: SLVVec2fT(angents): SLVVec4fJi (Joint IDs): SLVVec4fJw (Joint weights) : SLVVec4fI16 (inices 16bit): SLVushortI32 (indices 32bit): SLVuint_accelStruct: SLAccelStruct_vao: SLGLVertexArray_mat: SLMaterial*draw()hit()calcNormals()calcTangents()transformSkin()computeHardEdgesIndices()generateVAO()SLMaterial_reflectionModel: SLReflMdl_ambient: SLCol4f_diffuse: SLCol4f_specular: SLCol4f_emissive: SLCol4f_shininess: float_roughness: float_metalness: float_translucency: float_textures[n]: SLVGLTextures_program: SLGLProgram*_skybox: SLSkybox*_nodesVisible3D: SLVNode_nodesVisible2D: SLVNodeactivate()passToUniforms()SLGLProgram_progID: SLuint_shaders: SLVGLShader_uniforms1f: SLVGLUniform_uniforms1i: SLVGLUniform_isLinked: booluseProgram()endUse()passLightsToUniforms()SLGLTexture_texID: SLuint_img[6]: CVImage_min_filter_mag_filter_texType: SLTextureType_tm: SLMat4f_bumpScale: floatbuild()bindActive()+1+1SLGLShader_shaderID: SLuint_type: SLShaderType_code: SLstring_file: SLstringload()createAndCompile()removeComments()preprocessPragmas()SLNode_parent: SLNode*_children: SLVNode_mesh: SLMesh*_om: SLMat4_wm: SLMat4_wmI: SLMat4f_wmN: SLMat4f_drawBits: SLDrawBits_aabb: SLAABBox_animation: SLAnimation*updateAndGetWM()cullRec()hitRec()drawRec()drawMesh()addChild()insertChild()deleteChild()findChild()+0..n+1SLCamera_fov: float_clipNear: float_clipFar: float_aspect: float_projection_vm: SLMat4f_viewport: SLRectisetView()setProjection()onMouseDown()onMouseMove()onMouseUp()+0..1SLAABBox_minWS_maxWSisHitInWS()SLMat4f_m[16]: floattranslate()rotate()scale()frustum()+1+1+0..nSLVec3fx: floaty: floatz: floatlength()normalize()+2..nSLSLGLState_modelViewMatrix_viewMatrix_projectionMatrix_modelViewMatrixStacklightStatesmaterialStatesfogStatesSLBox_min: SLVec3f_max: SLVec3fSLRevolver_revPoints: SLVVec3f_revAxis: SLVec3f_slices: int_stacks: intSLSpheric_radius: float_thetaStart: float_thetaEnd: floatSLCylinder_radius: float_height: floatSLCone_radius: float_height: floatSLRectangle_min: SLVec3f_max: SLVec3f_resX: int_resY: intSLPolygon_corners: SLVVec3f_texCoords: SLVVec2fSLAccelStructSLUniformGrid+1SLLightSpot_radius: floatSLLight_id: int_ambient: SLCol4f_diffuse: SLCol4f_specular: SLCol4f_spotCutoff: float+1..nSLJoint_id uint_skeleton SLSkeleton*_offsetMat SLMat4f_radius SLfloatSLAnimation_name SLstring_length SLfloat_nodeAnimTracksapply()applyToNode()SLSkeleton_root SLJoint*_joints SLVJoint_changed bool_animations_animationPlaysupdateAnimations()reset()SLAnimTrack_animation SLAnimation*_keyframes SLVKeyframegetKeyframesAtTime()SLNodeAnimTrack_animatedNode SLNode*_interpolCurve SLCurve*calcInterpolatedKeyframe()SLAnimManager_skeletons_animationNamesMap_animPlaybackNamesMapupdate()SLAnimPlayback_animation SLAnimation*_localTime SLfloat_weight SLfloat_playbackRate SLfloat_playbackDir SLushort_enabled SLbool_easing SLEasingCurve_looping SLAnimLoopingplayForward()playBackward()pause()skipToNextKeyframe()skipToPrevKeyframe()skipToStart()skipToEnd()advanceTime()SLKeyframe_animTrack SLAnimTrack*_time SLfloatSLTransformKeyframe_translation SLVec3f_rotation SLQuat4f_scale SLVec3f+1+1+1+2..n+0..n+1..n+1..n+1..n+1..n+1..n+2..n+3SLInputManager_devices: SLVInputEvent_sysEvents: SLQInputEventpollAndProcessEvents()CVImage_cvMat: cv::Mat_format: CVPixformat_bytesPerPixel: int_bytesPerLine: int_bytesPerImage: int_path: string_name: string+1..6SLLightRect_width: float_height: floatSLGLVertexArray_idVAO: uint_numVertices: uint_vbof: SLGLVertexBuffer_numIndices: uint_indexData_indexType: SLGLBufTypesetAttrib()setIndices()updateAttrib()generate()drawArrayAs()drawElementAs()SLGLVertexBuffer_id: uint_numVertices: uint_dataType: SLGLBufType_attribs: SLVVertexAttrib_outputInterleaved: bool_strideBytes: uint_sizeBytes: uint_usage: SLGLBufferUsageupdateAttrib()generate()bindAndEnableAttrib()disableAttrib()+1+1SLGLVertexAttribtype: SLGLAttributeTypeelementSize: intoffsetBytes: uintbufferSizeBytes: uintdataPointer: void*location: intconvertToHalf: bool+1..nSLSphereCVCapturelastFrame: cv::MatlastFrameGray: cv::Matformat: CVPixFormatcaptureSize: cv:SizecalibMainCam: CVCalibrationcalibScndCam: CVCalibrationactiveCalib: CVCalibration*_videoType: CVVideoType_captureDevice: cv::videoCaptureCVTrackedChessboard_edgeLengthM: float_boardPoints3D: CVVPoint3f_boardSize: cv::Size_solved: bool_rVec: cv::Mat_tVec: cv::MatCVTracked_isVisible: bool_drawDetection: bool_objectViewMat: cv::Matx44f_timer: HighResTimerCVCalibration_cameraMat: cv::Mat_distortion: cv::Mat_cameraFOVDeg: float_state: CVCalibState_boardSize: cv::Size_boardSquareMM: float_numImgsToCapture: int_numCaptured: int_reprojectionError: float_imagePoints: CVVVPoint2f_showUndistorted: bool_isMirrored: boolCVTrackedAruco_arucoID: intSLLightDirectCVTrackedFaces_marker: SLFeatureMarker2D_currentFrame: SLFrameData_prevFrame: SLFrameData_forceRelocation: bool_featureManagerAppDemoGUIbuild()buildMenuBar()buildSceneGraph()loadConfig()saveConfig()AppCommoninputManager: SLInputManagerassetManager: SLAssetManager*scene: SLScene*sceneViews: SLVSceneViewgui: SLImGui*devRot: SLDeviceRotationdevLoc: SLDeviceLocationcreateApp()+1+1AppDemoMainmain()createSceneView()createScene()onUpdate()+2CVTrackedFeatures_marker: SLFeatureMarker2D_currentFrame: SLFrameData_prevFrame: SLFrameData_forceRelocation: bool_featureMngr: CVFeatureMngrCVAppDemoVideovideoTexture: SLGLTexture*tracker: CVTracked*trackedNode: SLNode*onUpdateVideo()APPAppDemoSceneViewonMouseDown()onKeyPress()onKeyRelease()Application code split inplatform independent(C/C++) code (lightbrown boxes) andplatform dependentcode (C/C++, Java orObjective C) in darkbrown boxes. Supportedplatforms are: GLFW(desktop OS),Emscripten (Web), iOSand Android.AppGLFWwindow: GLFWwindow*run()onResize()onPaint()onMouseButton()onMouseMove()onKeyPress()SLInterface C-InterfaceslCreateAppAndScene()slCreateSceneView()slUpdateScene()slResize()slPaintAllViews()slOnMouseDown()onKeyPress()UtilsUtilsAveragedProfilerCV contains classes that useOpenCV for video processing. No SL classes are used.SL (Scene Library) C++ classes contain thefunctionality scenegraph management and 3Drendering with OpenGL, ray or path tracing.Utils contains helpers used by SLand CV. No dependenciesExternalsOpenGLOpenCVassimpimguiglfwgl3w3D graphics API foracceleratedframebuffer renderingComputer Visionlibrary for imageand videoprocessing3D assets importand export libraryImmediate ModeGUI library forrealtime framebufferrenderingOpenGL contextand windowmanagement librarySimple OpenGLcore profile loadinglibrarySLRaytracerrenderClassic()renderDistrib()renderSlices()trace()shade()setPrimaryRay()sampleAAPixel()renderImage()saveImage()SLRayorigin: SLVec3fdir: SLVec3flength: floatdepth: intcontrib: floathitNode: SLNode*hitMesh: SLMesh*hitTriangle: uintreflect()refract()+1SLPathtracer+1Inherits fromSLSceneView ifspecific event handlingis needed.Video capturing for Android andiOS is handled within thetoplevel app code.SLLens_diameter: float_thickness: float_radiusBot: float_radiusTop: floatSLArrow_radius: float_length: float_headLen: float_headWidth: floatSLVec4fx: floaty: floatz: floatw: floatlength()SLVec2fx: floaty: floatlength()normalize()All UI is renderedwith OpenGL withImGUI once perframe.Top level main() functioncalls App::run.All external libraries areeither within the SLProjectrepository or areautomatically automaticallydownloaded by cmake,v4.2open source C++library for geometryprocessing researchand developmentlibiglSLAssetManager+meshes: SLVMesh+materials: SLVMaterial+textures: SLVGLTexture+programs: SLVGLProgramOwns top-levelinstances for apps+1..n+1SLGLProgramGenerated+buildProgramCode()+buildProgramName()Linear algebrasupport library foradvanced linalgoperationseigenProfilerZipUtilsPlatform dependent code.C-Interface for non-Cplatforms (iOS, Android)Major event handlerAll video code used fortracking.SLImGui+onInitNewFrame()+onPaint()+loadFonts()+onMouseDown()+onKeyPress()+1 \ No newline at end of file diff --git a/docs/images/app_framework.svg b/docs/images/app_framework.svg index 6fc7dd7..42d0eff 100644 --- a/docs/images/app_framework.svg +++ b/docs/images/app_framework.svg @@ -1,4 +1,4 @@ -
SL (SceneLibrary) Layer
SL (SceneLibrary) Layer
Platform Layer
Platform Layer
App Layer
App Layer
AppDemoMainAppNodeMainAppMinimalMainApp.hAppGLFW.cppAppEmscripten.cppAppAndroid.cppAppIOS.mmSLInterface.hAppCommonSLSceneSLSceneViewSLImGuiSLAssetManagerSLInputManager
C-Interface
C-Interface
Owner of SL Instances
Owner of SL Instances
Text is not SVG - cannot display
\ No newline at end of file +
SL (SceneLibrary) Layer
SL (SceneLibrary) Layer
Platform Layer
Platform Layer
App Layer
App Layer
AppDemoMainAppNodeMainAppMinimalMainApp.hAppGLFW.cppAppEmscripten.cppAppAndroid.cppAppIOS.mmSLInterface.hAppCommonSLSceneSLSceneViewSLImGuiSLAssetManagerSLInputManager
C-Interface
C-Interface
Owner of SL Instances
Owner of SL Instances
Text is not SVG - cannot display
\ No newline at end of file diff --git a/docs/pages/AppFramework.md b/docs/pages/AppFramework.md index 07f8b6d..19631dc 100644 --- a/docs/pages/AppFramework.md +++ b/docs/pages/AppFramework.md @@ -2,16 +2,11 @@ \section overview Overview -SLProject provides a framework for quickly setting up platform-independent apps that run on Windows, macOS, Linux, Android, iOS, and the Web. -The app framework is divided into three layers: +SLProject provides a framework for quickly setting up platform-independent apps that run on Windows, macOS, Linux, Android, iOS, and the Web. The app framework is divided into three layers: -- The **%App Layer** contains the code of your app. It contains the main function, some configuration code, and callbacks for hooking into - the SLProject systems. The central interface every app uses is the `App.h` header, which is implemented by the platform layer. -- The **Platform Layer** contains all platform-specific code for creating the rendering surface, setting up event handlers, etc. Every - platform has its own implementation of the `App.h`. The implementation corresponding to the target platform is selected at compile time by CMake. - The platform layer uses `SLInterface.h` to access SLProject modules. -- The **SL Layer** contains all the SLProject libraries. This is where rendering, UI, math, asset loading, input handling, video capture, etc. - is done. +- The **App Layer** contains the code of your app. At least one code file has to contain the apps main function and some configuration code, and callbacks for hooking into the SLProject systems. In our example apps these files end with *Main.cpp. The app code also must compile the AppCommon class that is the owner of the central instances of the SLProject. The central interface that every app uses is the `App.h` header, which is implemented by the platform layer. +- The **Platform Layer** contains all platform-specific code for creating the rendering surface, setting up event handlers, etc. Every platform has its own implementation of the `App.h`. The implementation corresponding to the target platform is selected at compile time by CMake. The platform layer uses `SLInterface.h` to access SLProject modules. The platform-specific code is C/C++ for the GLFW platforms (Windows, MacOS & Linux), C/C++ and Java for Android, C/C++ and JavaScript for Emscripten (running in the web browser) and ObjectiveC for iOS. All platform-specific code is under `apps/source/platforms`. +- The **SL Layer** contains all the SLProject libraries. This is where all inputs get processed, the updates get done and finally the 3D, 2D and UI rendering is done. The shown classes in the diagram is only a small section of the framework. Please see the [introduction page](https://cpvrlab.github.io/SLProject4/introduction.html) for a deeper overview.
@@ -53,15 +48,9 @@ int SL_MAIN_FUNCTION(int argc, char* argv[]) } ``` -The main function is defined using a macro that expands to the name of the main function on -the current platform. This is usually `main`, but on Android it expands to `slAndroidMain`, -a fake main function that is called from the JNI to initialize the application because there is -no actual `main` on Android. +The main function is defined using a macro that expands to the name of the main function on the current platform. This is usually `main`, but on Android it expands to `slAndroidMain`, a fake main function that is called from the JNI to initialize the application because there is no actual `main` on Android. -Inside the main function, an `App::Config` instance is created. This configuration specifies -things like the window size, the ID of the start scene, or a callback for building the GUI. -`App::run` is then called with this config to start the app. Every platform implements its own -version of this function. The various implementations can be found in `apps/source/platforms`. +Inside the main function, an `App::Config` instance is created. This configuration specifies things like the window size, the ID of the start scene, or a callback for building the GUI. `App::run` is then called with this config to start the app. Every platform implements its own version of this function. The various implementations can be found in `apps/source/platforms`. Here's a list of all of them: - `AppGLFW.cpp` (Windows, macOS, Linux) @@ -69,26 +58,15 @@ Here's a list of all of them: - `AppAndroid.cpp` (Android) - `AppIOS.mm` (iOS) -An implementation of `App::run` typically sets up the rendering surface, registers event handlers, -loads core assets, starts the event loop, and returns when the program terminates. -Only the Android version returns immediately because the event loop is handled by Java code and -interacts with the app via the JNI. +An implementation of `App::run` typically sets up the rendering surface, registers event handlers, loads core assets, starts the event loop, and returns when the program terminates. Only the Android version returns immediately because the event loop is handled by Java code and interacts with the app via the JNI. -For more information on creating a new app, see -[this wiki page](https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App). +For more information on creating a new app, see [this wiki page](https://github.com/cpvrlab/SLProject4/wiki/Creating-a-New-App). \subsection cmake CMake -New apps are added by calling the custom CMake function `sl_add_app`. This function is defined -in `apps/CMakeLists.txt` and takes care of creating a new target and setting source files, -headers, compile options, linked libraries, properties, etc. depending on the target platform. -The function has parameters for specifying things like the name of the target, the platforms -the app supports, additional source files (e.g. for scenes), the directory of the Android -project, or iOS resources. +New apps are added by calling the custom CMake function `sl_add_app`. This function is defined in `apps/CMakeLists.txt` and takes care of creating a new target and setting source files, headers, compile options, linked libraries, properties, etc. depending on the target platform. The function has parameters for specifying things like the name of the target, the platforms the app supports, additional source files (e.g. for scenes), the directory of the Android project, or iOS resources. -`sl_add_app` uses the CMake variable `SL_PLATFORM` to decide which platform is currently being -targeted. This variable is set in the top-level `CMakeLists.txt` based on the current target -system. The possible platforms are: +`sl_add_app` uses the CMake variable `SL_PLATFORM` to decide which platform is currently being targeted. This variable is set in the top-level `CMakeLists.txt` based on the current target system. The possible platforms are: - `GLFW` (Windows, macOS, Linux) - `EMSCRIPTEN` (Web) @@ -97,9 +75,7 @@ system. The possible platforms are: \section scene-loading Scene Loading -A scene is loaded by setting the value of `AppCommon::sceneToLoad` to the ID of the new scene. -Inside the event loop of every platform, we check whether this variable has a value and switch -to the new scene if so: +A scene is loaded by setting the value of `AppCommon::sceneToLoad` to the ID of the new scene. Inside the event loop of every platform, we check whether this variable has a value and switch to the new scene if so: ```cpp if (AppCommon::sceneToLoad) @@ -109,18 +85,7 @@ if (AppCommon::sceneToLoad) } ``` -Scene switching is implemented inside `AppLoad::switchScene`. This function calls the callback -`AppConfig::onNewScene` to create a new scene instance. The callback is specified by the app and -returns an instance of a class derived from `SLScene` (e.g. `AppDemoSceneMinimal`). -After creating the new scene instance, we switch to it in two stages: - -1. Register assets to be loaded. We call the overloaded `SLScene::registerAssetsToLoad` so it can - register tasks on the `SLAssetLoader` to be executed asynchronously in a different thread. - Meanwhile, the event loop on the main thread continues running so we can for example render - a loading screen. Every frame, `SLAssetLoader::checkIfAsyncLoadingIsDone` is called to check whether - the worker thread is done. When that happens, the next stage is triggered. - Note: All I/O operations have to be registered here because they cannot be executed synchronously on - the main thread on the Emscripten platform. -2. Assemble the scene. When the asset loader is done, we call the overloaded `SLScene::assemble` - function that uses the loaded assets to assemble the scene. After assembly, `AppCommon::scene` - is set to the new scene and the scene switch is completed. +Scene switching is implemented inside `AppLoad::switchScene`. This function calls the callback `AppConfig::onNewScene` to create a new scene instance. The callback is specified by the app and returns an instance of a class derived from `SLScene` (e.g. `AppDemoSceneMinimal`). After creating the new scene instance, we switch to it in two stages: + +1. Register assets to be loaded. We call the overloaded `SLScene::registerAssetsToLoad` so it can register tasks on the `SLAssetLoader` to be executed asynchronously in a different thread. Meanwhile, the event loop on the main thread continues running so we can for example render a loading screen. Every frame, `SLAssetLoader::checkIfAsyncLoadingIsDone` is called to check whether the worker thread is done. When that happens, the next stage is triggered. Note: All I/O operations have to be registered here because they cannot be executed synchronously on the main thread on the [Emscripten platform](https://cpvrlab.github.io/SLProject4/emscripten.html). +2. Assemble the scene. When the asset loader is done, we call the overloaded `SLScene::assemble` function that uses the loaded assets to assemble the scene. After assembly, `AppCommon::scene` is set to the new scene and the scene switch is completed. diff --git a/docs/pages/Introduction.md b/docs/pages/Introduction.md index 1b3a7c6..b71def1 100644 --- a/docs/pages/Introduction.md +++ b/docs/pages/Introduction.md @@ -30,15 +30,15 @@ There are 5 code sections in SLProject: The following class diagram gives you an overview of the major classes with its important attributes and methods: -- The **gray boxes** on top contain the application code that depend on the OS and do the GUI, the scene assembly and the video processing. -- The **light blue classes** are the central classes with the top-level instances of SLAssetManager and SLInputManager. The core classes for the scene are SLScene and SLSceneView. +- The **brown boxes** on top contain the application code that depend on the OS and do the GUI, the scene assembly and the video processing. +- The **light blue classes** are the central classes with the top-level instances of SLAssetManager and SLInputManager. The core classes for the scene are SLScene and SLSceneView. The UI is redered with SLImGui. - The **dark blue classes** are the alternative renderers for ray tracing and path tracing. - The **yellow classes** define the materials that are responsible for the visual appearances of the mesh objects. - The **green classes** build the scene graph that defines the spacial structure of the visible objects. - The **pink classes** define a single triangulated mesh object. - The **violet classes** encapsulate all OpenGL vertex array object and buffer objects. - The **red classes** build the animation framework. -- The **orange classes** encapsulate the video, image and AR tracking functionality using OpenCV. CV classes are independent from all SL classes. Only SLGLTexture uses CVImage for its texture images. +- The **peach classes** to the right encapsulate the video, image and AR tracking functionality using OpenCV. CV classes are independent from all SL classes. Only SLGLTexture uses CVImage for its texture images. - The **red classes** build the animation framework. - The **white classes** are low level classes for the math. Some of them are within the namespace Utils. - The **gray boxes** at the bottom are the external libraries that are used within the frame work. @@ -48,8 +48,8 @@ The following class diagram gives you an overview of the major classes with its \section app Application Code The application's code (grey boxes at the top of the diagram) contains the code for the operating system, the scene definition with SLProject library (SL), the video processing using CV-classes and the UI with ImGUI. In all cases we have the most outer shell of the application that handles the window and the OpenGL context creation and passes the events to a thin C-function interface before it is handled by the C++-framework in the library lib-SLProject. -For more information about application code please read the page about the [App Framework](https://cpvrlab.github.io/SLProject4/app-framework.html). -The following systems are supported and applications are provided for demonstration: + +The following platforms are supported and applications are provided for demonstration: - **Windows, Linux and macOS** applications use the [GLFW](http://www.glfw.org/) C-library for the platform independent window and context creation. @@ -60,27 +60,16 @@ The following systems are supported and applications are provided for demonstrat - **Apple iOS** applications start in Objective-C before it passes the events to the C-interface. See the [wiki for build instructions](https://github.com/cpvrlab/SLProject4/wiki/Build-on-MacOS-with-XCode-for-iOS) and `apps/source/platforms/ios/example_project` for the project used in demos. -- **Web** applications use [Emscripten](https://cpvrlab.github.io/SLProject4/emscripten.html) to compile C++ code to - [WebAssembly](https://webassembly.org/). This allows applications to be served by a web server +- **Web** applications use [Emscripten](https://cpvrlab.github.io/SLProject4/emscripten.html) to compile C++ code to [WebAssembly](https://webassembly.org/). This allows applications to be served by a web server and run inside the browser. -For all demo apps (desktop and mobile) we use the [Dear ImGui](https://github.com/ocornut/imgui) library for the UI. -The UI for `app-demo` is implemented in AppDemoGui. Dear ImGui is also included in the repository. -You could in fact use any GUI library on any OS that can render using OpenGL. -Other alternatives could be e.g. [Qt](https://www.qt.io/), [freeglut](http://freeglut.sourceforge.net/), -[FLTK](http://www.fltk.org/index.php), [wxWidgets](http://www.wxwidgets.org/), -[Nana](http://www.nanapro.org/en-us/), or [Juce](http://www.juce.com/). - -SLInterface.h and SLInterface.cpp define the C-Interface of the SLProject library. -We use a C-interface because this type can be called from any higher level language. -The SLInterface talks only to the SLInputManager, SLScene and SLSceneView classes. +For all demo apps (desktop and mobile) we use the [Dear ImGui](https://github.com/ocornut/imgui) library for the UI. The UI for `app-demo` is implemented in AppDemoGui. Dear ImGui is also included in the repository. For more information about SLProject's app framework, see [this page](#app-framework). \section central Central Classes The light blue classes form the center of the SLProject framework: - - SLAssetManager holds the expensive resources such as meshes, materials, textures and shader programs in vectors. - SLInputManager collects all user events from the mouse and keyboard as well as from additional input devices such as a LeapMotion or Kinect sensor. - SLScene is the top-level class of the framework that represents the scene with