We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi..I am trying to build a mouse coupled perspective with the following sketch.It is doing well in X axis but for nearly the same settings it is totally wrong with Y axis.What is the wrong with it?
int sketch_width=600;
int sketch_height=400;
void setup() {
size(sketch_width, sketch_height, P3D);
}
void draw() {
background(100);
lights();
float near = 0.1;
float far = 1000.0;
float fov = tan( 120 *(PI / 360));
float ratio = sketch_width / sketch_height;
float mouse_X;
float mouse_Y;
float dis = -200;
mouse_X = ((mouseX/2) / 950.0 * 2.0) - 1.0;
mouse_Y = ((500.0 - (mouseY/2)) / 500.0 * 2.0) - 1.0;
mouse_X *= 0.5;
mouse_Y *= 0.25;
frustum(near*(-fov * ratio + mouse_X),
near*(fov * ratio + mouse_X),
near*(-fov + mouse_Y),
near*(fov + mouse_Y),
near, far);
camera( mouse_X * dis, mouse_Y * dis, 0, mouse_X * dis, mouse_Y * dis, -1, 0, 1, 0);
translate( 0.0, 0.0, dis);
println(mouseX);
translate(0,0,0);
box(50);
}