예제 #1
0
        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;
            }));
        }
예제 #2
0
        public static W3dShaderMaterial Parse(BinaryReader reader, uint chunkSize)
        {
            var properties = new List <W3dShaderMaterialProperty>();

            var finalResult = ParseChunk <W3dShaderMaterial>(reader, chunkSize, (result, header) =>
            {
                switch (header.ChunkType)
                {
                case W3dChunkType.W3D_CHUNK_SHADER_MATERIAL_HEADER:
                    result.Header = W3dShaderMaterialHeader.Parse(reader, header.ChunkSize);
                    break;

                case W3dChunkType.W3D_CHUNK_SHADER_MATERIAL_PROPERTY:
                    properties.Add(W3dShaderMaterialProperty.Parse(reader, header.ChunkSize));
                    break;

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

            finalResult.Properties = properties;

            return(finalResult);
        }