Esempio n. 1
0
        public static W3dMeshAabTree Parse(BinaryReader reader, uint chunkSize)
        {
            return(ParseChunk <W3dMeshAabTree>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_AABTREE_HEADER:
                    result.Header = W3dMeshAabTreeHeader.Parse(reader);
                    break;

                case W3dChunkType.W3D_CHUNK_AABTREE_POLYINDICES:
                    result.PolygonIndices = new uint[result.Header.PolyCount];
                    for (var i = 0; i < result.Header.PolyCount; i++)
                    {
                        result.PolygonIndices[i] = reader.ReadUInt32();
                    }
                    break;

                case W3dChunkType.W3D_CHUNK_AABTREE_NODES:
                    result.Nodes = new W3dMeshAabTreeNode[result.Header.NodeCount];
                    for (var i = 0; i < result.Header.NodeCount; i++)
                    {
                        result.Nodes[i] = W3dMeshAabTreeNode.Parse(reader);
                    }
                    break;

                default:
                    throw CreateUnknownChunkException(header);
                }
            }));
        }
Esempio n. 2
0
        internal static W3dMeshAabTree Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk <W3dMeshAabTree>(reader, context, header =>
            {
                var result = new W3dMeshAabTree();
                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_AABTREE_HEADER:
                        result.Header = W3dMeshAabTreeHeader.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_AABTREE_POLYINDICES:
                        result.PolygonIndices = W3dMeshAabTreePolyIndices.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_AABTREE_NODES:
                        result.Nodes = W3dMeshAabTreeNodes.Parse(reader, context);
                        break;

                    default:
                        throw CreateUnknownChunkException(chunkType);
                    }
                });
                return result;
            }));
        }
        public static W3dMeshAabTreeHeader Parse(BinaryReader reader)
        {
            var result = new W3dMeshAabTreeHeader
            {
                NodeCount = reader.ReadUInt32(),
                PolyCount = reader.ReadUInt32()
            };

            reader.ReadBytes(6 * sizeof(uint)); // Padding

            return(result);
        }
Esempio n. 4
0
        internal static W3dMeshAabTreeHeader Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dMeshAabTreeHeader
                {
                    NodeCount = reader.ReadUInt32(),
                    PolyCount = reader.ReadUInt32()
                };

                reader.ReadBytes(6 * sizeof(uint)); // Padding

                return result;
            }));
        }