Hi, I am a new coder on processing. Normally, my code is 1000 lines.However, I prepared for you a simple code that I can modify on my code. The project last date is very soon. So, please be poilte and gentle. The code which I prepared only for you here:
void setup()
{
size(1200, 800, P3D);
camZ = (height/2) / tan((PI*60.0)/360.0);
noStroke();
}
float camZ = 0;
void draw()
{
background(0);
camera(0, 0.0, camZ, //default camera position
0, 0, -500, //where it is looking to
0, 1, 0); //eye openness
rotateX(rotX + distY);
rotateY(rotY + distX);
scale(100);
drawHouse();
if(keyPressed)
{
if(key == 'w')
camZ -= 5;
else if(key == 's')
camZ += 5;
}
}
void drawHouse()
{
beginShape(QUADS);
fill(255,0,0);
//+Z face
vertex(-1, -1, 1); //upper left corner
vertex(1, -1, 1); //upper right corner
vertex(1, 1, 1); //bottom right corner
vertex(-1, 1, 1); //bottom left corner
fill(0,255,0);
//-Z face
vertex(-1, -1, -1); //upper left corner
vertex(1, -1, -1); //upper right corner
vertex(1, 1, -1); //bottom right corner
vertex(-1, 1, -1); //bottom left corner
fill(0,0,255);
//+X face
vertex(1, -1, 1); //upper left corner
vertex(1, -1, -1);
vertex(1, 1, -1);
vertex(1, 1, 1);
fill(255);
//-X face
vertex(-1, -1, 1); //upper left corner
vertex(-1, -1, -1);
vertex(-1, 1, -1);
vertex(-1, 1, 1);
fill(208,13,211);
//-Y face
vertex(-1, -1, 1);
vertex(1, -1, 1);
vertex(1, -1, -1);
vertex(-1, -1, -1);
fill(250,150,18);
//+Y face
vertex(-1, 1, 1);
vertex(1, 1, 1);
vertex(1, 1, -1);
vertex(-1, 1, -1);
endShape();
}
float rotX = 0, rotY = 0;
float lastX, lastY;
float distX, distY;
void mousePressed()
{
lastX = mouseX;
lastY = mouseY;
}
void mouseDragged()
{
distX = radians(mouseX - lastX);
distY = radians(lastY - mouseY);
}
void mouseReleased()
{
rotX += distY;
rotY += distX;
distX = distY = 0;
}
So, I want to make a light inside the box which was given in the code. The light should effect only inside the box. How to make that happened?