![]()  | 
  
    SLProject
    4.2.000
    
   A platform independent 3D computer graphics framework for desktop OS,  Android,  iOS and online in web browsers 
   | 
 
#include <SLAssetLoader.h>
Public Member Functions | |
| SLAssetLoader (SLstring modelPath, SLstring texturePath, SLstring shaderPath, SLstring fontPath) | |
| ~SLAssetLoader () | |
| void | scene (SLScene *scene) | 
| bool | isLoading () const | 
| SLstring | modelPath () const | 
| SLstring | shaderPath () const | 
| SLstring | texturePath () const | 
| void | addRawDataToLoad (SLIOBuffer &buffer, SLstring filename, SLIOStreamKind kind) | 
| void | addTextureToLoad (SLGLTexture *&texture, const SLstring &path, SLint min_filter=GL_LINEAR_MIPMAP_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT) | 
| Add 2D textures with internal image allocation.  More... | |
| void | addTextureToLoad (SLGLTexture *&texture, const SLstring &imageFilenameXPos, const SLstring &imageFilenameXNeg, const SLstring &imageFilenameYPos, const SLstring &imageFilenameYNeg, const SLstring &imageFilenameZPos, const SLstring &imageFilenameZNeg, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown) | 
| Add cube map texture with internal image allocation.  More... | |
| void | addTextureToLoad (SLGLTexture *&texture, SLint depth, const SLstring &path, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT, const SLstring &name="3D-Texture", SLbool loadGrayscaleIntoAlpha=false) | 
| Add 3D texture from a single file with depth as 3rd dimension.  More... | |
| void | addTextureToLoad (SLGLTexture *&texture, const SLVstring &imagePaths, SLint min_filter, SLint mag_filter, SLint wrapS, SLint wrapT, const SLstring &name, SLbool loadGrayscaleIntoAlpha) | 
| Add 3D texture from a vector of files.  More... | |
| void | addGeoTiffToLoad (SLDeviceLocation &devLoc, const SLstring &imageFileWithPath) | 
| Add GeoTiff file to load for the SLDevLocation.  More... | |
| void | addNodeToLoad (SLNode *&node, const SLstring &modelPath, SLSkybox *skybox=nullptr, SLbool deleteTexImgAfterBuild=false, SLbool loadMeshesOnly=true, SLMaterial *overrideMat=nullptr, float ambientFactor=0.5f, SLbool forceCookTorranceRM=false, SLuint flags=SLProcess_Triangulate|SLProcess_JoinIdenticalVertices|SLProcess_RemoveRedundantMaterials|SLProcess_FindDegenerates|SLProcess_FindInvalidData|SLProcess_SplitLargeMeshes) | 
| Add mesh from file to load via assimp loader.  More... | |
| void | addProgramToLoad (SLGLProgram *&program, const SLstring &vertShaderFile, const SLstring &fragShaderFile) | 
| Add generic GLSL program with shader files to load.  More... | |
| void | addSkyboxToLoad (SLSkybox *&skybox, const SLstring &path, SLVec2i resolution, SLstring name) | 
| Add skybox with HDR texture to load.  More... | |
| void | addSkyboxToLoad (SLSkybox *&skybox, const SLstring &cubeMapXPos, const SLstring &cubeMapXNeg, const SLstring &cubeMapYPos, const SLstring &cubeMapYNeg, const SLstring &cubeMapZPos, const SLstring &cubeMapZNeg) | 
| Add skybox with 6 textures for a cubemap to load.  More... | |
| void | addLoadTask (SLAssetLoadTask task) | 
| Add generic task.  More... | |
| void | loadAssetsSync () | 
| void | loadAssetsAsync (function< void()> onDone) | 
| void | checkIfAsyncLoadingIsDone () | 
Public Attributes | |
| SLScene * | _scene | 
| SLAssetManager * | _am | 
| SLstring | _modelPath | 
| SLstring | _texturePath | 
| SLstring | _shaderPath | 
| SLstring | _fontPath | 
| SLVAssetLoadTask | _loadTasks | 
| function< void()> | _onDoneLoading | 
| Callback after threaded loading.  More... | |
| thread | _worker | 
| worker thread for parallel loading  More... | |
| atomic< State > | _state | 
| current state (used for communication between threads)  More... | |
| mutex | _messageMutex | 
| mutex protecting state between threads  More... | |
| condition_variable | _messageCondVar | 
| mutex for waiting until state has changed  More... | |
Private Types | |
| enum class | State { IDLE , SUBMITTED , WORKING , DONE , STOPPING , STOPPED } | 
Definition at line 44 of file SLAssetLoader.h.
      
  | 
  strongprivate | 
| Enumerator | |
|---|---|
| IDLE | |
| SUBMITTED | |
| WORKING | |
| DONE | |
| STOPPING | |
| STOPPED | |
Definition at line 47 of file SLAssetLoader.h.
| SLAssetLoader::SLAssetLoader | ( | SLstring | modelPath, | 
| SLstring | texturePath, | ||
| SLstring | shaderPath, | ||
| SLstring | fontPath | ||
| ) | 
Definition at line 27 of file SLAssetLoader.cpp.
| SLAssetLoader::~SLAssetLoader | ( | ) | 
Definition at line 74 of file SLAssetLoader.cpp.
| void SLAssetLoader::addGeoTiffToLoad | ( | SLDeviceLocation & | devLoc, | 
| const SLstring & | imageFileWithPath | ||
| ) | 
Add GeoTiff file to load for the SLDevLocation.
Definition at line 229 of file SLAssetLoader.cpp.
| void SLAssetLoader::addLoadTask | ( | SLAssetLoadTask | task | ) | 
Add generic task.
Definition at line 304 of file SLAssetLoader.cpp.
| void SLAssetLoader::addNodeToLoad | ( | SLNode *& | node, | 
| const SLstring & | modelPath, | ||
| SLSkybox * | skybox = nullptr,  | 
        ||
| SLbool | deleteTexImgAfterBuild = false,  | 
        ||
| SLbool | loadMeshesOnly = true,  | 
        ||
| SLMaterial * | overrideMat = nullptr,  | 
        ||
| float | ambientFactor = 0.5f,  | 
        ||
| SLbool | forceCookTorranceRM = false,  | 
        ||
| SLuint | flags = SLProcess_Triangulate | SLProcess_JoinIdenticalVertices | SLProcess_RemoveRedundantMaterials | SLProcess_FindDegenerates | SLProcess_FindInvalidData | SLProcess_SplitLargeMeshes  | 
        ||
| ) | 
| void SLAssetLoader::addProgramToLoad | ( | SLGLProgram *& | program, | 
| const SLstring & | vertShaderFile, | ||
| const SLstring & | fragShaderFile | ||
| ) | 
Add generic GLSL program with shader files to load.
Definition at line 238 of file SLAssetLoader.cpp.
| void SLAssetLoader::addRawDataToLoad | ( | SLIOBuffer & | buffer, | 
| SLstring | filename, | ||
| SLIOStreamKind | kind | ||
| ) | 
Definition at line 89 of file SLAssetLoader.cpp.
| void SLAssetLoader::addSkyboxToLoad | ( | SLSkybox *& | skybox, | 
| const SLstring & | cubeMapXPos, | ||
| const SLstring & | cubeMapXNeg, | ||
| const SLstring & | cubeMapYPos, | ||
| const SLstring & | cubeMapYNeg, | ||
| const SLstring & | cubeMapZPos, | ||
| const SLstring & | cubeMapZNeg | ||
| ) | 
| void SLAssetLoader::addSkyboxToLoad | ( | SLSkybox *& | skybox, | 
| const SLstring & | path, | ||
| SLVec2i | resolution, | ||
| SLstring | name | ||
| ) | 
| void SLAssetLoader::addTextureToLoad | ( | SLGLTexture *& | texture, | 
| const SLstring & | imageFilenameXPos, | ||
| const SLstring & | imageFilenameXNeg, | ||
| const SLstring & | imageFilenameYPos, | ||
| const SLstring & | imageFilenameYNeg, | ||
| const SLstring & | imageFilenameZPos, | ||
| const SLstring & | imageFilenameZNeg, | ||
| SLint | min_filter = GL_LINEAR,  | 
        ||
| SLint | mag_filter = GL_LINEAR,  | 
        ||
| SLTextureType | type = TT_unknown  | 
        ||
| ) | 
Add cube map texture with internal image allocation.
Definition at line 122 of file SLAssetLoader.cpp.
| void SLAssetLoader::addTextureToLoad | ( | SLGLTexture *& | texture, | 
| const SLstring & | path, | ||
| SLint | min_filter = GL_LINEAR_MIPMAP_LINEAR,  | 
        ||
| SLint | mag_filter = GL_LINEAR,  | 
        ||
| SLTextureType | type = TT_unknown,  | 
        ||
| SLint | wrapS = GL_REPEAT,  | 
        ||
| SLint | wrapT = GL_REPEAT  | 
        ||
| ) | 
| void SLAssetLoader::addTextureToLoad | ( | SLGLTexture *& | texture, | 
| const SLVstring & | imagePaths, | ||
| SLint | min_filter, | ||
| SLint | mag_filter, | ||
| SLint | wrapS, | ||
| SLint | wrapT, | ||
| const SLstring & | name, | ||
| SLbool | loadGrayscaleIntoAlpha | ||
| ) | 
Add 3D texture from a vector of files.
Method for adding a 3D texture from a vector of images to load in parallel thread.
| texture | Pointer to SLGLTexture to return | 
| imageFilenames | Vector of texture image files. If only filenames are passed they will be searched on the SLGLTexture::defaultPath. | 
| min_filter | Minification filter constant from OpenGL | 
| mag_filter | Magnification filter constant from OpenGL | 
| wrapS | Texture wrapping in S direction (OpenGL constant) | 
| wrapT | Texture wrapping in T direction (OpenGL constant) | 
| name | Name of the 3D texture | 
| loadGrayscaleIntoAlpha | Flag if grayscale image should be loaded into alpha channel. | 
Definition at line 201 of file SLAssetLoader.cpp.
| void SLAssetLoader::addTextureToLoad | ( | SLGLTexture *& | texture, | 
| SLint | depth, | ||
| const SLstring & | path, | ||
| SLint | min_filter = GL_LINEAR,  | 
        ||
| SLint | mag_filter = GL_LINEAR,  | 
        ||
| SLint | wrapS = GL_REPEAT,  | 
        ||
| SLint | wrapT = GL_REPEAT,  | 
        ||
| const SLstring & | name = "3D-Texture",  | 
        ||
| SLbool | loadGrayscaleIntoAlpha = false  | 
        ||
| ) | 
Add 3D texture from a single file with depth as 3rd dimension.
Definition at line 156 of file SLAssetLoader.cpp.
| void SLAssetLoader::checkIfAsyncLoadingIsDone | ( | ) | 
This method is called from the main thread to check if the async loading is is finished. If so, the assembly can be done in _onDoneLoading.
Definition at line 357 of file SLAssetLoader.cpp.
      
  | 
  inline | 
Definition at line 68 of file SLAssetLoader.h.
Definition at line 343 of file SLAssetLoader.cpp.
| void SLAssetLoader::loadAssetsSync | ( | ) | 
Definition at line 335 of file SLAssetLoader.cpp.
      
  | 
  inline | 
Definition at line 69 of file SLAssetLoader.h.
Definition at line 65 of file SLAssetLoader.h.
      
  | 
  inline | 
Definition at line 70 of file SLAssetLoader.h.
      
  | 
  inline | 
Definition at line 71 of file SLAssetLoader.h.
| SLAssetManager* SLAssetLoader::_am | 
Definition at line 169 of file SLAssetLoader.h.
| SLstring SLAssetLoader::_fontPath | 
Definition at line 173 of file SLAssetLoader.h.
| SLVAssetLoadTask SLAssetLoader::_loadTasks | 
Definition at line 174 of file SLAssetLoader.h.
| condition_variable SLAssetLoader::_messageCondVar | 
mutex for waiting until state has changed
Definition at line 180 of file SLAssetLoader.h.
| mutex SLAssetLoader::_messageMutex | 
mutex protecting state between threads
Definition at line 179 of file SLAssetLoader.h.
| SLstring SLAssetLoader::_modelPath | 
Definition at line 170 of file SLAssetLoader.h.
| function<void()> SLAssetLoader::_onDoneLoading | 
Callback after threaded loading.
Definition at line 175 of file SLAssetLoader.h.
| SLScene* SLAssetLoader::_scene | 
Definition at line 168 of file SLAssetLoader.h.
| SLstring SLAssetLoader::_shaderPath | 
Definition at line 172 of file SLAssetLoader.h.
| atomic<State> SLAssetLoader::_state | 
current state (used for communication between threads)
Definition at line 178 of file SLAssetLoader.h.
| SLstring SLAssetLoader::_texturePath | 
Definition at line 171 of file SLAssetLoader.h.
| thread SLAssetLoader::_worker | 
worker thread for parallel loading
Definition at line 177 of file SLAssetLoader.h.