Created
October 25, 2010 18:05
-
-
Save eskimoblood/645404 to your computer and use it in GitHub Desktop.
Simple example of using SunflowApiApi with processing in eclipse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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