Movig the point of view (not the grid)

edited January 2015 in Questions about Code

I have a code which is constantly drawing some wireframes in the middle of the screen. Now I am trying to slowly move the camera so that middle of the screen where wireframes are drawn to be on the top of the screen. Like moving the camera on the real time where object stay in the same place. But I didn't found a solution yet, because every time the grid is moving and wireframes are being drawn in different places. I have tried using translate(), camera() and OCD Library, but without success. Any idea would be very helpful. Here is my code

`

import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;

Minim minim;
AudioPlayer song;

float h = 0;

float centerX,centerY;
float initRadius = 150;
int formResolution = 1023;
int stepSize = 2;

float[] x = new float[formResolution];
float[] y = new float[formResolution];

void setup(){
size(displayWidth, displayHeight, P3D);
smooth();

minim = new Minim(this);

song = minim.loadFile("Ilir.mp3");
song.play();

centerX = width/2;
centerY = height/2;

float radius = initRadius*random(0.5,5.0);
float angle = random(PI);
radius = initRadius*4;
angle = 0;

float x1 = cos(angle) * radius;
float y1 = sin(angle) * radius;
float x2 = cos(angle-PI) * radius;
float y2 = sin(angle-PI) * radius;
for(int i=0; i<formResolution; i++) {
x[i] = lerp(x1, x2, i/(float)formResolution);
y[i] = lerp(y1, y2, i/(float)formResolution);
}
stroke(0, 50);
background(255);
}
void draw(){
for(int i=0; i<formResolution; i++){
x[i] += song.left.get(i)*50;
y[i] += song.left.get(i)*50;
}
noFill();
// this is the block diagram that need to be fixed
if(millis() > 2000 && h<300){
translate(0, -300,0); //-it should be like this in the end
//translate(0, -h, 0);but camera need to move slowly
//camera(width/2.0, height, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height, 0, 0, 1, 0); or by using the camea
//h+=10;
}
beginShape();
curveVertex(x[0]+centerX, y[0]+centerY);
for(int i=0; i<formResolution; i++){
curveVertex(x[i]+centerX, y[i]+centerY);
}
curveVertex(x[formResolution-1]+centerX, y[formResolution-1]+centerY);
endShape();
}

`

Comments

Sign In or Register to comment.