Skip to content

Instantly share code, notes, and snippets.

@eskimoblood
Created October 25, 2010 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eskimoblood/645404 to your computer and use it in GitHub Desktop.
Save eskimoblood/645404 to your computer and use it in GitHub Desktop.
Simple example of using SunflowApiApi with processing in eclipse
package yourPackage;
import java.awt.Color;
import org.sunflow.math.Point3;
import org.sunflow.math.Vector3;
import processing.core.*;
import sunflowapiapi.*;
public class Box extends PApplet {
static public void main(String args[]) {
PApplet.main(new String[] { /* "--present", */"yourPackage.Box" });
}
private boolean render = false;
private P5SunflowAPIAPI sunflow ;
public void setup() {
size(500, 500, "sunflowapiapi.P5SunflowAPIAPI");
sunflow = (P5SunflowAPIAPI) g;
fill(255);
}
public void draw() {
if (render) {
sunflow.setSunSkyLight("mySunskyLight");
sunflow.setDirectionalLight("myDirectionalLight1", new Point3(0, 1, 0), new Vector3(1, 1, 0), 100, new Color(125, 125, 125));
sunflow.setAmbientOcclusionShader("myAmbientOcclusionShader", new Color(255, 125, 125), new Color(0, 0, 0), 128, 16);
}
pushMatrix();
rotateY(0.5f);
rotateX(0.5f);
box(7);
popMatrix();
if (render) {
sunflow.setPathTracingGIEngine(64);
sunflow.render("box.png");
render = false;
}
}
public void keyPressed() {
switch (key) {
case 'r':
render = true;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment