It's really just a matter of specifying the right renderer in the size() function call:
size(400, 400, P3D).
Here's some code that plots 2d shapes in projective 3D space.
I used Processing's built-in rect() call as well as a simple custom poly function.
Code:
void setup(){
size(400, 400, P3D);
framerate(30);
noStroke();
}
void draw(){
background(50);
translate(width/2, height/2);
//built-in
fill(0, 0, 255, 50);
rotateY(frameCount*PI/150);
rect(-150, -150, 300, 300);
// custom poly calls
rotateX(frameCount*PI/120);
makePoly(5, 150, color(255, 255, 0, 100));
rotateY(frameCount*PI/110);
makePoly(3, 100, color(0, 255, 255, 100));
rotateX(frameCount*PI/130);
makePoly(8, 45, color(255, 0, 255, 100));
rotateY(frameCount*PI/50);
makePoly(12, 25, color(255, 255, 255, 100));
}
//custom poly
void makePoly(int pts, float radius, color c){
float angle = 0;
float x=0, y=0;
fill(c);
beginShape();
for (int i=0; i<pts; i++){
x = cos(radians(angle))*radius;
y = sin(radians(angle))*radius;
vertex(x, y);
angle+=360/pts;
}
endShape();
}