//sunflow libraries //import hipstersinc.sunflow.*; //import hipstersinc.sunflow.shader.*; //import hipstersinc.*; //dxf import processing.dxf.*; //opengl import processing.opengl.*; //set up xyz arrays float [] x=new float[100]; float [] y=new float[100]; float [] z=new float[100]; //set record to false boolean record=false; //create output object for writing to txt //PrintWriter output; void setup(){ // size(300,300,"hipstersinc.P5Sunflow"); // requires lights to be off //size(300,300,P3D); size(300,300,OPENGL); //set txt output file name //output=createWriter("xyzpoints.txt"); } void draw(){ //if(record) beginRaw(DXF,"test-####.dxf"); background(0); //lights must be turned off for sunflow render lights(); //camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ) camera(mouseX*2,mouseY*2,300,width/2,height/2,0,0,1,0); //fill x y z arrays with positions for (int i=1; i<100; i++){ for(int j=1; j<100; j++){ //spacing of 4 pixels int spacing=4; x[i]=i*spacing; y[j]=j*spacing; //z is based on sin to create a wave of amplitude 25 and frequency of 6 z[j]=sin(TWO_PI*j/100*6)*25; //if we're recording, save x y z to txt file //if(record)output.println(x[i]+","+y[j]+","+z[j]); } } //draw quads fill(100); noStroke(); for (int i=1; i<100-1; i++){ for(int j=1; j<100-1; j++){ fill(255); beginShape(QUADS); vertex(x[i],y[j],z[j]); vertex(x[i+1],y[j],z[j]); vertex(x[i+1],y[j+1],z[j+1]); vertex(x[i],y[j+1],z[j+1]); endShape(); } } //if we're recording, save dxf, save txt file, and exit if(record){ endRaw(); record=false; //output.flush(); //output.close(); exit(); } } void keyPressed(){ if(key=='r')record=true; }