Пример #1
0
void motion(int x, int y)
{
    moveTrackball(x, y);
	if(!TwEventMouseMotionGLUT(x, y)) {

	}
}
Пример #2
0
void mouseMotion(int x, int y){
    if (TwEventMouseMotionGLUT(x,y)){        
        return;
    }
    
    mouse.Dx = mouse.x - x;
    mouse.Dy = mouse.y - y;
    
    // rotate camera 
    if (mouse.buttons[0]){    
        //camera.setSphericCoords(10, phi, 1.25);
        //phi+=0.005;
        //camera.lookLefRigObj(mouse.Dx*mouse.sensitivity);
        //camera.lookUpDownObj(mouse.Dy*mouse.sensitivity);
        camera.rotateAroundObj(mouse.Dx*mouse.sensitivity, mouse.Dy*mouse.sensitivity);
    }
    // zoom camera
    else if (mouse.buttons[2]){
        //camera.MoveFrente(mouse.Dy*mouse.sensitivity);
    }
    
    // update mouse coords
    mouse.x = x;
    mouse.y = y;
}
Пример #3
0
void MotionFunc(int x, int y)
{
    if (TwEventMouseMotionGLUT(x, y))
        return;

    CurMouseX = x;
    CurMouseY = y;
}
Пример #4
0
void passive_motion(int x,int y)
{
  // Tweakbar has precedence over everything else
  if(TwEventMouseMotionGLUT(x,y))
  {
    glutPostRedisplay();
  }
}
Пример #5
0
//****************************************
void MouseMotion(int x, int y) {
  if (rendering) {
    if (!TwEventMouseMotionGLUT(x, y)) {
      y = window_height - y;

      if (left_mouse_button) {
        // Arc-ball rotational movement
        Vec3f arc_coords = arcSnap(x, y);
        float fx = arc_coords[0];
        float fy = arc_coords[1];
        float fz = arc_coords[2];

        // Find rotational axis
        float normal_x = arcmouse_y*fz - arcmouse_z*fy;
        float normal_y = arcmouse_z*fx - arcmouse_x*fz;
        float normal_z = arcmouse_x*fy - arcmouse_y*fx;

        // Find rotational angle
        float ax = sqrt(normal_x*normal_x +
                        normal_y*normal_y +
                        normal_z*normal_z);

        float ay = arcmouse_x*fx + arcmouse_y*fy + arcmouse_z*fz;
        float angle = atan2(ax, ay)*180/3.14159;

        // Modify and save rotation matrix
        glLoadIdentity();
        glRotatef(angle, normal_x, normal_y, normal_z);
        glMultMatrixf(rot_matrix);
        glGetFloatv(GL_MODELVIEW_MATRIX, rot_matrix);

        arcmouse_x = fx, arcmouse_y = fy, arcmouse_z = fz;

      } else if (right_mouse_button && y && mouse_y) {
        // Zoom: Multiplies current zoom by ratio between initial and current y
        float smy = mouse_y+window_height;
        float sy = y+window_height;
        float dy;

        if (sy < 0 && smy < 0) {
          dy = abs(smy/sy);
        } else {
          dy = abs(sy/smy);
        }

        zoom *= dy;
      }

      mouse_x = x, mouse_y = y;
    }
    glutPostRedisplay();
  }
}
void RotationsViewer::onMouseMotion(int pX, int pY)
{
    // Check GUI first
    if (TwEventMouseMotionGLUT(pX, pY)) return;

    int deltaX = mLastX - pX;
    int deltaY = mLastY - pY;
    bool moveLeftRight = abs(deltaX) > abs(deltaY);
    bool moveUpDown = !moveLeftRight;

    mLastX = pX;
    mLastY = pY;
}
Пример #7
0
void mouseMove(int x, int y) {

	// this will only be true when the left button is down
	if (xOrigin >= 0) {

		xAngle = x - xOrigin;
		xOrigin = x;
		yAngle = y - yOrigin;
		yOrigin = y;
	}
		/// step 5: handle events and window size changes
	TwEventMouseMotionGLUT(x,y);
	glutPostRedisplay();
}
Пример #8
0
static void MotionCallback(int x, int y)
{
	if(!TwEventMouseMotionGLUT(x, y))
	{
		if(gButton==2)
		{
			int dx = gMouseX - x;
			int dy = gMouseY - y;
			
			RotateCamera(dx, dy);

			gMouseX = x;
			gMouseY = y;
		}
		else
			gCollisionTests[gTest]->MotionCallback(x, y);
	}
}
	void PassiveMotion(int x, int y) {
		TwEventMouseMotionGLUT(x, y);
	}
Пример #10
0
void MouseMotion(int x, int y)
{
	TwEventMouseMotionGLUT(x, y);
	glutPostRedisplay();
}
Пример #11
0
void passiveMotion(int x, int y)
{
    motion_x = x;
    motion_x = y;
    TwEventMouseMotionGLUT(x, y);
}
Пример #12
0
void motion(int x, int y)
{
    motion_x = x;
    motion_y = y;
    TwEventMouseMotionGLUT(x, y);
}
void OnMouseMotion(int mouseX, int mouseY)
{
    // send event to AntTweakBar
    if (TwEventMouseMotionGLUT(mouseX, mouseY))
        glutPostRedisplay(); // request redraw if event has been handled
}
// Mouse Motion event callbacks
int MouseMotionCB(int mouseX, int mouseY) 
{
	TwSetCurrentWindow(glutGetWindow());
	return TwEventMouseMotionGLUT(mouseX,mouseY);
}
Пример #15
0
void motion(int x,int y) {
  pScene      sc;
  pTransform  tr;
  pPersp      p;
  GLuint      gtime;
  double      deltax,deltay;
  float       coeff,pos[3],dx,dy,dz;
  int         idw = currentScene();

  /* default */
  if ( picking )  return;
  if ( ddebug ) fprintf(stdout,"motion\n");

#ifdef IGL
  // Tweakbar has precedence over everything else
  if(TwEventMouseMotionGLUT(x,y))
  {
    if(!tracking)
    {
      glutPostRedisplay();
    }
  }
#endif

  if ( tracking == GL_FALSE )  return;
  sc = cv.scene[idw];
  p  = sc->persp;
  if ( p->rubber == 1 )  return;

  /* what is transformed ? */
  if ( sc->cube->active & C_EDIT ) 
    tr = sc->cube->cubetr;
  else if ( sc->clip->active & C_EDIT ) 
    tr = sc->clip->cliptr;
  else
    tr = sc->view;

  if ( tr->mstate != GLUT_DOWN )  return;
  if ( picking )  tr->angle = 0.0f;

  gtime = glutGet(GLUT_ELAPSED_TIME);
  if ( (animate || sc->type & S_FOLLOW) && gtime < lasttime+40 )  return;

  if ( tr->mbutton == GLUT_LEFT_BUTTON ) {
    /* calculate axis of rotation: cross product */
    point2Vect(x,y,sc->par.xs,sc->par.ys,pos);
    tr->axis[0] = tr->pos[1]*pos[2] - tr->pos[2]*pos[1];
    tr->axis[1] = tr->pos[2]*pos[0] - tr->pos[0]*pos[2];
    tr->axis[2] = tr->pos[0]*pos[1] - tr->pos[1]*pos[0];
 
    /* calculate angle to rotate by */
    if ( animate && saveimg )
      tr->angle = 2.0f;
    else {
      dx = pos[0] - tr->pos[0];
      dy = pos[1] - tr->pos[1];
      dz = pos[2] - tr->pos[2];
      tr->angle = 180.0*sqrt(dx*dx+dy*dy+dz*dz);
    }

    /* reset for next time */
    tr->pos[0] = pos[0];
    tr->pos[1] = pos[1];
    tr->pos[2] = pos[2];
    lasttime   = gtime;

    if ( sc->cube->active & C_ON && sc->cube->active & C_EDIT )
      sc->cube->active |= C_UPDATE;
    else if ( sc->clip->active & C_ON && 
	         (sc->clip->active & C_EDIT || sc->clip->active & C_FREEZE) )
      sc->clip->active |= C_UPDATE;

    glutPostRedisplay();
  }

  else if ( tr->mbutton == GLUT_MIDDLE_BUTTON ) {
    coeff  = tr->manim == GL_TRUE ? 0.2 : 2.0;
    deltax = coeff * (x-startx) / (float)sc->par.xs;
    deltay = coeff * (starty-y) / (float)sc->par.ys;

    if ( deltax != 0.0 )
      tr->panx += -deltax * p->depth * tan(p->fovy/360.*M_PI);
    if ( deltay != 0.0 )
      tr->pany += -deltay * p->depth * tan(p->fovy/360.*M_PI);
    tr->angle = 0.0;
    startx = x;
    starty = y;

    lasttime = gtime;
    if ( sc->cube->active & C_ON && sc->cube->active & C_EDIT )
      sc->cube->active |= C_UPDATE;
    else if ( sc->clip->active & C_ON && 
        (sc->clip->active & C_EDIT || sc->clip->active & C_FREEZE) )
      sc->clip->active |= C_UPDATE;

    glutPostRedisplay();
  }
}