Beispiel #1
0
        internal static W3dHLod Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dHLod();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_HLOD_HEADER:
                        result.Header = W3dHLodHeader.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_HLOD_LOD_ARRAY:
                        result.Lods.Add(W3dHLodArray.Parse(reader, context));
                        break;

                    case W3dChunkType.W3D_CHUNK_HLOD_AGGREGATE_ARRAY:
                        result.Aggregate = W3dHLodAggregateArray.Parse(reader, context);
                        break;

                    default:
                        throw CreateUnknownChunkException(chunkType);
                    }
                });

                return result;
            }));
        }
Beispiel #2
0
        public static W3dHLod Parse(BinaryReader reader, uint chunkSize)
        {
            var lods = new List <W3dHLodArray>();

            var finalResult = ParseChunk <W3dHLod>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_HLOD_HEADER:
                    result.Header = W3dHLodHeader.Parse(reader);
                    result.Lods   = new W3dHLodArray[result.Header.LodCount];
                    break;

                case W3dChunkType.W3D_CHUNK_HLOD_LOD_ARRAY:
                    lods.Add(W3dHLodArray.Parse(reader, header.ChunkSize));
                    break;

                case W3dChunkType.W3D_CHUNK_HLOD_AGGREGATE_ARRAY:
                    if (result.Aggregate != null)
                    {
                        throw new InvalidDataException();
                    }
                    result.Aggregate = W3dHLodArray.Parse(reader, header.ChunkSize);
                    break;

                default:
                    throw CreateUnknownChunkException(header);
                }
            });

            finalResult.Lods = lods;

            return(finalResult);
        }