how to pan the view of a 3D scene?
in
Programming Questions
•
11 months ago
I read the following from "Processing a Programming Handbook":
What I wan to do is: pan the view of a 3D scene when the mouse is pressed and dragged and the degree of rotation of the 3D scene depends on the distance of the mouse dragging, e.g. press the mouse and drag it from left to right to rotate a box along the y axis, or do the same up and down to rotate the box along x axis...
Can anybody give an advise on this?
Thanks in advance!
- void setup() {
size(400, 400, P3D);
fill(204);
}
void draw() {
background(0);
translate(width/2, height/2, -width);
rotateY(map(mouseX, 0, width, -PI, PI));
rotateX(map(mouseY, 0, height, -PI, PI));
noStroke();
rect(-200, -200, 400, 400);
stroke(255);
line(0, 0, -200, 0, 0, 200);
}
What I wan to do is: pan the view of a 3D scene when the mouse is pressed and dragged and the degree of rotation of the 3D scene depends on the distance of the mouse dragging, e.g. press the mouse and drag it from left to right to rotate a box along the y axis, or do the same up and down to rotate the box along x axis...
Can anybody give an advise on this?
Thanks in advance!
1