------------------------------------------------------------------------------------------------ Imports the given file into the given scene structure.
| 191 | // ------------------------------------------------------------------------------------------------ |
| 192 | // Imports the given file into the given scene structure. |
| 193 | void MS3DImporter::InternReadFile( const std::string& pFile, |
| 194 | aiScene* pScene, IOSystem* pIOHandler) |
| 195 | { |
| 196 | |
| 197 | auto file = pIOHandler->Open(pFile, "rb"); |
| 198 | if (!file) |
| 199 | throw DeadlyImportError("MS3D: Could not open ", pFile); |
| 200 | |
| 201 | StreamReaderLE stream(file); |
| 202 | |
| 203 | // CanRead() should have done this already |
| 204 | char head[10]; |
| 205 | int32_t version; |
| 206 | |
| 207 | mScene = pScene; |
| 208 | |
| 209 | |
| 210 | // 1 ------------ read into temporary data structures mirroring the original file |
| 211 | |
| 212 | stream.CopyAndAdvance(head,10); |
| 213 | stream >> version; |
| 214 | if (strncmp(head,"MS3D000000",10)) { |
| 215 | throw DeadlyImportError("Not a MS3D file, magic string MS3D000000 not found: ", pFile); |
| 216 | } |
| 217 | |
| 218 | if (version != 4) { |
| 219 | throw DeadlyImportError("MS3D: Unsupported file format version, 4 was expected"); |
| 220 | } |
| 221 | |
| 222 | uint16_t verts; |
| 223 | stream >> verts; |
| 224 | |
| 225 | std::vector<TempVertex> vertices(verts); |
| 226 | for (unsigned int i = 0; i < verts; ++i) { |
| 227 | TempVertex& v = vertices[i]; |
| 228 | |
| 229 | stream.IncPtr(1); |
| 230 | ReadVector(stream,v.pos); |
| 231 | v.bone_id[0] = stream.GetI1(); |
| 232 | v.ref_cnt = stream.GetI1(); |
| 233 | |
| 234 | v.bone_id[1] = v.bone_id[2] = v.bone_id[3] = UINT_MAX; |
| 235 | v.weights[1] = v.weights[2] = v.weights[3] = 0.f; |
| 236 | v.weights[0] = 1.f; |
| 237 | } |
| 238 | |
| 239 | uint16_t tris; |
| 240 | stream >> tris; |
| 241 | |
| 242 | std::vector<TempTriangle> triangles(tris); |
| 243 | for (unsigned int i = 0;i < tris; ++i) { |
| 244 | TempTriangle& t = triangles[i]; |
| 245 | |
| 246 | stream.IncPtr(2); |
| 247 | for (unsigned int j = 0; j < 3; ++j) { |
| 248 | t.indices[j] = stream.GetI2(); |
| 249 | } |
| 250 |
nothing calls this directly
no test coverage detected