void ModelNode_KotOR::load(Model_KotOR::ParserContext &ctx) { uint16 flags = ctx.mdl->readUint16LE(); uint16 superNode = ctx.mdl->readUint16LE(); uint16 nodeNumber = ctx.mdl->readUint16LE(); if (nodeNumber < ctx.names.size()) _name = ctx.names[nodeNumber]; ctx.mdl->skip(6 + 4); // Unknown + parent pointer _position [0] = ctx.mdl->readIEEEFloatLE(); _position [1] = ctx.mdl->readIEEEFloatLE(); _position [2] = ctx.mdl->readIEEEFloatLE(); _orientation[3] = Common::rad2deg(acos(ctx.mdl->readIEEEFloatLE()) * 2.0); _orientation[0] = ctx.mdl->readIEEEFloatLE(); _orientation[1] = ctx.mdl->readIEEEFloatLE(); _orientation[2] = ctx.mdl->readIEEEFloatLE(); uint32 childrenOffset, childrenCount; Model::readArrayDef(*ctx.mdl, childrenOffset, childrenCount); std::vector<uint32> children; Model::readArray(*ctx.mdl, ctx.offModelData + childrenOffset, childrenCount, children); uint32 controllerKeyOffset, controllerKeyCount; Model::readArrayDef(*ctx.mdl, controllerKeyOffset, controllerKeyCount); uint32 controllerDataOffset, controllerDataCount; Model::readArrayDef(*ctx.mdl, controllerDataOffset, controllerDataCount); std::vector<float> controllerData; Model::readArray(*ctx.mdl, ctx.offModelData + controllerDataOffset, controllerDataCount, controllerData); readNodeControllers(ctx, ctx.offModelData + controllerKeyOffset, controllerKeyCount, controllerData); if ((flags & 0xFC00) != 0) throw Common::Exception("Unknown node flags %04X", flags); if (flags & kNodeFlagHasLight) { // TODO: Light ctx.mdl->skip(0x5C); } if (flags & kNodeFlagHasEmitter) { // TODO: Emitter ctx.mdl->skip(0xD8); } if (flags & kNodeFlagHasReference) { // TODO: Reference ctx.mdl->skip(0x44); } if (flags & kNodeFlagHasMesh) { readMesh(ctx); } if (flags & kNodeFlagHasSkin) { // TODO: Skin ctx.mdl->skip(0x64); } if (flags & kNodeFlagHasAnim) { // TODO: Anim ctx.mdl->skip(0x38); } if (flags & kNodeFlagHasDangly) { // TODO: Dangly ctx.mdl->skip(0x18); } if (flags & kNodeFlagHasAABB) { // TODO: AABB ctx.mdl->skip(0x4); } for (std::vector<uint32>::const_iterator child = children.begin(); child != children.end(); ++child) { ModelNode_KotOR *childNode = new ModelNode_KotOR(*_model); ctx.nodes.push_back(childNode); childNode->setParent(this); ctx.mdl->seek(ctx.offModelData + *child); childNode->load(ctx); } }
void ModelNode_Witcher::load(Model_Witcher::ParserContext &ctx) { ctx.mdb->skip(24); // Function pointers uint32 inheritColor = ctx.mdb->readUint32LE(); uint32 nodeNumber = ctx.mdb->readUint32LE(); _name = Common::readStringFixed(*ctx.mdb, Common::kEncodingASCII, 64); ctx.mdb->skip(8); // Parent pointers uint32 childrenOffset, childrenCount; Model::readArrayDef(*ctx.mdb, childrenOffset, childrenCount); std::vector<uint32> children; Model::readArray(*ctx.mdb, ctx.offModelData + childrenOffset, childrenCount, children); uint32 controllerKeyOffset, controllerKeyCount; Model::readArrayDef(*ctx.mdb, controllerKeyOffset, controllerKeyCount); uint32 controllerDataOffset, controllerDataCount; Model::readArrayDef(*ctx.mdb, controllerDataOffset, controllerDataCount); std::vector<float> controllerData; Model::readArray(*ctx.mdb, ctx.offModelData + controllerDataOffset, controllerDataCount, controllerData); readNodeControllers(ctx, ctx.offModelData + controllerKeyOffset, controllerKeyCount, controllerData); ctx.mdb->skip(4); // Unknown uint32 imposterGroup = ctx.mdb->readUint32LE(); uint32 fixedRot = ctx.mdb->readUint32LE(); int32 minLOD = ctx.mdb->readUint32LE(); int32 maxLOD = ctx.mdb->readUint32LE(); NodeType type = (NodeType) ctx.mdb->readUint32LE(); switch (type) { case kNodeTypeTrimesh: readMesh(ctx); break; case kNodeTypeTexturePaint: readTexturePaint(ctx); break; default: break; } // Only render the highest LOD (0), or if the node is not LODing (-1) if ((minLOD != -1) && (maxLOD != -1) && (minLOD > 0)) _render = false; for (std::vector<uint32>::const_iterator child = children.begin(); child != children.end(); ++child) { ModelNode_Witcher *childNode = new ModelNode_Witcher(*_model); ctx.nodes.push_back(childNode); childNode->setParent(this); ctx.mdb->seek(ctx.offModelData + *child); childNode->load(ctx); } }
void ModelNode_Witcher::load(Model_Witcher::ParserContext &ctx) { ctx.mdb->skip(24); uint32 inheritColor = ctx.mdb->readUint32LE(); uint32 nodeNumber = ctx.mdb->readUint32LE(); _name.readFixedASCII(*ctx.mdb, 64); ctx.mdb->skip(8); // Parent pointers uint32 childrenOffset, childrenCount; Model::readArrayDef(*ctx.mdb, childrenOffset, childrenCount); std::vector<uint32> children; Model::readArray(*ctx.mdb, ctx.offModelData + childrenOffset, childrenCount, children); uint32 controllerKeyOffset, controllerKeyCount; Model::readArrayDef(*ctx.mdb, controllerKeyOffset, controllerKeyCount); uint32 controllerDataOffset, controllerDataCount; Model::readArrayDef(*ctx.mdb, controllerDataOffset, controllerDataCount); std::vector<float> controllerData; Model::readArray(*ctx.mdb, ctx.offModelData + controllerDataOffset, controllerDataCount, controllerData); readNodeControllers(ctx, ctx.offModelData + controllerKeyOffset, controllerKeyCount, controllerData); ctx.mdb->skip(20); uint32 flags = ctx.mdb->readUint32LE(); if ((flags & 0xFFFC0000) != 0) throw Common::Exception("Unknown node flags %08X", flags); if (flags & kNodeFlagHasLight) { // TODO: Light } if (flags & kNodeFlagHasEmitter) { // TODO: Emitter } if (flags & kNodeFlagHasReference) { // TODO: Reference } if (flags & kNodeFlagHasMesh) { readMesh(ctx); } if (flags & kNodeFlagHasSkin) { // TODO: Skin } if (flags & kNodeFlagHasAnim) { // TODO: Anim } if (flags & kNodeFlagHasDangly) { // TODO: Dangly } if (flags & kNodeFlagHasAABB) { // TODO: AABB } for (std::vector<uint32>::const_iterator child = children.begin(); child != children.end(); ++child) { ModelNode_Witcher *childNode = new ModelNode_Witcher(*_model); ctx.nodes.push_back(childNode); childNode->setParent(this); ctx.mdb->seek(ctx.offModelData + *child); childNode->load(ctx); } }