示例#1
0
void mouseClick(int button, int state, int x, int y){

	if(TwEventMouseButtonGLUT(button,state,x,y)) return;
	if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
		processSelection(x, y);
   }

}
	void Mouse(int button, int state, int x, int y) {
		TwEventMouseButtonGLUT(button, state, x, y);

		if (button == 3) { // scroll up
			_camera->move(-10.0f);
		}
		else if (button == 4) { // scroll down
			_camera->move(10.0f);
		}
	}
示例#3
0
static void MouseCallback(int button, int state, int x, int y)
{
	gButton = button;
	gMouseX = x;
	gMouseY = y;

	if(!TwEventMouseButtonGLUT(button, state, x, y))
	{
		gCollisionTests[gTest]->MouseCallback(button, state, x, y);
	}
}
示例#4
0
void mouseFunc(int button, int state, int x, int y){
    if (TwEventMouseButtonGLUT(button, state, x, y)){
        mouse.buttons[button]=false;
        return;
    }
    
    // update mouse buttons and coordinates
    mouse.buttons[button] = !mouse.buttons[button];
    mouse.x = x;
    mouse.y = y;

}
示例#5
0
文件: part2.cpp 项目: isqb/graphics
void mouse(int button, int state, int x, int y)
{
    if (state == GLUT_DOWN) {
        mouseButtonPressed(button, x, y);
    }
    else {
        mouseButtonReleased(button, x, y);
    }
	if(!TwEventMouseButtonGLUT(button,state,x,y) ) {

	}
}
示例#6
0
文件: main.c 项目: vvolkgang/YASS
void mouseClick(int button, int state, int x, int y){
	int tw = TwEventMouseButtonGLUT(button,state,x,y);
	if(!tw){
		if(button == GLUT_LEFT_BUTTON) {
			if(state != GLUT_DOWN) {

				_camera->deltaAnglev= 0.0f; // this will prevent the not stoping camera bug
				_camera->deltaAngle = 0.0f;
			}
		}
	}
}
示例#7
0
void mouseButton(int button, int state, int x, int y) {

	// only start motion if the left button is pressed
	if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
			xOrigin = x;
			yOrigin = y;
	}else{
		xOrigin = -1;
		yOrigin = -1;
	}
	/// step 5: handle events and window size changes
	TwEventMouseButtonGLUT(button,state,x,y);
}
void RotationsViewer::onMouse(int pButton, int pState, int pX, int pY)
{
    // Check GUI first
    if (TwEventMouseButtonGLUT(pButton, pState, pX, pY))  return;

    mButtonState = pButton;
    mModifierState = glutGetModifiers();
    mLastX = pX;
    mLastY = pY;

    if (mButtonState == GLUT_LEFT_BUTTON)
    {
    }
}
示例#9
0
文件: main.cpp 项目: happanda/Engine
void mouse(int btn, int state, int x, int y)
{
    motion_x = x;
    motion_y = y;
    TwEventMouseButtonGLUT(btn, state, x, y);
    int w = glutGet(GLUT_WINDOW_WIDTH);
    int h = glutGet(GLUT_WINDOW_HEIGHT);
    if (btn == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
    {
        Vector2 localCoord;
        Body* body = click_inside(x, y, localCoord);
        if (body != 0)
        {
            Force force;
            force.Body = body;
            force.LocalPoint = localCoord;
            world.addForce(force);
            drag_force = &world.forces.at(world.forces.size() - 1);
            printf("Inside body!!\n");
        }
    }
    if (btn == GLUT_RIGHT_BUTTON && state == GLUT_DOWN)
    {
        Vector2 localCoord;
        kickBody = click_inside(x, y, localCoord);
    }
    if (btn == GLUT_RIGHT_BUTTON && state == GLUT_UP)
    {
        if (kickBody != 0)
        {
            double wx, wy;
            screen_coords2world(motion_x, motion_y, wx, wy);
            Vector2 kickImpulse = (Vector2(wx, wy) - kickBody->form->point) * 5;
            if (kickImpulse.norm2sq() > 35)
            {
                kickImpulse.normalize2();
                kickImpulse = kickImpulse * 35;
            }
            if (kickBody->mass < world.vars.UNMOVABLE_MASS)
                kickBody->velocity = kickBody->velocity + kickImpulse;
            kickBody = 0;
        }
    }
    if (btn == GLUT_LEFT_BUTTON && state == GLUT_UP)
    {
        drag_force = 0;
        world.forces.clear();
    }
}
示例#10
0
文件: main.cpp 项目: vlopezsa/code
void MouseFunc(int button, int state, int x, int y)
{
    if (TwEventMouseButtonGLUT(button, state, x, y))
        return;

    if (GLUT_DOWN == state)
    {
        CurMouseX = LastMouseX = x;
        CurMouseY = LastMouseY = y;
        LastMouseButtonClicked = button;
        MouseDown = true;
    }
    else
    {
        MouseDown = false;
    }
}
示例#11
0
//****************************************
void MouseButton(int button, int state, int x, int y) {
  if (rendering) {
    if (!TwEventMouseButtonGLUT(button, state, x, y)) {
      y = window_height - y;

      if (button == GLUT_LEFT_BUTTON) {
        Vec3f arc_coords = arcSnap(x, y);
        arcmouse_x = arc_coords[0];
        arcmouse_y = arc_coords[1];
        arcmouse_z = arc_coords[2];

        left_mouse_button = !state;  // state==0 if down
      }

      if (button == GLUT_RIGHT_BUTTON) {
        right_mouse_button = !state;  // state==0 if down
      }

      mouse_x = x, mouse_y = y;
    }
    glutPostRedisplay();
  }
}
示例#12
0
void MouseButton(int button, int state, int x, int y)
{
	TwEventMouseButtonGLUT(button, state, x, y);
	glutPostRedisplay();
}
// Event callbacks
void OnMouseButton(int glutButton, int glutState, int mouseX, int mouseY)
{
    // send event to AntTweakBar
    if (TwEventMouseButtonGLUT(glutButton, glutState, mouseX, mouseY))
        glutPostRedisplay(); // request redraw if event has been handled
}
// Mouse Button event callbacks
int MouseButtonCB(int glutButton, int glutState, int mouseX, int mouseY) 
{
	TwSetCurrentWindow(glutGetWindow());
	return TwEventMouseButtonGLUT(glutButton,glutState,mouseX,mouseY);
}
示例#15
0
文件: mouse.c 项目: CHen417/medit
void mouse(int button,int state,int x,int y) {
  button = alt_ctrl_left_to_middle(button);
  pScene      sc;
  pTransform  tr;
  pPersp      p;
  int         keyact,idw = currentScene();
  static int  olds = -1;
#ifdef IGL
  // Tweakbar has precedence over everything else
  if(TwEventMouseButtonGLUT(button,state,x,y) && state == GLUT_DOWN)
  {
    return;
  }
#endif

  /* default */
  if ( ddebug ) printf("control mouse %d\n",state);
  sc = cv.scene[idw];
  p  = sc->persp;
  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;
  tr->mstate  = state;
  tr->mbutton = button;

  /* check if ctrl-shift-alt pressed */
  keyact = glutGetModifiers();

  if ( state == GLUT_DOWN ) {
  
  picking=GL_FALSE;
    tracking = GL_TRUE;
    lasttime = glutGet(GLUT_ELAPSED_TIME);

    if ( button == GLUT_LEFT_BUTTON ) {
      if ( keyact & GLUT_ACTIVE_SHIFT ) {
        /* entity designation */
        picking = GL_TRUE;
	if ( sc->picklist ) glDeleteLists(sc->picklist,1);
	sc->picklist = pickingScene(sc,x,y,0);
	return;
      }

      else if ( keyact & GLUT_ACTIVE_ALT ) {
	    /* zoom */
	    starty = y;
	    glutMotionFunc(zoomMotion);
	    return;
      }

      else if ( keyact & GLUT_ACTIVE_CTRL ) {
        /* rubberband selection */
        glutSetCursor(GLUT_CURSOR_CROSSHAIR);
        p->rubix  = p->rubfx = x;
        p->rubiy  = p->rubfy = sc->par.ys-y;
        rxi = rx1 = x;
        ryi = ry1 = sc->par.ys-y;
        p->rubber = 1;
        glDrawBuffer(GL_BACK_LEFT);
        ortho2D(sc,ON);
        glutMotionFunc(rubberMotion);
        return;
      }
    }
    
    else if ( button == GLUT_MIDDLE_BUTTON && keyact & GLUT_ACTIVE_SHIFT ) {
      picking = GL_TRUE;
      if ( sc->picklist ) glDeleteLists(sc->picklist,1);
      sc->picklist = pickingScene(sc,x,y,LPoint);
      return;
    }

    /* transformation */
    startx = x;
    starty = y;
    point2Vect(x,y,sc->par.xs,sc->par.ys,tr->pos);
    glutSetCursor(GLUT_CURSOR_INFO);
  }

  else if ( state == GLUT_UP ) {

    if ( button == GLUT_LEFT_BUTTON ) {
      
      if ( keyact & GLUT_ACTIVE_CTRL ) {
        /* rubberband selection */
        p->rubfx  = x;
        p->rubfy  = sc->par.ys-y;
        p->rubber = 2;
        glDrawBuffer(GL_BACK_LEFT);
        ortho2D(sc,OFF);
        glutMotionFunc(motion);
        return;
      }
      
      else if ( keyact & GLUT_ACTIVE_ALT ) {
        glutMotionFunc(motion);
	    return;
      }

      else if ( picking == GL_TRUE ) {
        picking = GL_FALSE;
        reshapeScene(sc->par.xs,sc->par.ys);
        glutPostRedisplay();
      }
    }
    
    glutMotionFunc(motion);
    if ( sc->clip->active & C_EDIT )
      sc->clip->active |= C_REDO;

    /* transformation */
    glutSetCursor(GLUT_CURSOR_INHERIT);
    tracking = GL_FALSE;
    if ( glutGet(GLUT_ELAPSED_TIME) >= lasttime ) { 
      if ( tr->manim == GL_TRUE )  glutIdleFunc(glutIdle);
      else  tr->angle = 0.0;
      /*if ( abs(startx-x) + abs(starty-y) > 0 )*/
        glutPostRedisplay();
    }
    else if ( tr->manim == GL_TRUE && olds == idw )  
      glutIdleFunc(NULL);
  }

  olds = idw;
}