Search in sources :

Example 1 with SunflowExporter

use of org.jwildfire.create.eden.export.SunflowExporter in project JWildfire by thargor6.

the class FilterKernelVisualisation3dRenderer method createSunflowRenderer.

private SunflowAPI createSunflowRenderer(Scene scene) throws IOException, Exception {
    String sceneTxt = new SunflowExporter().exportScene(scene);
    String filename = createTmpFilename();
    Tools.writeUTF8Textfile(filename, sceneTxt);
    String template = "import org.sunflow.core.*;\nimport org.sunflow.core.accel.*;\nimport org.sunflow.core.camera.*;\nimport org.sunflow.core.primitive.*;\nimport org.sunflow.core.shader.*;\nimport org.sunflow.image.Color;\nimport org.sunflow.math.*;\n\npublic void build() {\n  include(\"" + filename.replace("\\", "\\\\") + "\");\n}\n";
    SunflowAPI api = SunflowAPI.compile(template);
    api.build();
    api.parameter("sampler", "ipr");
    api.parameter("accel", "kdtree");
    api.options(SunflowAPI.DEFAULT_OPTIONS);
    return api;
}
Also used : SunflowAPI(org.sunflow.SunflowAPI) SunflowExporter(org.jwildfire.create.eden.export.SunflowExporter)

Example 2 with SunflowExporter

use of org.jwildfire.create.eden.export.SunflowExporter in project JWildfire by thargor6.

the class EDENController method edenCreateSurfaceScene.

private String edenCreateSurfaceScene() {
    try {
        Scene scene = new Scene();
        scene.addPointLight(0, 0, -200, 0.6);
        scene.addPointLight(-100, 20, -160, 0.8);
        scene.addPointLight(-10, 200, -60, 0.5);
        int width = 800;
        int height = 600;
        double surfWidth = width / 25.0;
        double surfHeight = height / 25.0;
        double surfDepth = MathLib.sqrt(surfWidth * surfWidth + surfHeight * surfHeight) / 100.0;
        List<Creator> creators = new ArrayList<Creator>();
        // creators.add(new SphereCreator(scene));
        creators.add(new BoxCreator(scene));
        List<Transformer> transformers = new ArrayList<Transformer>();
        transformers.add(new Transformer1(scene));
        transformers.add(new Transformer2(scene));
        for (Creator creator : creators) {
            creator.create();
        }
        Map<Transformer, Set<VisibleSceneElement>> expandedMap = new HashMap<Transformer, Set<VisibleSceneElement>>();
        for (int i = 0; i < 7; i++) {
            for (Transformer transformer : transformers) {
                Set<VisibleSceneElement> expandedSet = expandedMap.get(transformer);
                if (expandedSet == null) {
                    expandedSet = new HashSet<VisibleSceneElement>();
                    expandedMap.put(transformer, expandedSet);
                }
                List<VisibleSceneElement> elements = scene.getAllVisibleElements();
                for (VisibleSceneElement element : elements) {
                    if (!expandedSet.contains(element)) {
                        VisibleSceneElement copy = element.clone();
                        transformer.transform(copy);
                        expandedSet.add(element);
                    }
                }
            }
        }
        System.out.println("ELEMENTS: " + scene.getAllVisibleElements().size());
        return new SunflowExporter().exportScene(scene);
    } catch (Exception ex) {
        Unchecker.rethrow(ex);
        return null;
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Scene(org.jwildfire.create.eden.scene.Scene) IOException(java.io.IOException) VisibleSceneElement(org.jwildfire.create.eden.scene.VisibleSceneElement) SunflowExporter(org.jwildfire.create.eden.export.SunflowExporter)

Aggregations

SunflowExporter (org.jwildfire.create.eden.export.SunflowExporter)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Scene (org.jwildfire.create.eden.scene.Scene)1 VisibleSceneElement (org.jwildfire.create.eden.scene.VisibleSceneElement)1 SunflowAPI (org.sunflow.SunflowAPI)1