Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ch.bildspur.postfx.builder.PostFX;
- import ddf.minim.AudioInput;
- import ddf.minim.Minim;
- import ddf.minim.analysis.BeatDetect;
- import ddf.minim.analysis.FFT;
- import peasy.*;
- import processing.core.PApplet;
- import processing.core.PVector;
- public class MainApp extends PApplet{
- PostFX fx;
- PeasyCam cam;
- PVector[][] globe;
- float xScl = 50;
- float yScl = 50;
- float xMax = 128;
- float yMax = 128;
- public static void main(String[] args) {
- PApplet.main("MainApp");
- }
- public void settings() {
- fullScreen(P3D);
- noSmooth();
- }
- public void setup() {
- colorMode(HSB);
- fx = new PostFX(this);
- cam = new PeasyCam(this, 1500);
- }
- public void draw() {
- background(100);
- xNoiseScl = (.5f);
- yNoiseScl = (.5f);
- strokeWeight(2);
- drawSea();
- // noFill();
- drawPlane();
- fx.render().compose();
- }
- private void drawSea() {
- pushMatrix();
- translate(0,0, -50);
- noStroke();
- // stroke(255);
- fill(150,150,200);
- quad(-xMax*xScl,
- -yMax*xScl,
- xMax*xScl ,
- -yMax *xScl ,
- xMax *xScl ,
- yMax *xScl ,
- -xMax*xScl ,
- yMax*xScl )
- ;
- popMatrix();
- }
- private void drawPlane() {
- pushMatrix();
- translate(-xMax*xScl/2,-yMax*yScl/2);
- for(float y = 0; y < yMax; y++){
- beginShape(TRIANGLE_STRIP);
- for(float x = 0; x < xMax; x++){
- float e = getElevationAt(x,y);
- float e1 = getElevationAt(x,y+1);
- float hue = map(max(e,e1), 0, 100, 40, 120);
- noStroke();
- fill(hue, 255,255);
- vertex(x*xScl,y*yScl, e);
- vertex(x*xScl,(y+1)*yScl, e1);
- }
- endShape();
- }
- popMatrix();
- }
- float xNoiseScl;
- float yNoiseScl;
- private float getElevationAt(float x, float y) {
- return 250*(-1+2*noise(x*xNoiseScl,y*yNoiseScl, frameCount/360f));
- }
- float mapX(float top){
- float result = map(mouseX, 0, width, 0, top);
- println("x:"+result);
- return result;
- }
- float mapY(float top){
- float result = map(mouseY, 0, height, 0, top);
- println("y:"+result);
- return result;
- }
- }
Add Comment
Please, Sign In to add comment