Hi all,
This is what i'm trying to do, but i can't achieve the result i need... any help?? thanks in advance..
Code:
int widthImg = 600;
int heightImg = 635;
size(1200,600, P3D);
//background(240);
//float fov = mouseX/float(width) * PI/2;
// float cameraX = width;
//float cameraZ = (height/2.0) / tan(fov / 2.0);
//perspective();
//perspective(fov, float(width)/float(height), cameraZ/10.0, cameraZ*10.0);
//ortho(-width/2, width/2, -height/2, height/2, -10, 10);
float fov = PI/3.0;
float cameraZ = (height/2.0) / tan(PI * fov / 360.0);
perspective(fov, float(width)/float(height),
cameraZ/2.0, cameraZ*2.0);
// X, Z, Y --> eye, center , etc...
//camera(0, 600, 0, 600, 0, -600, 0, 1, 0);
//rect(0,0, 100, 100);
//ortho(-width/2, width/2, -height/2, height/2, -10, 10);
//strokeWeight(1);
// griglia set-up
//line(x1,y1,z1, x2,y2,z2);
// inverted X as X / Y as -Z / Z as Y
line(0, 0+600, 0, 0, 600, -9000); // y axis
line(100, 0+600, 0, 0, 600, -9000); // y axis
line(200, 0+600, 0, 0, 600, -9000); // y axis
line(300, 0+600, 0, 0, 600, -9000); // y axis
line(400, 0+600, 0, 0, 600, -9000); // y axis
line(500, 0+600, 0, 0, 600, -9000); // y axis
line(600, 0+600, 0, 0, 600, -9000); // y axis
line(700, 0+600, 0, 0, 600, -9000); // y axis
line(800, 0+600, 0, 0, 600, -9000); // y axis
// line (X, Z, Y);
line(0, 0+600, -200, 800, 0+600, -200); // x axis
line(0, 0+600, -400, 800, 0+600, -400); // x axis
line(0, 0+600, -600, 800, 0+600, -600); // x axis
line(0, 0+600, -800, 800, 0+600, -800); // x axis
PImage img = loadImage("mestreorto.jpg");
color fillColor = color(0,255,0);
color black = color(0,0,0);
colorMode(HSB, 360, 100, 100);
img.loadPixels();
for (int i = 0; i < (widthImg*heightImg); i++){
color c = img.pixels[i];
if (hue(c) >= 35 && hue(c) <= 150 && saturation(c) > 25 && brightness(c) > 15 && brightness(c) < 95){
img.pixels[i] = fillColor;
int riga = 0;
if(i > 600){
riga = i/600;
}else{
riga = 0;
}
int colonna = 0;
if(i > 100){
colonna = i-((i/600)*600);
}else{
colonna = i;
}
//real coordinates
//translate(colonna, riga, hue(c));
float x = colonna;
float y = riga;
float z = hue(c)/2;
// point (x,z,y);
//stroke(fillColor);
//point (x, (z*-1.0)+600, (-1.0*y));
println("colonna -> " + colonna + "// hue->" + hue(c) + "// riga->" + riga );
}else{
img.pixels[i] = black;
}
}
/*
PImage a = loadImage("mestreorto.jpg");
beginShape();
texture(a);
// X, Z, Y
vertex(0, 600, 0, 0);
vertex(600, 600, 0, 0);
vertex(0, 600, 635, 635);
vertex(600, 600, 635, 635);
endShape();
*/
//img.updatePixels();
// image(img, 0, 0);