Ejemplo n.º 1
0
        internal static W3dCollection Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dCollection();

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

                    case W3dChunkType.W3D_CHUNK_COLLECTION_OBJ_NAME:
                        result.ObjName = W3dCollectionObjName.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_PLACEHOLDER:
                        result.Placeholder = W3dCollectionPlaceholder.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_TRANSFORM_NODE:
                        result.TransformNode = W3dCollectionTransformNode.Parse(reader, context);
                        break;

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

                return result;
            }));
        }
Ejemplo n.º 2
0
        internal static W3dCollectionHeader Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dCollectionHeader
                {
                    Version = reader.ReadUInt32()
                };

                result.Name = reader.ReadFixedLengthString((int)context.CurrentEndPosition - (int)reader.BaseStream.Position - 4);
                result.RenderObjectCount = reader.ReadUInt32();

                return result;
            }));
        }