Index: src/org/sunflow/image/Color.java =================================================================== --- src/org/sunflow/image/Color.java (revision 212) +++ src/org/sunflow/image/Color.java (working copy) @@ -1,8 +1,10 @@ package org.sunflow.image; +import java.io.Serializable; + import org.sunflow.math.MathUtils; -public final class Color { +public final class Color implements Serializable { private float r, g, b; public static final Color BLACK = new Color(0, 0, 0); public static final Color WHITE = new Color(1, 1, 1); Index: src/org/sunflow/SunflowAPI.java =================================================================== --- src/org/sunflow/SunflowAPI.java (revision 212) +++ src/org/sunflow/SunflowAPI.java (working copy) @@ -658,6 +658,49 @@ } /** + * Render using the specified options, sampler and the specified display. If the + * specified options do not exist - defaults will be used. + * + * @param optionsName name of the {@link RenderObject} which contains the + * options + * @param display display object + */ + public final void render(String optionsName, ImageSampler sampler, Display display) { + renderObjects.updateScene(scene); + Options opt = lookupOptions(optionsName); + if (opt == null) + opt = new Options(); + scene.setCamera(lookupCamera(opt.getString("camera", null))); + + // shader override + String shaderOverrideName = opt.getString("override.shader", "none"); + boolean overridePhotons = opt.getBoolean("override.photons", false); + + if (shaderOverrideName.equals("none")) + scene.setShaderOverride(null, false); + else { + Shader shader = lookupShader(shaderOverrideName); + if (shader == null) + UI.printWarning(Module.API, "Unable to find shader \"%s\" for override, disabling", shaderOverrideName); + scene.setShaderOverride(shader, overridePhotons); + } + + // baking + String bakingInstanceName = opt.getString("baking.instance", null); + if (bakingInstanceName != null) { + Instance bakingInstance = lookupInstance(bakingInstanceName); + if (bakingInstance == null) { + UI.printError(Module.API, "Unable to bake instance \"%s\" - not found", bakingInstanceName); + return; + } + scene.setBakingInstance(bakingInstance); + } else + scene.setBakingInstance(null); + + scene.render(opt, sampler, display); + } + + /** * Parse the specified filename. The include paths are searched first. The * contents of the file are simply added to the active scene. This allows to * break up a scene into parts, even across file formats. The appropriate