------------------------------------------------------------------------------------------------ Imports the given file into the given scene structure.
| 104 | // ------------------------------------------------------------------------------------------------ |
| 105 | // Imports the given file into the given scene structure. |
| 106 | void IRRMeshImporter::InternReadFile(const std::string &pFile, |
| 107 | aiScene *pScene, IOSystem *pIOHandler) { |
| 108 | std::unique_ptr<IOStream> file(pIOHandler->Open(pFile)); |
| 109 | |
| 110 | // Check whether we can read from the file |
| 111 | if (file == nullptr) { |
| 112 | throw DeadlyImportError("Failed to open IRRMESH file ", pFile); |
| 113 | } |
| 114 | |
| 115 | // Construct the irrXML parser |
| 116 | XmlParser parser; |
| 117 | if (!parser.parse(file.get())) { |
| 118 | throw DeadlyImportError("XML parse error while loading IRRMESH file ", pFile); |
| 119 | } |
| 120 | XmlNode root = parser.getRootNode(); |
| 121 | |
| 122 | // final data |
| 123 | std::vector<aiMaterial *> materials; |
| 124 | std::vector<aiMesh *> meshes; |
| 125 | materials.reserve(5); |
| 126 | meshes.reserve(5); |
| 127 | |
| 128 | // temporary data - current mesh buffer |
| 129 | // TODO move all these to inside loop |
| 130 | aiMaterial *curMat = nullptr; |
| 131 | aiMesh *curMesh = nullptr; |
| 132 | unsigned int curMatFlags = 0; |
| 133 | |
| 134 | std::vector<aiVector3D> curVertices, curNormals, curTangents, curBitangents; |
| 135 | std::vector<aiColor4D> curColors; |
| 136 | std::vector<aiVector3D> curUVs, curUV2s; |
| 137 | |
| 138 | // some temporary variables |
| 139 | // textMeaning is a 15 year old variable, that could've been an enum |
| 140 | // int textMeaning = 0; // 0=none? 1=vertices 2=indices |
| 141 | // int vertexFormat = 0; // 0 = normal; 1 = 2 tcoords, 2 = tangents |
| 142 | bool useColors = false; |
| 143 | |
| 144 | // irrmesh files have a top level <mesh> owning multiple <buffer> nodes. |
| 145 | // Each <buffer> contains <material>, <vertices>, and <indices> |
| 146 | // <material> tags here directly owns the material data specs |
| 147 | // <vertices> are a vertex per line, contains position, UV1 coords, maybe UV2, normal, tangent, bitangent |
| 148 | // <boundingbox> is ignored, I think assimp recalculates those? |
| 149 | |
| 150 | // Parse the XML file |
| 151 | pugi::xml_node const &meshNode = root.child("mesh"); |
| 152 | for (pugi::xml_node bufferNode : meshNode.children()) { |
| 153 | if (ASSIMP_stricmp(bufferNode.name(), "buffer")) { |
| 154 | // Might be a useless warning |
| 155 | ASSIMP_LOG_WARN("IRRMESH: Ignoring non buffer node <", bufferNode.name(), "> in mesh declaration"); |
| 156 | continue; |
| 157 | } |
| 158 | |
| 159 | curMat = nullptr; |
| 160 | curMesh = nullptr; |
| 161 | |
| 162 | curVertices.clear(); |
| 163 | curColors.clear(); |
nothing calls this directly
no test coverage detected