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;
}
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;
}
}
Aggregations