public override bool parse(Stream stream, SunflowAPI api) { //string localDir = Path.GetFullPath(filename); numLightSamples = 1; Timer timer = new Timer(); timer.start(); UI.printInfo(UI.Module.API, "Parsing stream ..."); try { p = new Systems.Parser(stream); while (true) { string token = p.getNextToken(); if (token == null) break; if (token == "image") { UI.printInfo(UI.Module.API, "Reading image settings ..."); parseImageBlock(api); } else if (token == "background") { UI.printInfo(UI.Module.API, "Reading background ..."); parseBackgroundBlock(api); } else if (token == "accel") { UI.printInfo(UI.Module.API, "Reading accelerator type ..."); p.getNextToken(); UI.printWarning(UI.Module.API, "Setting accelerator type is not recommended - ignoring"); } else if (token == "filter") { UI.printInfo(UI.Module.API, "Reading image filter type ..."); parseFilter(api); } else if (token == "bucket") { UI.printInfo(UI.Module.API, "Reading bucket settings ..."); api.parameter("bucket.size", p.getNextInt()); api.parameter("bucket.order", p.getNextToken()); api.options(SunflowAPI.DEFAULT_OPTIONS); } else if (token == "photons") { UI.printInfo(UI.Module.API, "Reading photon settings ..."); parsePhotonBlock(api); } else if (token == "gi") { UI.printInfo(UI.Module.API, "Reading global illumination settings ..."); parseGIBlock(api); } else if (token == "lightserver") { UI.printInfo(UI.Module.API, "Reading light server settings ..."); parseLightserverBlock(api); } else if (token == "trace-depths") { UI.printInfo(UI.Module.API, "Reading trace depths ..."); parseTraceBlock(api); } else if (token == "camera") { parseCamera(api); } else if (token == "shader") { if (!parseShader(api)) return false; } else if (token == "modifier") { if (!parseModifier(api)) return false; } else if (token == "override") { api.shaderOverride(p.getNextToken(), p.getNextbool()); } else if (token == "object") { parseObjectBlock(api); } else if (token == "instance") { parseInstanceBlock(api); } else if (token == "light") { parseLightBlock(api); } else if (token == "texturepath") { string path = p.getNextToken(); //if (!new File(path).isAbsolute()) // path = localDir + File.separator + path; api.addTextureSearchPath(Path.GetFullPath(path)); } else if (token == "includepath") { string path = p.getNextToken(); //if (!new File(path).isAbsolute()) // path = localDir + File.separator + path; api.addIncludeSearchPath(Path.GetFullPath(path)); } else if (token == "include") { string file = p.getNextToken(); UI.printInfo(UI.Module.API, "Including: \"{0}\" ...", file); api.parse(file); } else UI.printWarning(UI.Module.API, "Unrecognized token {0}", token); } p.close(); } catch (Exception e) { UI.printError(UI.Module.API, "{0}", e); return false; } timer.end(); UI.printInfo(UI.Module.API, "Done parsing."); UI.printInfo(UI.Module.API, "Parsing time: {0}", timer.ToString()); return true; }