use of org.sunflow.image.ColorFactory.ColorSpecificationException in project joons-renderer by joonhyublee.
the class SCParser method parse.
@Override
public boolean parse(String filename, SunflowAPIInterface api) {
String localDir = new File(filename).getAbsoluteFile().getParentFile().getAbsolutePath();
numLightSamples = 1;
Timer timer = new Timer();
timer.start();
UI.printInfo(Module.API, "Parsing \"%s\" ...", filename);
try {
p = new Parser(filename);
while (true) {
String token = p.getNextToken();
if (token == null) {
break;
}
if (token.equals("image")) {
UI.printInfo(Module.API, "Reading image settings ...");
parseImageBlock(api);
} else if (token.equals(BACKGROUND)) {
UI.printInfo(Module.API, "Reading background ...");
parseBackgroundBlock(api);
} else if (token.equals("accel")) {
UI.printInfo(Module.API, "Reading accelerator type ...");
p.getNextToken();
UI.printWarning(Module.API, "Setting accelerator type is not recommended - ignoring");
} else if (token.equals(FILTER)) {
UI.printInfo(Module.API, "Reading image filter type ...");
parseFilter(api);
} else if (token.equals("bucket")) {
UI.printInfo(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.equals("photons")) {
UI.printInfo(Module.API, "Reading photon settings ...");
parsePhotonBlock(api);
} else if (token.equals("gi")) {
UI.printInfo(Module.API, "Reading global illumination settings ...");
parseGIBlock(api);
} else if (token.equals("lightserver")) {
UI.printInfo(Module.API, "Reading light server settings ...");
parseLightserverBlock(api);
} else if (token.equals("trace-depths")) {
UI.printInfo(Module.API, "Reading trace depths ...");
parseTraceBlock(api);
} else if (token.equals("camera")) {
parseCamera(api);
} else if (token.equals(SHADER)) {
if (!parseShader(api)) {
return false;
}
} else if (token.equals(MODIFIER)) {
if (!parseModifier(api)) {
return false;
}
} else if (token.equals("override")) {
api.parameter("override.shader", p.getNextToken());
api.parameter("override.photons", p.getNextBoolean());
api.options(SunflowAPI.DEFAULT_OPTIONS);
} else if (token.equals("object")) {
parseObjectBlock(api);
} else if (token.equals("instance")) {
parseInstanceBlock(api);
} else if (token.equals("light")) {
parseLightBlock(api);
} else if (token.equals("texturepath")) {
String path = p.getNextToken();
if (!new File(path).isAbsolute()) {
path = localDir + File.separator + path;
}
api.searchpath(TEXTURE, path);
} else if (token.equals("includepath")) {
String path = p.getNextToken();
if (!new File(path).isAbsolute()) {
path = localDir + File.separator + path;
}
api.searchpath("include", path);
} else if (token.equals("include")) {
String file = p.getNextToken();
UI.printInfo(Module.API, "Including: \"%s\" ...", file);
api.include(file);
} else {
UI.printWarning(Module.API, "Unrecognized token %s", token);
}
}
p.close();
} catch (ParserException e) {
UI.printError(Module.API, "%s", e.getMessage());
Logger.getLogger(SCParser.class.getName()).log(Level.SEVERE, null, e);
return false;
} catch (FileNotFoundException e) {
UI.printError(Module.API, "%s", e.getMessage());
return false;
} catch (IOException e) {
UI.printError(Module.API, "%s", e.getMessage());
return false;
} catch (ColorSpecificationException e) {
UI.printError(Module.API, "%s", e.getMessage());
return false;
}
timer.end();
UI.printInfo(Module.API, "Done parsing.");
UI.printInfo(Module.API, "Parsing time: %s", timer.toString());
return true;
}
Aggregations