We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Crossposted: http://stackoverflow.com/questions/28066391/point-of-view-movement-in-processing
Yes I have posted the same question in both forums but I haven not gotten any response :S
It's considered common courtesy to link between crossposts, that way we don't waste time repeating advice you've already heard.
Also you should make sure your code is formatted properly, that way it's easier for us to read. Similarly, you should post an MCVE, eliminating any code that does not directly relate to your problem.