Exemple #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;
            }));
        }
Exemple #2
0
        internal static W3dCollectionObjName Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var nameCount = header.ChunkSize / W3dConstants.NameLength;
                var result = new W3dCollectionObjName {
                };

                result.Names = new string[nameCount];
                for (int i = 0; i < nameCount; i++)
                {
                    result.Names[i] = reader.ReadFixedLengthString(W3dConstants.NameLength);
                }

                return result;
            }));
        }