Search in sources :

Example 1 with VisibleSceneElement

use of org.jwildfire.create.eden.scene.VisibleSceneElement 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

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 SunflowExporter (org.jwildfire.create.eden.export.SunflowExporter)1 Scene (org.jwildfire.create.eden.scene.Scene)1 VisibleSceneElement (org.jwildfire.create.eden.scene.VisibleSceneElement)1