stop movment by mouse click
in
Programming Questions
•
1 year ago
Hi
How could I by left mouse button stp moving
and by right mouse buttonmove the image again in the following code:
and by right mouse buttonmove the image again in the following code:
- import processing.opengl.*;
float theta = 0;
float dTheta = TWO_PI/360;
float radius = 200;
//Lights, Camera, Action
void setup()
{
size(800,600,OPENGL);
noStroke();
camera(width/2, height/2, width, width/2, height/2, 0,0, -1, 0);
lights();
fill(255);
}
void draw()
{
background(255);
float x,z;
x = radius*cos(theta);
z = radius*sin(theta);
directionalLight(255, 255, 255, 0,0, -1);
pushMatrix();
translate(width/2+x, height/2, z);
sphere(50);
popMatrix();
pushMatrix();
translate(width/2-x, height/2, -z);
sphere(50);
popMatrix();
pushMatrix();
x= radius*cos(theta+PI/2);
z= radius*sin(theta+PI/2);
translate(width/2, height/2+x, -z);
sphere(50);
popMatrix();
pushMatrix();
// translate(width/2, height/2+x, z);
translate(width/2, height/2-x, z);
sphere(100);
popMatrix();
theta = (theta + dTheta)% TWO_PI;
}
1