Creating Shadows
in
Programming Questions
•
2 years ago
I am trying to cast a shadow of the line onto the 2 axes that are shown in the following program code, not sure if its possible.
Also, is it possible that after running the code, to change the position of the line without going back to the source code?
Thanks a million!
void setup ()
{
size(600, 500, P3D);
smooth();
frameRate(30);
}
void draw() {
//ortho();
lights();
background(#D6D6D6);
camera(400, -400, 400, // eyeX, eyeY, eyeZ
0, 0, 0.0, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ
float dirY = (mouseY / float(height) - 0.5) * 2;
float dirX = (mouseX / float(width) - 0.5) * 2;
directionalLight(204, 204, 204, -dirX, -dirY, -1);
// Draw the axes
noStroke();
pushMatrix();
translate(300/2,0,0);
box(350, 0, 350);
popMatrix();
pushMatrix();
translate(0,-300/2,0);
box(0, 350, 350);
popMatrix();
// Draw a line
stroke(#000000);
strokeWeight(1);
line(340,-140,240,40,-250,-300);
noStroke();
pushMatrix();
translate(40, -250, -300);
sphere(5);
popMatrix();
pushMatrix();
translate(340, -140, 240);
sphere(5);
popMatrix();
}
1