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

Method InternReadFile

code/AssetLib/Irr/IRRLoader.cpp:1204–1349  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1202// ------------------------------------------------------------------------------------------------
1203// Imports the given file into the given scene structure.
1204void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
1205 std::unique_ptr<IOStream> file(pIOHandler->Open(pFile));
1206 // Check whether we can read from the file
1207 if (file == nullptr) {
1208 throw DeadlyImportError("Failed to open IRR file ", pFile);
1209 }
1210
1211 // Construct the irrXML parser
1212 XmlParser st;
1213 if (!st.parse(file.get())) {
1214 throw DeadlyImportError("XML parse error while loading IRR file ", pFile);
1215 }
1216 pugi::xml_node documentRoot = st.getRootNode();
1217
1218 // The root node of the scene
1219 Node *root = new Node(Node::DUMMY);
1220 root->parent = nullptr;
1221 root->name = "<IRRSceneRoot>";
1222
1223 // Batch loader used to load external models
1224 BatchLoader batch(pIOHandler);
1225 // batch.SetBasePath(pFile);
1226
1227 cameras.reserve(1); // Probably only one camera in entire scene
1228 lights.reserve(5);
1229
1230 this->guessedAnimCnt = 0;
1231 this->guessedMeshCnt = 0;
1232 this->guessedMatCnt = 0;
1233
1234 // Parse the XML
1235 // Find the scene root from document root.
1236 const pugi::xml_node &sceneRoot = documentRoot.child("irr_scene");
1237 if (!sceneRoot) {
1238 delete root;
1239 throw new DeadlyImportError("IRR: <irr_scene> not found in file");
1240 }
1241 for (pugi::xml_node &child : sceneRoot.children()) {
1242 // XML elements are either nodes, animators, attributes, or materials
1243 if (!ASSIMP_stricmp(child.name(), "node")) {
1244 // Recursive collect subtree children
1245 Node *nd = ParseNode(child, batch);
1246 // Attach to root
1247 root->children.push_back(nd);
1248 }
1249 }
1250
1251 // Now iterate through all cameras and compute their final (horizontal) FOV
1252 for (aiCamera *cam : cameras) {
1253 // screen aspect could be missing
1254 if (cam->mAspect) {
1255 cam->mHorizontalFOV *= cam->mAspect;
1256 } else {
1257 ASSIMP_LOG_WARN("IRR: Camera aspect is not given, can't compute horizontal FOV");
1258 }
1259 }
1260
1261 batch.LoadAll();

Callers

nothing calls this directly

Calls 15

DeadlyImportErrorFunction · 0.85
ASSIMP_stricmpFunction · 0.85
getRootNodeMethod · 0.80
childMethod · 0.80
childrenMethod · 0.80
LoadAllMethod · 0.80
OpenMethod · 0.45
parseMethod · 0.45
getMethod · 0.45
reserveMethod · 0.45
nameMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected