TDME2  1.9.200
ModelReaderFBX.cpp
Go to the documentation of this file.
2 
3 #include <memory>
4 #include <string>
5 #include <vector>
6 
7 #include <tdme/tdme.h>
18 #include <tdme/utilities/Console.h>
21 
22 using std::string;
23 using std::unique_ptr;
24 using std::vector;
25 
40 
41 vector<string> ModelReader::extensions = {{"dae", "fbx", "glb", "gltf", "tm", "tmodel"}};
42 
43 const vector<string>& ModelReader::getModelExtensions() {
44  return extensions;
45 }
46 
47 Model* ModelReader::read(const string& pathName, const string& fileName, bool useBC7TextureCompression)
48 {
49  try {
50  if (StringTools::endsWith(StringTools::toLowerCase(fileName), ".dae") == true) {
51  return DAEReader::read(pathName, fileName, useBC7TextureCompression);
52  } else
53  if (StringTools::endsWith(StringTools::toLowerCase(fileName), ".fbx") == true) {
54  return FBXReader::read(pathName, fileName, useBC7TextureCompression);
55  } else
56  if (StringTools::endsWith(StringTools::toLowerCase(fileName), ".glb") == true) {
57  return GLTFReader::read(pathName, fileName, useBC7TextureCompression);
58  } else
59  if (StringTools::endsWith(StringTools::toLowerCase(fileName), ".gltf") == true) {
60  return GLTFReader::read(pathName, fileName, useBC7TextureCompression);
61  } else
62  if (StringTools::endsWith(StringTools::toLowerCase(fileName), ".tm") == true) {
63  return TMReader::read(pathName, fileName, useBC7TextureCompression);
64  } else
65  if (StringTools::endsWith(StringTools::toLowerCase(fileName), ".tmodel") == true) {
66  unique_ptr<Prototype> prototype(PrototypeReader::read(pathName, fileName));
67  if (prototype != nullptr && prototype->getModel() != nullptr) {
68  auto model = prototype->unsetModel();
69  return model;
70  } else {
71  return nullptr;
72  }
73  } else {
74  throw ModelFileIOException(string("Unsupported mode file: ") + pathName + "/" + fileName);
75  }
76  } catch (Exception& exception) {
77  Console::println("ModelReader::read(): Could not load model: " + pathName + "/" + fileName + ": " + exception.what());
78  throw;
79  }
80  return nullptr;
81 }
82 
Collada DAE model reader.
Definition: DAEReader.h:39
static Model * read(const string &pathName, const string &fileName, bool useBC7TextureCompression=true)
Reads Collada DAE file.
Definition: DAEReader.cpp:96
static Model * read(const string &pathName, const string &fileName, bool useBC7TextureCompression=true)
Reads FBX file.
Definition: FBXReader.cpp:71
static Model * read(const string &pathName, const string &fileName, bool useBC7TextureCompression=true)
Reads GLTF file.
Definition: GLTFReader.cpp:85
static STATIC_DLL_IMPEXT vector< string > extensions
Definition: ModelReader.h:28
static Model * read(const string &pathName, const string &fileName, bool useBC7TextureCompression=true)
Reads a model.
Definition: ModelReader.cpp:46
static Model * read(const string &pathName, const string &fileName, bool useBC7TextureCompression=true)
TDME model format reader.
Definition: TMReader.cpp:69
Representation of a 3D model.
Definition: Model.h:35
Prototype definition.
Definition: Prototype.h:55
File system singleton class.
Definition: FileSystem.h:17
Console class.
Definition: Console.h:29
String tools class.
Definition: StringTools.h:22
std::exception Exception
Exception base class.
Definition: Exception.h:18