Esempio n. 1
0
        public static W3dHierarchyDef Parse(BinaryReader reader, uint chunkSize)
        {
            return(ParseChunk <W3dHierarchyDef>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_HIERARCHY_HEADER:
                    result.Header = W3dHierarchy.Parse(reader);
                    result.Pivots = new W3dPivot[result.Header.NumPivots];
                    break;

                case W3dChunkType.W3D_CHUNK_PIVOTS:
                    for (var count = 0; count < result.Header.NumPivots; count++)
                    {
                        result.Pivots[count] = W3dPivot.Parse(reader);
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_PIVOT_FIXUPS:
                    // We don't need this chunk; it's only relevant to the exporter, apparently.
                    reader.ReadBytes((int)header.ChunkSize);
                    break;

                default:
                    throw CreateUnknownChunkException(header);
                }
            }));
        }
Esempio n. 2
0
        internal static W3dHierarchyDef Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dHierarchyDef();

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

                    case W3dChunkType.W3D_CHUNK_PIVOTS:
                        result.Pivots = W3dPivots.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PIVOT_FIXUPS:
                        result.PivotFixups = W3dPivotFixups.Parse(reader, context);
                        break;

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

                return result;
            }));
        }