void Model_Witcher::load(ParserContext &ctx) { if (ctx.mdb->readByte() != 0) { ctx.mdb->seek(0); Common::UString type; type.readASCII(*ctx.mdb); if (type.beginsWith("binarycompositemodel")) throw Common::Exception("TODO: binarycompositemodel"); throw Common::Exception("Not a The Witcher MDB file"); } ctx.mdb->seek(4); ctx.fileVersion = ctx.mdb->readUint16LE(); ctx.mdb->skip(10); ctx.modelDataSize = ctx.mdb->readUint32LE(); ctx.mdb->skip(4); ctx.offModelData = 32; if (ctx.fileVersion == 133) { ctx.offRawData = ctx.mdb->readUint32LE() + ctx.offModelData; ctx.rawDataSize = ctx.mdb->readUint32LE(); ctx.offTexData = ctx.offModelData; ctx.texDatasize = 0; } else { ctx.offRawData = ctx.offModelData; ctx.rawDataSize = 0; ctx.offTexData = ctx.mdb->readUint32LE() + ctx.offModelData; ctx.texDatasize = ctx.mdb->readUint32LE(); } ctx.mdb->skip(8); _name.readFixedASCII(*ctx.mdb, 64); uint32 offsetRootNode = ctx.mdb->readUint32LE(); ctx.mdb->skip(32); byte type = ctx.mdb->readByte(); ctx.mdb->skip(3); ctx.mdb->skip(48); float firstLOD = ctx.mdb->readIEEEFloatLE(); float lastLOD = ctx.mdb->readIEEEFloatLE(); ctx.mdb->skip(16); Common::UString detailMap; detailMap.readFixedASCII(*ctx.mdb, 64); ctx.mdb->skip(4); float scale = ctx.mdb->readIEEEFloatLE(); Common::UString superModel; superModel.readFixedASCII(*ctx.mdb, 64); ctx.mdb->skip(16); newState(ctx); ModelNode_Witcher *rootNode = new ModelNode_Witcher(*this); ctx.nodes.push_back(rootNode); ctx.mdb->seek(ctx.offModelData + offsetRootNode); rootNode->load(ctx); addState(ctx); }