void mouse(int button, int state, int x, int y){
  switch (button) {
  case GLUT_LEFT_BUTTON:
    if (state == GLUT_DOWN) {
      yreal = matrizViewport[3] - (GLint) y - 1;
      gluUnProject ((GLdouble) x, (GLdouble) yreal, 0.0, 
		    matrizModelview, matrizProjecao, matrizViewport, 
		    &wx, &wy, &wz); 
      mudaCurva=1;
      proximidade();
    }
    if (state == GLUT_UP) {
      mudaCurva=0;
    }
    break;
  }
}
Beispiel #2
0
void mouse(int button, int state, int x, int y) {
    switch (button) {
    case GLUT_LEFT_BUTTON:
        if (state == GLUT_DOWN) {
            realy = matrizViewport[3] - (GLint) y - 1;
            gluUnProject ((GLdouble) x, (GLdouble) realy, 0.0,
                          matrizModelview, matrizProjecao, matrizViewport,
                          &wx0, &wy0, &wz0);
            gluUnProject ((GLdouble) x, (GLdouble) realy, 1.0,
                          matrizModelview, matrizProjecao, matrizViewport,
                          &wx1, &wy1, &wz1);
            vx=wx1-wx0;
            vy=wy1-wy0;
            vz=wz1-wz0;
            proximidade();
            glutPostRedisplay();
        }
        else {
            mudaCurva=0;
        }
        break;
    }
}