MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / LoadModel

Method LoadModel

neo/renderer/Model_md5.cpp:506–589  ·  view source on GitHub ↗

==================== idRenderModelMD5::LoadModel used for initial loads, reloadModel, and reloading the data of purged models Upon exit, the model will absolutely be valid, but possibly as a default model ==================== */

Source from the content-addressed store, hash-verified

504====================
505*/
506void idRenderModelMD5::LoadModel() {
507 int version;
508 int i;
509 int num;
510 int parentNum;
511 idToken token;
512 idLexer parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS );
513 idJointQuat *pose;
514 idMD5Joint *joint;
515 idJointMat *poseMat3;
516
517 if ( !purged ) {
518 PurgeModel();
519 }
520 purged = false;
521
522 if ( !parser.LoadFile( name ) ) {
523 MakeDefaultModel();
524 return;
525 }
526
527 parser.ExpectTokenString( MD5_VERSION_STRING );
528 version = parser.ParseInt();
529
530 if ( version != MD5_VERSION ) {
531 parser.Error( "Invalid version %d. Should be version %d\n", version, MD5_VERSION );
532 }
533
534 //
535 // skip commandline
536 //
537 parser.ExpectTokenString( "commandline" );
538 parser.ReadToken( &token );
539
540 // parse num joints
541 parser.ExpectTokenString( "numJoints" );
542 num = parser.ParseInt();
543 joints.SetGranularity( 1 );
544 joints.SetNum( num );
545 defaultPose.SetGranularity( 1 );
546 defaultPose.SetNum( num );
547 poseMat3 = ( idJointMat * )_alloca16( num * sizeof( *poseMat3 ) );
548
549 // parse num meshes
550 parser.ExpectTokenString( "numMeshes" );
551 num = parser.ParseInt();
552 if ( num < 0 ) {
553 parser.Error( "Invalid size: %d", num );
554 }
555 meshes.SetGranularity( 1 );
556 meshes.SetNum( num );
557
558 //
559 // parse joints
560 //
561 parser.ExpectTokenString( "joints" );
562 parser.ExpectTokenString( "{" );
563 pose = defaultPose.Ptr();

Callers

nothing calls this directly

Calls 15

SetTranslationMethod · 0.80
ParseMeshMethod · 0.80
ReadFileMethod · 0.80
TransposeMethod · 0.60
LoadFileMethod · 0.45
ExpectTokenStringMethod · 0.45
ParseIntMethod · 0.45
ErrorMethod · 0.45
ReadTokenMethod · 0.45
SetGranularityMethod · 0.45
SetNumMethod · 0.45
PtrMethod · 0.45

Tested by

no test coverage detected