public ModelData Load() { using (Log.Instance.EnterStage("Loading model from DFF file: " + modelName)) { // К сожалению, в GTA III есть dff-файлы размера 0 if (input.BaseStream.Length > 0) { SectionHeader header = new SectionHeader(); header.Read(input); ProcessRenderwareSection(header.SectionSize, 0, header.SectionType); ProcessFrames(); } input.Close(); return(modelData); } }
private void ProcessRenderwareSection(int size, int depthLevel, SectionType parentType) // depthLevel нужен для отладки, если мы вдруг захочется вывести структуру файла { int sectionEnd = (int)input.BaseStream.Position + size; while (input.BaseStream.Position < sectionEnd) { SectionHeader header = new SectionHeader(); header.Read(input); switch (header.SectionType) { case SectionType.Extension: case SectionType.Texture: case SectionType.Material: case SectionType.MaterialList: case SectionType.FrameList: case SectionType.Geometry: case SectionType.Clump: case SectionType.Atomic: case SectionType.GeometryList: ProcessRenderwareSection(header.SectionSize, depthLevel + 1, header.SectionType); break; case SectionType.MaterialSplit: ParseMaterialSplit(header.SectionSize); break; case SectionType.Frame: ParseFrame(header.SectionSize); break; case SectionType.Data: ParseDataSection(header.SectionSize, parentType, header.Version); break; case SectionType.String: ParseStringSection(header.SectionSize, parentType); break; default: input.BaseStream.Seek(header.SectionSize, SeekOrigin.Current); break; } } }
// depthLevel нужен для отладки, если мы вдруг захочется вывести структуру файла private void ProcessRenderwareSection(int size, int depthLevel, SectionType parentType) { int sectionEnd = (int)input.BaseStream.Position + size; while (input.BaseStream.Position < sectionEnd) { SectionHeader header = new SectionHeader(); header.Read(input); switch(header.SectionType) { case SectionType.Extension: case SectionType.Texture: case SectionType.Material: case SectionType.MaterialList: case SectionType.FrameList: case SectionType.Geometry: case SectionType.Clump: case SectionType.Atomic: case SectionType.GeometryList: ProcessRenderwareSection(header.SectionSize, depthLevel + 1, header.SectionType); break; case SectionType.MaterialSplit: ParseMaterialSplit(header.SectionSize); break; case SectionType.Frame: ParseFrame(header.SectionSize); break; case SectionType.Data: ParseDataSection(header.SectionSize, parentType, header.Version); break; case SectionType.String: ParseStringSection(header.SectionSize, parentType); break; default: input.BaseStream.Seek(header.SectionSize, SeekOrigin.Current); break; } } }
public ModelData Load() { using (Log.Instance.EnterStage("Loading model from DFF file: " + modelName)) { // К сожалению, в GTA III есть dff-файлы размера 0 if (input.BaseStream.Length > 0) { SectionHeader header = new SectionHeader(); header.Read(input); ProcessRenderwareSection(header.SectionSize, 0, header.SectionType); ProcessFrames(); } input.Close(); return modelData; } }