Advertisement
Guest User

Untitled

a guest
Nov 27th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. import processing.opengl.*;
  3. import java.awt.Color;
  4. import sunflowapiapi.P5SunflowAPIAPI;
  5. import org.sunflow.math.Point3;
  6. import org.sunflow.math.Vector3;
  7.  
  8. PFont font;
  9.  
  10. ArrayList cubes;
  11. int maxCubes = 10; // Max num of cubes
  12. boolean rendered = false;
  13. P5SunflowAPIAPI sunflow;
  14.  
  15. void setup() {
  16. size(600, 600, "sunflowapiapi.P5SunflowAPIAPI");
  17. sunflow = (P5SunflowAPIAPI) g;
  18. smooth();
  19.  
  20. //Load font for debug Info
  21. font = loadFont("LucidaGrande-12.vlw");
  22. textFont(font);
  23.  
  24.  
  25. //Create ArrayList of Cubes
  26. cubes = new ArrayList();
  27. for (int i = 0; i < maxCubes; i++) {
  28. cubes.add(new cube(int(random(100, 200)), int(random(100, 200)), 200));
  29. }
  30.  
  31. }
  32. void draw() {
  33. background(90);
  34. for (int i = cubes.size() - 1; i >= 0; i--) {
  35. cube Cube = (cube) cubes.get(i);
  36. Cube.run();
  37. }
  38. info();
  39. if(rendered){
  40. noLoop();
  41. }
  42. }
  43.  
  44. //Debug Info
  45. void info() {
  46. text("Frame", 10, 20);
  47. text(frameCount, 60, 20);
  48. text("FPS", 10, 40);
  49. text(round(frameRate), 60, 40);
  50. }
  51.  
  52. void keyPressed(){
  53. sunflow.setSunSkyLight("mySunskyLight");
  54. sunflow.setDirectionalLight("myDirectionalLight1", new Point3(0, 1, 0), new Vector3(1, 1, 0), 100, new Color(125, 125, 125));
  55. sunflow.setDiffuseShader();
  56. sunflow.setInstantGIEngine(16, 1, 1.0, 1);
  57. sunflow.render();
  58. rendered = true;
  59. }
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement