MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / parseModel

Function parseModel

TheForceEngine/TFE_Asset/modelAsset_jedi.cpp:364–914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362 }
363
364 bool parseModel(JediModel* model, const char* name, AssetPool pool)
365 {
366 if (s_buffer.empty()) { return false; }
367 const size_t len = s_buffer.size();
368
369 model->isBridge = 0;
370 model->vertexCount = 0;
371 model->vertices = nullptr;
372 model->polygonCount = 0;
373 model->polygons = nullptr;
374 model->vertexNormals = nullptr;
375 model->polygonNormals = nullptr;
376 model->flags = 0;
377 model->textureCount = 0;
378 model->textures = nullptr;
379 model->radius = 0;
380 model->drawId = nullptr; // invalid ID initially.
381
382 // Check to see if the name has an underscore.
383 // If so, set the "isBridge" field.
384 const size_t nameLen = strlen(name);
385 for (size_t i = 0; i < nameLen; i++)
386 {
387 if (name[i] == '_')
388 {
389 model->isBridge = 1;
390 break;
391 }
392 }
393
394 TFE_Parser parser;
395 size_t bufferPos = 0;
396 parser.init(s_buffer.data(), len);
397 const char* fileBuffer = s_buffer.data();
398 parser.addCommentString("#");
399
400 // For now just do what the original code does.
401 // TODO: Make this more robust.
402 const char* buffer = parser.readLine(bufferPos, true);
403 if (!buffer) { return false; }
404
405 f32 version;
406 if (sscanf(buffer, "3DO %f", &version) != 1)
407 {
408 TFE_System::logWrite(LOG_ERROR, "Object3D_Load", "'%s' has no valid name.", name);
409 assert(0);
410 return false;
411 }
412 if (version < 1.2f)
413 {
414 TFE_System::logWrite(LOG_ERROR, "Object3D_Load", "'%s' has inavlid version", name);
415 assert(0);
416 return false;
417 }
418
419 buffer = parser.readLine(bufferPos, true);
420 if (!buffer) { return false; }
421 char name3do[32];

Callers 1

getFunction · 0.85

Calls 15

logWriteFunction · 0.85
ignore3doLimitsFunction · 0.85
bitmap_getAllocatorFunction · 0.85
bitmap_setAllocatorFunction · 0.85
bitmap_loadFunction · 0.85
floatToFixed16Function · 0.85
allocatePolygonFunction · 0.85
getGraphicsSettingsFunction · 0.85
maxFunction · 0.85
intToFixed16Function · 0.85
mul16Function · 0.85
dataMethod · 0.80

Tested by

no test coverage detected