Advertisement
Guest User

Untitled

a guest
Jun 24th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. private static void OnMouse(int button, int state, int x, int y)
  2.         {
  3.             // this method gets called whenever a new mouse button event happens
  4.             if(button == Glut.GLUT_RIGHT_BUTTON) mouseDown = (state == Glut.GLUT_DOWN);
  5.  
  6.             // if the mouse has just been clicked then we hide the cursor and store the position
  7.             if(mouseDown)
  8.             {
  9.                 Glut.glutSetCursor(Glut.GLUT_CURSOR_NONE);
  10.                 downX = x;
  11.                 downY = y;
  12.                 ty = 0;
  13.                 tp = 0;
  14.             }
  15.             else // unhide the cursor if the mouse has just been released
  16.             { Glut.glutSetCursor(Glut.GLUT_CURSOR_LEFT_ARROW); }
  17.         }
  18.         public static float ty = 0,tp = 0;
  19.         private static void OnMove(int x, int y)
  20.         {
  21.             // if the mouse move event is caused by glutWarpPointer then do nothing
  22.             //if((x == downX && y == downY) || Math.Pow((downX - x), 2) + Math.Pow((downY - y), 2) < 16) return;
  23.             if(x == downX && y == downY)return;
  24.             // move the camera when the mouse is down
  25.             if(mouseDown)
  26.             {
  27.                 float yaw = (downX - x) * 0.002f;
  28.                 ty += yaw;
  29.                 camera.Yaw(yaw);
  30.  
  31.                 float pitch = (downY - y) * 0.002f;
  32.                 tp += pitch;
  33.                 camera.Pitch(pitch);
  34.  
  35.                 Glut.glutWarpPointer(downX, downY);
  36.                 Console.Clear();
  37.                 Console.WriteLine(ty.ToString() + "   " + tp.ToString() + "   " + downX.ToString() + "   " + downY.ToString() + "   " + x.ToString() + "   " + y.ToString());
  38.             }
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement