Making 3D walls visible

I have a 3d box bouncing sim, with a camera around the mouse. anyways i want to make the walls different colors so u can tell its 3d, heres my code.

float x;
float y;
int xa;
int xb;
int xdirection = 1;
int ydirection = 1;
int textsize;
float rad=50;
PImage img;
float rotate;
int z;
int d;
int rect;
void setup() {
rad=rad-0.5;
x=random(-12, 12);
y=random(-12, 12);

size(700, 600, P3D);
xa=500;
frameRate (60);
fill(255,0,0);

}

void draw() {
fill(255,0,0);
rect(-700,-600.0,700.0,600.0);

camera(mouseX, mouseY, 700, 200, 300, 350,
-1, -1, -1);

x=x+xdirection;
y=y+ydirection;
if (x> width-rad) {

xdirection=xdirection+-1;

}
if (y>height-rad) {
ydirection=ydirection±1;
}
if (y < 0) {
ydirection=ydirection+1;
}
if (x < 0) {
xdirection=xdirection+1;
}
background(200);
rotateX(PI/5);
fill(0, 0, 255);
translate(x, y, z);
sphere(50);

rotate=rotate +1;
}

Well for starters, the rectangle you declared at the beginning isn’t visible because the console is reading the lines in order, meaning it will first display a rectangle, then display the background (erasing the whole canvas and coloring it 200,200,200), then display the sphere. You want to display the background before displaying anything else :slight_smile:

As for getting each wall to be a different color, this can easily be achieved by just running a fill command before displaying each wall, with the color in the fill() corresponding to the color of aforementioned wall.

Finally, and this is more of a precaution than anything, looking into it, the rectangle function seems to be a bit…inconsistent in P3D mode. While I’ll admit I’m not that experienced with the 3D feature of processing, the camera doesn’t seem to quite work right when drawing rectangles. If you find yourself unable to fix the problems that arise from using rect(), I recommend using the box command as a substitute, and having one of the box’s 3 dimensions being either 0 or some very small number.

thanks ill give it a try when i get the chance!

After background please try using lights (); because looks better