Guest User

Untitled

a guest
Jul 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. import ch.bildspur.postfx.builder.PostFX;
  2. import ddf.minim.AudioInput;
  3. import ddf.minim.Minim;
  4. import ddf.minim.analysis.BeatDetect;
  5. import ddf.minim.analysis.FFT;
  6.  
  7. import peasy.*;
  8. import processing.core.PApplet;
  9.  
  10. import processing.core.PVector;
  11.  
  12.  
  13. public class MainApp extends PApplet{
  14.  
  15.  
  16. PostFX fx;
  17. PeasyCam cam;
  18.  
  19. PVector[][] globe;
  20.  
  21. float xScl = 50;
  22. float yScl = 50;
  23. float xMax = 128;
  24. float yMax = 128;
  25.  
  26. public static void main(String[] args) {
  27. PApplet.main("MainApp");
  28. }
  29.  
  30. public void settings() {
  31. fullScreen(P3D);
  32. noSmooth();
  33. }
  34.  
  35. public void setup() {
  36. colorMode(HSB);
  37. fx = new PostFX(this);
  38. cam = new PeasyCam(this, 1500);
  39. }
  40.  
  41. public void draw() {
  42. background(100);
  43. xNoiseScl = (.5f);
  44. yNoiseScl = (.5f);
  45.  
  46. strokeWeight(2);
  47.  
  48. drawSea();
  49.  
  50. // noFill();
  51.  
  52. drawPlane();
  53.  
  54. fx.render().compose();
  55. }
  56.  
  57. private void drawSea() {
  58. pushMatrix();
  59. translate(0,0, -50);
  60. noStroke();
  61. // stroke(255);
  62. fill(150,150,200);
  63. quad(-xMax*xScl,
  64. -yMax*xScl,
  65. xMax*xScl ,
  66. -yMax *xScl ,
  67. xMax *xScl ,
  68. yMax *xScl ,
  69. -xMax*xScl ,
  70. yMax*xScl )
  71. ;
  72. popMatrix();
  73. }
  74.  
  75.  
  76. private void drawPlane() {
  77. pushMatrix();
  78. translate(-xMax*xScl/2,-yMax*yScl/2);
  79. for(float y = 0; y < yMax; y++){
  80. beginShape(TRIANGLE_STRIP);
  81. for(float x = 0; x < xMax; x++){
  82. float e = getElevationAt(x,y);
  83. float e1 = getElevationAt(x,y+1);
  84. float hue = map(max(e,e1), 0, 100, 40, 120);
  85. noStroke();
  86. fill(hue, 255,255);
  87. vertex(x*xScl,y*yScl, e);
  88. vertex(x*xScl,(y+1)*yScl, e1);
  89. }
  90. endShape();
  91. }
  92. popMatrix();
  93. }
  94.  
  95. float xNoiseScl;
  96. float yNoiseScl;
  97.  
  98.  
  99. private float getElevationAt(float x, float y) {
  100. return 250*(-1+2*noise(x*xNoiseScl,y*yNoiseScl, frameCount/360f));
  101. }
  102.  
  103. float mapX(float top){
  104. float result = map(mouseX, 0, width, 0, top);
  105. println("x:"+result);
  106. return result;
  107. }
  108.  
  109. float mapY(float top){
  110. float result = map(mouseY, 0, height, 0, top);
  111. println("y:"+result);
  112. return result;
  113. }
  114.  
  115. }
Add Comment
Please, Sign In to add comment