Example #1
0
        public static BRDF parseBRDF(InputStream inputFile, Scene scene)
        {
            BRDF        result;
            KeywordEnum key = inputFile.expectKeywords(new List <KeywordEnum>()
            {
                KeywordEnum.Diffuse, KeywordEnum.Specular
            });

            inputFile.expectSymbol("(");
            IPigment pigment = parsePigment(inputFile, scene);

            inputFile.expectSymbol(")");


            if (key == KeywordEnum.Diffuse)
            {
                result = new DiffuseBRDF(pigment);
            }
            else if (key == KeywordEnum.Specular)
            {
                result = new SpecularBRDF(pigment);
            }
            else
            {
                throw new GrammarError(inputFile.location, "This line should be unreachable");
            }


            return(result);
        }
Example #2
0
        public static Tuple <string, Material> parseMaterial(InputStream inputFile, Scene scene)
        {
            string name = inputFile.expectIdentifier();

            inputFile.expectSymbol("(");
            BRDF brdf = parseBRDF(inputFile, scene);

            inputFile.expectSymbol(",");
            IPigment emRad = parsePigment(inputFile, scene);

            inputFile.expectSymbol(")");

            return(new Tuple <string, Material>(name, new Material(brdf, emRad)));
        }
Example #3
0
 public Material(BRDF? Brdf = null, IPigment? EmittedRadiance = null)
 {
     this.brdf = Brdf ?? new DiffuseBRDF();
     this.emittedRadiance = EmittedRadiance ?? new UniformPigment(Constant.Black);
 }
Example #4
0
 public BRDF(IPigment? pig = null)
 {
     this.pigment = pig ?? new UniformPigment(Constant.White);
 }