internal static W3dShaderMaterial Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dShaderMaterial();

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

                    case W3dChunkType.W3D_CHUNK_SHADER_MATERIAL_PROPERTY:
                        result.Properties.Add(W3dShaderMaterialProperty.Parse(reader, context));
                        break;

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

                return result;
            }));
        }
        public static W3dShaderMaterials Parse(BinaryReader reader, uint chunkSize)
        {
            var normalMaps = new List <W3dShaderMaterial>();

            var finalResult = ParseChunk <W3dShaderMaterials>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_SHADER_MATERIAL:
                    normalMaps.Add(W3dShaderMaterial.Parse(reader, header.ChunkSize));
                    break;

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

            finalResult.Materials = normalMaps;

            return(finalResult);
        }