hey, antiplastic! as I am quite new to processing (just about a month) i could not really understand all the arrays and mapping stuff. sorry could not follow your advice there.. =] though i came up with the idea to use red(), green(), blue() values of the color in the buffer and use them as translate(x,y,z). works really great. (I imagine that this is somehow the long way of arrays and hashmap). I understand that this is a very limited method as there are only 255 possible values for each axis, but for now it works for me.
thanks for all the help, it was your suggestion initially that set me on this approach. I am sure I'll need more help further down the project somewhere, but for now the code is like this:
import processing.opengl.*;
PGraphics bf;
float expo = 1;
float rotx, roty;
float rate = 0.01;
void mouseDragged()
{
rotx = rotx + (mouseY - pmouseY) * rate;
roty = roty + (mouseX - pmouseX) * rate;
}
void setup()
{
size(700,400,OPENGL);
bf = createGraphics(width,height,P3D);
stroke(150);
}
void draw()
{
background(255);
if (keyPressed && keyCode==UP)
{
expo = expo + 0.01;
}
if (keyPressed && keyCode==DOWN)
{
expo = expo - 0.01;
}
translate(350,200,0);
rotateX(rotx);
rotateY(roty);
scale(expo);
translate(-350,-350,-350);
for (int x = 150; x<=550; x+=100)
{
for (int y = 150; y<=550; y+=100)
{
for (int z = 150; z<=550; z+=100)
{
line(150,y,z,x,y,z);
line(x,150,z,x,y,z);
line(x,y,150,x,y,z);
pushMatrix();
color c1 = bf.get(mouseX,mouseY);
color c2 = color(0);
if (c1 > c2)
{
translate(red(c1)*10,green(c1)*10,blue(c1)*10);
fill(0);
box(10);
}
popMatrix();
}
}
}
bf.beginDraw();
bf.background(255);
bf.translate(350,200,0);
bf.rotateX(rotx);
bf.rotateY(roty);
bf.scale(expo);
bf.translate(-350,-350,-350);
for (int x = 150; x<=550; x+=100)
{
for (int y = 150; y<=550; y+=100)
{
for (int z = 150; z<=550; z+=100)
{
bf.line(150,y,z,x,y,z);
bf.line(x,150,z,x,y,z);
bf.line(x,y,150,x,y,z);
bf.pushMatrix();
bf.translate(x,y,z);
bf.noStroke();
bf.fill(x/10,y/10,z/10);
bf.box(10);
bf.popMatrix();
}
}
}
}
thanks again, antiplastic!