Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void OnMouse(int button, int state, int x, int y)
- {
- // this method gets called whenever a new mouse button event happens
- if(button == Glut.GLUT_RIGHT_BUTTON) mouseDown = (state == Glut.GLUT_DOWN);
- // if the mouse has just been clicked then we hide the cursor and store the position
- if(mouseDown)
- {
- Glut.glutSetCursor(Glut.GLUT_CURSOR_NONE);
- downX = x;
- downY = y;
- ty = 0;
- tp = 0;
- }
- else // unhide the cursor if the mouse has just been released
- { Glut.glutSetCursor(Glut.GLUT_CURSOR_LEFT_ARROW); }
- }
- public static float ty = 0,tp = 0;
- private static void OnMove(int x, int y)
- {
- // if the mouse move event is caused by glutWarpPointer then do nothing
- //if((x == downX && y == downY) || Math.Pow((downX - x), 2) + Math.Pow((downY - y), 2) < 16) return;
- if(x == downX && y == downY)return;
- // move the camera when the mouse is down
- if(mouseDown)
- {
- float yaw = (downX - x) * 0.002f;
- ty += yaw;
- camera.Yaw(yaw);
- float pitch = (downY - y) * 0.002f;
- tp += pitch;
- camera.Pitch(pitch);
- Glut.glutWarpPointer(downX, downY);
- Console.Clear();
- Console.WriteLine(ty.ToString() + " " + tp.ToString() + " " + downX.ToString() + " " + downY.ToString() + " " + x.ToString() + " " + y.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement