P3D Object creation...
in
Programming Questions
•
4 months ago
Hello,
I'm a problem, I want to create 3D object when condition are true.
The problem is that when this condition is fulfilled the object disappears.
I try but I can not find a solution.
Here's the code:
float rx;
float ry;
int a=0;
void setup(){
size(300,300,P3D);
}
void draw(){
background(204);
translate(width/2,height/2,0);
if (mousePressed && (mouseButton == LEFT)) {
rotateX(rx);
rotateY(ry);
rx =map (mouseX, 150,width,-PI,PI);
ry =map (mouseY, 150,height,-PI,PI);
//print(rx);
//print(ry);
}else{ }
rotateX(rx);
rotateY(ry);
if(a == 0){
pushMatrix();
box(30);
popMatrix();
a=1;
}
}
This code shows that the condition is true, but once the cube is not existing.
1