SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLImporter.h
Go to the documentation of this file.
1 /**
2  * \file SLImporter.h
3  * \authors Marcus Hudritsch
4  * \date July 2014
5  * \authors Marcus Hudritsch
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifndef SLIMPORTER_H
12 #define SLIMPORTER_H
13 
14 #include <fstream>
15 #include <map>
16 
17 #include <SL.h>
18 #include <SLAnimation.h>
19 #include <SLEnums.h>
20 #include <SLMesh.h>
21 
22 class SLNode;
23 class SLMaterial;
24 class SLAssetManager;
25 class SLAnimManager;
26 class SLProgressHandler;
27 class SLSkybox;
28 
29 //-----------------------------------------------------------------------------
30 //! Copy of the aiPostProcessStep enum for usage in the wrapper load function
32 {
55  SLProcess_FlipUVs = 0x800000,
58  SLProcess_Dejoint = 0x4000000
59 };
60 
61 //-----------------------------------------------------------------------------
62 typedef std::map<int, SLMesh*> SLMeshMap;
63 //-----------------------------------------------------------------------------
64 //! Interface for 3D file format importer implementations
66 {
67 public:
68  SLImporter();
69  explicit SLImporter(SLLogVerbosity consoleVerb);
70  explicit SLImporter(const SLstring& logFile,
71  SLLogVerbosity logConsoleVerb = LV_normal,
72  SLLogVerbosity logFileVerb = LV_diagnostic);
73  virtual ~SLImporter();
74 
77 
78  virtual SLNode* load(SLAnimManager& aniMan,
79  SLAssetManager* assetMgr,
80  SLstring pathFilename,
81  SLstring texturePath,
82  SLSkybox* skybox = nullptr,
83  SLbool deleteTexImgAfterBuild = false,
84  SLbool loadMeshesOnly = true,
85  SLMaterial* overrideMat = nullptr,
86  float ambientFactor = 0.0f,
87  SLbool forceCookTorranceRM = false,
88  SLProgressHandler* progressHandler = nullptr,
89  SLuint flags =
97  //|SLProcess_OptimizeMeshes
98  //|SLProcess_OptimizeGraph
99  //|SLProcess_CalcTangentSpace
100  //|SLProcess_MakeLeftHanded
101  //|SLProcess_RemoveComponent
102  //|SLProcess_GenNormals
103  //|SLProcess_GenSmoothNormals
104  //|SLProcess_PreTransformVertices
105  //|SLProcess_LimitJointWeights
106  //|SLProcess_ValidateDataStructure
107  //|SLProcess_ImproveCacheLocality
108  //|SLProcess_FixInfacingNormals
109  //|SLProcess_GenUVCoords
110  //|SLProcess_TransformUVCoords
111  //|SLProcess_FindInstances
112  //|SLProcess_FlipUVs
113  //|SLProcess_FlipWindingOrder
114  //|SLProcess_SplitByJointCount
115  //|SLProcess_Dejoint
116  ) = 0;
117 
118  SLNode* rootNode() { return _sceneRoot; }
119  SLVMesh& meshes() { return _meshes; }
122 
123 protected:
124  std::ofstream _log; //!< log stream
125  SLstring _logFile; //!< name of the log file
126  SLLogVerbosity _logConsoleVerbosity; //!< verbosity level of log output to the console
127  SLLogVerbosity _logFileVerbosity; //!< verbosity level of log output to the file
128 
129  // the imported data for easy access after importing it
130  SLNode* _sceneRoot; //!< the root node of the scene
131  SLVMesh _meshes; //!< all imported meshes
132  SLAnimSkeleton* _skeleton; //!< the imported skeleton for this file
133  SLVAnimation _animationNamesMap; //!< all imported node animations
134 
135  // misc helper
136  void logMessage(SLLogVerbosity verbosity, const char* msg, ...);
137 };
138 //-----------------------------------------------------------------------------
139 #endif // SLIMPORTER_H
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
vector< SLAnimation * > SLVAnimation
Definition: SLAnimation.h:84
SLLogVerbosity
Definition: SLEnums.h:244
@ LV_diagnostic
Definition: SLEnums.h:249
@ LV_normal
Definition: SLEnums.h:247
SLPostProcessSteps
Copy of the aiPostProcessStep enum for usage in the wrapper load function.
Definition: SLImporter.h:32
@ SLProcess_SplitByJointCount
Definition: SLImporter.h:57
@ SLProcess_OptimizeMeshes
Definition: SLImporter.h:53
@ SLProcess_SplitLargeMeshes
Definition: SLImporter.h:40
@ SLProcess_FindInstances
Definition: SLImporter.h:52
@ SLProcess_SortByPType
Definition: SLImporter.h:47
@ SLProcess_Triangulate
Definition: SLImporter.h:36
@ SLProcess_FlipUVs
Definition: SLImporter.h:55
@ SLProcess_ImproveCacheLocality
Definition: SLImporter.h:44
@ SLProcess_Dejoint
Definition: SLImporter.h:58
@ SLProcess_GenUVCoords
Definition: SLImporter.h:50
@ SLProcess_PreTransformVertices
Definition: SLImporter.h:41
@ SLProcess_FindDegenerates
Definition: SLImporter.h:48
@ SLProcess_FlipWindingOrder
Definition: SLImporter.h:56
@ SLProcess_FixInfacingNormals
Definition: SLImporter.h:46
@ SLProcess_FindInvalidData
Definition: SLImporter.h:49
@ SLProcess_GenNormals
Definition: SLImporter.h:38
@ SLProcess_GenSmoothNormals
Definition: SLImporter.h:39
@ SLProcess_ValidateDataStructure
Definition: SLImporter.h:43
@ SLProcess_LimitJointWeights
Definition: SLImporter.h:42
@ SLProcess_RemoveRedundantMaterials
Definition: SLImporter.h:45
@ SLProcess_TransformUVCoords
Definition: SLImporter.h:51
@ SLProcess_OptimizeGraph
Definition: SLImporter.h:54
@ SLProcess_JoinIdenticalVertices
Definition: SLImporter.h:34
@ SLProcess_MakeLeftHanded
Definition: SLImporter.h:35
@ SLProcess_RemoveComponent
Definition: SLImporter.h:37
@ SLProcess_CalcTangentSpace
Definition: SLImporter.h:33
std::map< int, SLMesh * > SLMeshMap
Definition: SLImporter.h:62
vector< SLMesh * > SLVMesh
Definition: SLMesh.h:263
SLAnimManager is the central class for all animation handling.
Definition: SLAnimManager.h:27
SLAnimSkeleton keeps track of a skeletons joints and animations.
Toplevel holder of the assets meshes, materials, textures and shaders.
Interface for 3D file format importer implementations.
Definition: SLImporter.h:66
SLNode * rootNode()
Definition: SLImporter.h:118
SLAnimSkeleton * _skeleton
the imported skeleton for this file
Definition: SLImporter.h:132
void logConsoleVerbosity(SLLogVerbosity verb)
Definition: SLImporter.h:75
SLVAnimation _animationNamesMap
all imported node animations
Definition: SLImporter.h:133
SLAnimSkeleton * skeleton()
Definition: SLImporter.h:120
SLLogVerbosity _logConsoleVerbosity
verbosity level of log output to the console
Definition: SLImporter.h:126
SLVMesh _meshes
all imported meshes
Definition: SLImporter.h:131
void logFileVerbosity(SLLogVerbosity verb)
Definition: SLImporter.h:76
SLVAnimation & nodeAnimations()
Definition: SLImporter.h:121
SLLogVerbosity _logFileVerbosity
verbosity level of log output to the file
Definition: SLImporter.h:127
SLNode * _sceneRoot
the root node of the scene
Definition: SLImporter.h:130
virtual ~SLImporter()
Definition: SLImporter.cpp:51
SLVMesh & meshes()
Definition: SLImporter.h:119
void logMessage(SLLogVerbosity verbosity, const char *msg,...)
Definition: SLImporter.cpp:66
std::ofstream _log
log stream
Definition: SLImporter.h:124
virtual SLNode * load(SLAnimManager &aniMan, SLAssetManager *assetMgr, SLstring pathFilename, SLstring texturePath, SLSkybox *skybox=nullptr, SLbool deleteTexImgAfterBuild=false, SLbool loadMeshesOnly=true, SLMaterial *overrideMat=nullptr, float ambientFactor=0.0f, SLbool forceCookTorranceRM=false, SLProgressHandler *progressHandler=nullptr, SLuint flags=SLProcess_Triangulate|SLProcess_JoinIdenticalVertices|SLProcess_SplitLargeMeshes|SLProcess_RemoveRedundantMaterials|SLProcess_SortByPType|SLProcess_FindDegenerates|SLProcess_FindInvalidData)=0
SLstring _logFile
name of the log file
Definition: SLImporter.h:125
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
Skybox node class with a SLBox mesh.
Definition: SLSkybox.h:29