MCPcopy Create free account
hub / github.com/assimp/assimp / InternReadFile

Method InternReadFile

code/AssetLib/Unreal/UnrealLoader.cpp:199–513  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Imports the given file into the given scene structure.

Source from the content-addressed store, hash-verified

197// ------------------------------------------------------------------------------------------------
198// Imports the given file into the given scene structure.
199void UnrealImporter::InternReadFile(const std::string &pFile,
200 aiScene *pScene, IOSystem *pIOHandler) {
201 // For any of the 3 files being passed get the three correct paths
202 // First of all, determine file extension
203 std::string::size_type pos = pFile.find_last_of('.');
204 std::string extension = GetExtension(pFile);
205
206 std::string d_path, a_path, uc_path;
207 if (extension == "3d") {
208 // jjjj_d.3d
209 // jjjj_a.3d
210 pos = pFile.find_last_of('_');
211 if (std::string::npos == pos) {
212 throw DeadlyImportError("UNREAL: Unexpected naming scheme");
213 }
214 extension = pFile.substr(0, pos);
215 } else {
216 extension = pFile.substr(0, pos);
217 }
218
219 // build proper paths
220 d_path = extension + "_d.3d";
221 a_path = extension + "_a.3d";
222 uc_path = extension + ".uc";
223
224 ASSIMP_LOG_DEBUG("UNREAL: data file is ", d_path);
225 ASSIMP_LOG_DEBUG("UNREAL: aniv file is ", a_path);
226 ASSIMP_LOG_DEBUG("UNREAL: uc file is ", uc_path);
227
228 // and open the files ... we can't live without them
229 std::unique_ptr<IOStream> p(pIOHandler->Open(d_path));
230 if (!p)
231 throw DeadlyImportError("UNREAL: Unable to open _d file");
232 StreamReaderLE d_reader(pIOHandler->Open(d_path));
233
234 const uint16_t numTris = d_reader.GetI2();
235 const uint16_t numVert = d_reader.GetI2();
236 d_reader.IncPtr(44);
237 if (!numTris || numVert < 3) {
238 throw DeadlyImportError("UNREAL: Invalid number of vertices/triangles");
239 }
240
241 // maximum texture index
242 unsigned int maxTexIdx = 0;
243
244 // collect triangles
245 std::vector<Unreal::Triangle> triangles(numTris);
246 for (auto &tri : triangles) {
247 for (unsigned int i = 0; i < 3; ++i) {
248 tri.mVertex[i] = d_reader.GetI2();
249 if (tri.mVertex[i] >= numTris) {
250 ASSIMP_LOG_WARN("UNREAL: vertex index out of range");
251 tri.mVertex[i] = 0;
252 }
253 }
254 tri.mType = d_reader.GetI1();
255
256 // handle mesh flagss?

Callers

nothing calls this directly

Calls 15

DeadlyImportErrorFunction · 0.85
DecompressVertexFunction · 0.85
TokenMatchIFunction · 0.85
IsLineEndFunction · 0.85
ASSIMP_strincmpFunction · 0.85
IsSpaceOrNewLineFunction · 0.85
strtoul10Function · 0.85
fast_atoreal_moveFunction · 0.85
findFunction · 0.85
ai_snprintfFunction · 0.85
aiVector3DClass · 0.85
GetI2Method · 0.80

Tested by

no test coverage detected