I want to make dynamic visualization where I need to use cube made of as many as possible smaller cubes with controlled color and opacity.
It will be somekind of voxel cloud.
I’m new to Processing but I have some knowladge about graphics.
As first steps to my goal I trying to make cubes manually.
I use beginShape(QUADS); and fill() to make transparent cube, but I found what opacity works not as I expect.
I see what opacity is like works only in one direction, and not transparent at all in another direction.
How to fix that?
there is my sketch
float a;
int c = 200 + 255*255+ 120*256*256 ;
boolean toggle = true;
void setup() {
size(640, 640, P3D);
textMode(MODEL);
//noStroke();
//fill(255,000,00,100);
}
void randfill()
{
int x = int(random(255));
int y = int(random(255));
int z = int(random(255));
fill(x,y,z,40);
}
void draw() {
background(190);
//lights();
translate(width/2, height/2, 0);
rotateX(-PI/8+a/17);
rotateY(PI/6+a/23);
rotateZ(PI/9);
stroke(0);
fill(0);
text(" 1 1 1", 100, 100, 100);
text("-1 1 1",-100, 100, 100);
text("-1 -1 1",-100,-100, 100);
text("-1 -1 -1",-100,-100,-100);
text("-1 1 -1",-100, 100,-100);
text(" 1 -1 -1", 100,-100,-100);
text(" 1 1 -1", 100, 100,-100);
if (toggle){
a += 0.05;
}
if(mousePressed){
toggle = !toggle;
}
beginShape(QUADS);
randfill();
vertex(100,100,100);
vertex(-100,100,100);
vertex(-100,100,-100);
vertex(100,100,-100);
randfill();
vertex(100,-100,-100);
vertex(100,100,-100);
vertex(100,100,100);
vertex(100,-100,100);
randfill();
vertex(-100,-100,100);
vertex(-100,100,100);
vertex(100,100,100);
vertex(100,-100,100);
randfill();
vertex(-100,-100,100);
vertex(-100,-100,-100);
vertex(-100,100,-100);
vertex(-100,100,100);
randfill();
vertex(-100,-100,100);
vertex(100,-100,100);
vertex(100,-100,-100);
vertex(-100,-100,-100);
randfill();
vertex(-100,-100,-100);
vertex(-100,100,-100);
vertex(100,100,-100);
vertex(100,-100,-100);
fill(0,250);
vertex(100,200,100);
vertex(-100,200,100);
vertex(-100,200,-100);
vertex(100,200,-100);
vertex(200,-100,-100);
vertex(200,100,-100);
vertex(200,100,100);
vertex(200,-100,100);
vertex(-100,-100,200);
vertex(-100,100,200);
vertex(100,100,200);
vertex(100,-100,200);
vertex(-200,-100,100);
vertex(-200,-100,-100);
vertex(-200,100,-100);
vertex(-200,100,100);
vertex(-100,-200,100);
vertex(100,-200,100);
vertex(100,-200,-100);
vertex(-100,-200,-100);
vertex(-100,-100,-200);
vertex(-100,100,-200);
vertex(100,100,-200);
vertex(100,-100,-200);
endShape();
text(" 1 1 1", 100, 100, 100);
text("-1 1 1",-100, 100, 100);
text("-1 -1 1",-100,-100, 100);
text("-1 -1 -1",-100,-100,-100);
text("-1 1 -1",-100, 100,-100);
text(" 1 -1 -1", 100,-100,-100);
text(" 1 1 -1", 100, 100,-100);
//box(160);
}