示例#1
0
void Draw3d()
{
	Setup3dWorld();

	DrawWorld();	
	//pointer
	u.pointer = GetOGLPos(int(u.mp.x), int(u.mp.y));
	mPointer.Draw(u.pointer, 0);
}
示例#2
0
void mouse_cb( int button, int state, int x, int y )
{
  if( state != GLUT_DOWN )
    return;
  if( button == GLUT_RIGHT_BUTTON )
    exit( 0 );

  vec3 test = GetOGLPos( x, y );

  if( woman.IntersectP( test ) ) {
    Selected = true;
  } else {
    Selected = false;
  }

  glutPostRedisplay();
}
示例#3
0
void onMouseMotionCb(int x, int y)
{
   int deltaX = lastX - x;
   int deltaY = lastY - y;
   bool moveLeftRight = abs(deltaX) > abs(deltaY);
   bool moveUpDown = !moveLeftRight;


   if (theButtonState == GLUT_LEFT_BUTTON)  // Rotate    //use this to detect if it clicks on Particles
   {
	    openGLPosition = GetOGLPos(x,y);

      /*
	  if (moveLeftRight && deltaX > 0) theCamera.orbitLeft(deltaX);
      else if (moveLeftRight && deltaX < 0) theCamera.orbitRight(-deltaX);
      else if (moveUpDown && deltaY > 0) theCamera.orbitUp(deltaY);
      else if (moveUpDown && deltaY < 0) theCamera.orbitDown(-deltaY);
	  */

       a = theJello.onMouseCheck(openGLPosition);
	  //cout<<openGLPosition[0]<<"  "<<openGLPosition[1]<<"   " <<openGLPosition[2];

	  if(a!=(-1))
	  {
	  pressPosition = openGLPosition;
	  pressFlag = true;
	  particleIndex = a;
	  std::cout << "Pick up particle"<<particleIndex<<"\n";
	  theJello.clearUserForces();
	  }

	  //if(pressFlag)
	  if(a==(-1))
	  {
	  forcePosition = openGLPosition; 
	  // std::cout << "drag up particle";
	  if(particleIndex==(-1))
	  {
	  pressFlag = false;
	  }

	  if(pressFlag)
	  {
	  theJello.dragJello(pressPosition,forcePosition, particleIndex);
	  }
	  
	  }


   }

   else if (theButtonState == GLUT_MIDDLE_BUTTON) // Zoom
   {
       if (theModifierState & GLUT_ACTIVE_ALT) // camera move
       {
            if (moveLeftRight && deltaX > 0) theCamera.moveLeft(deltaX);
            else if (moveLeftRight && deltaX < 0) theCamera.moveRight(-deltaX);
            else if (moveUpDown && deltaY > 0) theCamera.moveUp(deltaY);
            else if (moveUpDown && deltaY < 0) theCamera.moveDown(-deltaY);
       }
       else
       {
           if (moveUpDown && deltaY > 0) theCamera.moveForward(deltaY);
           else if (moveUpDown && deltaY < 0) theCamera.moveBack(-deltaY);
       }

   }    
 
   lastX = x;
   lastY = y;
   glutPostRedisplay();
}