MCPcopy Create free account
hub / github.com/XJTU-Graphics/dandelion / InternReadFile

Method InternReadFile

deps/assimp/code/AssetLib/MS3D/MS3DLoader.cpp:197–650  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

DeadlyImportErrorFunction · 0.85
ReadVectorFunction · 0.85
inrangeFunction · 0.85
aiColor4DClass · 0.85
aiVector3DClass · 0.85
aiQuaternionClass · 0.85
aiMatrix3x3Class · 0.85
aiMatrix4x4Class · 0.85
CopyAndAdvanceMethod · 0.80
IncPtrMethod · 0.80
GetI1Method · 0.80
GetI2Method · 0.80

Tested by

no test coverage detected