private void ParseModels(Stream stream, long bodyPartPosition, mstudiobodyparts_t bodyPart) { if (bodyPart.modelCount >= 0) { long nextModelPosition = bodyPartPosition + bodyPart.modelOffset; bodyPart.models = new mstudiomodel_t[bodyPart.modelCount]; for (int i = 0; i < bodyPart.models.Length; i++) { stream.Position = nextModelPosition; long modelPosition = nextModelPosition; bodyPart.models[i] = new mstudiomodel_t(); bodyPart.models[i].name = new char[64]; for (int j = 0; j < bodyPart.models[i].name.Length; j++) { bodyPart.models[i].name[j] = DataParser.ReadChar(stream); } bodyPart.models[i].type = DataParser.ReadInt(stream); bodyPart.models[i].boundingRadius = DataParser.ReadFloat(stream); bodyPart.models[i].meshCount = DataParser.ReadInt(stream); bodyPart.models[i].meshOffset = DataParser.ReadInt(stream); bodyPart.models[i].vertexCount = DataParser.ReadInt(stream); bodyPart.models[i].vertexOffset = DataParser.ReadInt(stream); bodyPart.models[i].tangentOffset = DataParser.ReadInt(stream); bodyPart.models[i].attachmentCount = DataParser.ReadInt(stream); bodyPart.models[i].attachmentOffset = DataParser.ReadInt(stream); bodyPart.models[i].eyeballCount = DataParser.ReadInt(stream); bodyPart.models[i].eyeballOffset = DataParser.ReadInt(stream); bodyPart.models[i].vertexData = new mstudio_modelvertexdata_t(); bodyPart.models[i].vertexData.vertexDataP = DataParser.ReadInt(stream); bodyPart.models[i].vertexData.tangentDataP = DataParser.ReadInt(stream); bodyPart.models[i].unused = new int[8]; for (int j = 0; j < bodyPart.models[i].unused.Length; j++) { bodyPart.models[i].unused[j] = DataParser.ReadInt(stream); } nextModelPosition = stream.Position; ParseEyeballs(stream, modelPosition, bodyPart.models[i]); ParseMeshes(stream, modelPosition, bodyPart.models[i]); } } }
private mstudiobodyparts_t[] ParseBodyParts(Stream stream) { if (header1.bodypart_count >= 0) { long nextBodyPartPosition = fileBeginOffset + header1.bodypart_offset; bodyParts = new mstudiobodyparts_t[header1.bodypart_count]; for (int i = 0; i < bodyParts.Length; i++) { stream.Position = nextBodyPartPosition; long bodyPartPosition = nextBodyPartPosition; bodyParts[i] = new mstudiobodyparts_t(); bodyParts[i].nameOffset = DataParser.ReadInt(stream); bodyParts[i].modelCount = DataParser.ReadInt(stream); bodyParts[i].theBase = DataParser.ReadInt(stream); bodyParts[i].modelOffset = DataParser.ReadInt(stream); nextBodyPartPosition = stream.Position; if (bodyParts[i].nameOffset != 0) { stream.Position = bodyPartPosition + bodyParts[i].nameOffset; bodyParts[i].name = DataParser.ReadNullTerminatedString(stream); } else { bodyParts[i].name = ""; } ParseModels(stream, bodyPartPosition, bodyParts[i]); } } return(bodyParts); }