Ejemplo n.º 1
0
void gluiMainWindow (int control){
	switch(control){
	case 0:
		subGlui->hide();
		bt3->enable();
		break;
	case 1:
		//inicializar LeapMotion y FMod
		controller.addListener(leap);
		sonido.init();
		simulator=1;
		luces();
		bt1->disable();
		break;
	case 3:
		enable=1;
		bt3->disable();
		break;
	case -3:
		bt4->disable();
		controller.removeListener(leap);
		exit(0);
		break;
	}
	glutPostRedisplay();
}
Ejemplo n.º 2
0
/* ----------------------------------------------------------------------------------------- */
int main(int argc, char ** argv)
{
  int infile = 0, outfile = 0;
  double filter = 0;
  parse_argv(argc, argv, &infile, &outfile, &filter);

  if(infile != 0) {
    play(infile);
    return 0;
  }
 
  // Create a sample listener and controller
  CListener listener;
  Controller controller;
 
  if(outfile != 0)
    listener.set_robot_output(outfile);

  listener.set_filter(filter);

  // Have the sample listener receive events from the controller
  controller.addListener(listener);

  // Keep this process running until Enter is pressed
  std::cout << "Press Enter to quit..." << std::endl;
  std::cin.get();

  // Remove the sample listener when done
  controller.removeListener(listener);

  return 0;
}
Ejemplo n.º 3
0
int main()
{
  // Create a sample listener and controller
  SampleListener listener;
  Controller controller;

  listener.Mouse = new MouseManager();
  listener.mystate = 0;
  listener.clickcount = 0;
  listener.pressstate = 0;
  listener.side = 0;
  listener.pressedDelay = 0;
  listener.rclick = 0;
  listener.sensibility = 8;
  listener.active = false;

  listener.lastFrameID = -1;
  listener.lastToggle = 0;
  listener.lastEvent = time(0);

  std::cout << "width: "  << listener.Mouse->w_width  << std::endl;
  std::cout << "height: " << listener.Mouse->w_height << std::endl;

  // Have the sample listener receive events from the controller
  controller.addListener(listener);

  // Keep this process running until Enter is pressed
  std::cout << "Press Enter to quit..." << std::endl;
  std::cin.get();

  // Remove the sample listener when done
  controller.removeListener(listener);

  return 0;
}
Ejemplo n.º 4
0
int main(int argc, const char *argv[]){
	screen_width = (unsigned int)CGDisplayPixelsWide(kCGDirectMainDisplay);
	screen_height = (unsigned int)CGDisplayPixelsHigh(kCGDirectMainDisplay);
	CGPoint current_point = CGEventGetLocation(CGEventCreate(nil));

	screen = controller.calibratedScreens()[0];
	if(!screen.isValid()){
		cout << "This screen has not been calibrated." << endl;
		return 0;
	}
	
	// Create a sample listener and controller
	SampleListener listener;
	
	// Have the sample listener receive events from the controller
	controller.addListener(listener);
	
	// Keep this process running until Enter is pressed
	std::cout << "Press Enter to quit..." << std::endl;
	std::cin.get();
	
	// Remove the sample listener when done
	controller.removeListener(listener);
	
	return 0;
}
Ejemplo n.º 5
0
int main(int argc, char** argv) {

    ros::init(argc, argv, "leap_motion");
    ros::NodeHandle nh("leap_motion");

    bool setup_params[7];

    // Read parameters from the defined in listener_params.yaml
    nh.getParam("/enable_controller_info", setup_params[0] );
    nh.getParam("/enable_frame_info", setup_params[1] );
    nh.getParam("/enable_hand_info", setup_params[2] );

    nh.getParam("/enable_gesture_circle", setup_params[3] );
    nh.getParam("/enable_gesture_swipe", setup_params[4] );
    nh.getParam("/enable_gesture_screen_tap", setup_params[5] );
    nh.getParam("/enable_gesture_key_tap", setup_params[6] );

    LeapListener listener(setup_params);
    // Add a publisher to the leapListener object
    listener.ros_publisher = nh.advertise<leap_motion::Human>("leap_device", 1);

    Controller controller;
    controller.addListener(listener);
    // Keep doing ROS spin until shutdown() or Ctrl+C
    ros::spin();
    controller.removeListener(listener);

    return 0;
}
Ejemplo n.º 6
0
int main(int argc , char ** argv) {
	screen = controller.calibratedScreens()[0];
	if(!screen.isValid()){
		cout << "This screen has not been calibrated." << endl;
		return 0;
	}

	srand((unsigned int)time(NULL));

	// Have the sample listener receive events from the controller
	controller.addListener(listener);

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA);
	glutInitWindowSize(screen_width, screen_height);
	glutInitWindowPosition(0, 0);
	window = glutCreateWindow("LEAP intersection Test");
	glutDisplayFunc(&DrawGLScene);
	glutIdleFunc(&Idle);
	glutReshapeFunc(&ReSizeGLScene);
	glutKeyboardFunc(&NormalKeyPressed);
	glutSpecialFunc(&SpecialKeyPressed);

	glDisable(GL_DEPTH_TEST);								// Disables Depth Testing
	glShadeModel(GL_SMOOTH);								// Enables Smooth Color Shading
	
	glutMainLoop();

	return 0;
}
Ejemplo n.º 7
0
int main(int argc, char** argv) {
	controller.addListener(listener);

	// Keep this process running until Enter is pressed
	std::cout << "Press Enter to quit..." << std::endl;
	std::cin.get();

	// Remove the sample listener when done
	controller.removeListener(listener);

	return 0;
}
Ejemplo n.º 8
0
int main(int argc, char** argv) {
	// Create a sample listener and controller
	SampleListener listener;
	Controller controller;
	// Have the sample listener receive events from the controller
	controller.addListener(listener);
	if(argc > 1 && strcmp(argv[1], "--bg") == 0)
		controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);
	getchar();
	// Remove the sample listener when done
	controller.removeListener(listener);
	return 0;
}
void LeapCinderVectorFieldApp::setup()
{
	m_LeapController.addListener( m_LeapListener );

	/** timing data */
	m_fLastTime = getElapsedSeconds();
	m_fFrameTime = 0;

	/** background image */
	//m_BGImage = gl::Texture( loadImage( loadAsset( "testBg.jpg" ) ) );

	/** vector field */
	m_VectorField = new VectorFieldController();
}
Ejemplo n.º 10
0
int main() {
	// Create a sample listener and controller
	myFingers listener;
	Controller controller;
	// Have the sample listener receive events from the controller
	controller.addListener(listener);

	// Keep this process running until Enter is pressed
	std::cout << "Press Enter to quit..." << std::endl;
	std::cin.get();

	// Remove the sample listener when done
	controller.removeListener(listener);

	return 0;
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);

  MangoListener listener;

  Controller controller;
  controller.addListener(listener);

  std::cout << "Mango started, press enter to quit..." << std::endl;
  app.exec();
  std::cin.get();

  controller.removeListener(listener);

  return 0;
}
Ejemplo n.º 12
0
int main(int argc, char **argv, char **envp) {
	if (argc == 1) {
		cerr << "Usage: " << argv[0] << " <basenote>" << endl
			<< "\tThe basenote can be any number starting from 0 (lowest C)" << endl
			<< "\tRemember that the scale is divided in 12 half-tones" << endl;
		return 1;
	}

	const int basenote = atoi(argv[1]);
	SoundClient soundClient;
	LeapListener listener(basenote, soundClient);
	Controller controller;
	controller.addListener(listener);

	cout << "Press Enter to quit..." << endl;
	cin.get();

	controller.removeListener(listener);
	return 0;
}
Ejemplo n.º 13
0
int main(int argc, char** argv) {
  // Create a sample listener and controller
  SampleListener listener;
  Controller controller;

  // Have the sample listener receive events from the controller
  controller.addListener(listener);

  if (argc > 1 && strcmp(argv[1], "--bg") == 0)
    controller.setPolicy(Leap::Controller::POLICY_BACKGROUND_FRAMES);

  // Keep this process running until Enter is pressed
  std::cout << "Press Enter to quit..." << std::endl;
  std::cin.get();

  // Remove the sample listener when done
  controller.removeListener(listener);

  return 0;
}
Ejemplo n.º 14
0
int main(int argc , char ** argv) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
	glutInitWindowSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	glutInitWindowPosition(0, 0);
	window = glutCreateWindow("LEAP Axis Test");
	glutDisplayFunc(&DrawGLScene);
	glutIdleFunc(&Idle);
	glutReshapeFunc(&ReSizeGLScene);
	glutKeyboardFunc(&NormalKeyPressed);
	glutSpecialFunc(&SpecialKeyPressed);
	InitGL(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	
	// Have the sample listener receive events from the controller
	controller.addListener(listener);

	glutMainLoop();

	return 0;
}
Ejemplo n.º 15
0
int main() {
    // Create a sample listener and controller
    SampleListener listener;
    Controller controller;
    
    // Have the sample listener receive events from the controller
    controller.addListener(listener);
    
    file = fopen("/dev/tty.usbmodemfd1311", "w");  //Opening device file
    
    // Keep this process running until Enter is pressed
    std::cout << "Press Enter to quit..." << std::endl;
    std::cin.get();
    
    // Remove the sample listener when done
    controller.removeListener(listener);
    
    fclose(file);
    
    return 0;
}
Ejemplo n.º 16
0
int main() {
 // LeapClient::LeapComm leapComm;
 // int ret = leapComm.lc_initialize();
 // if (ret == -1) exit(-1);
 // while ( 1 ) {
	//char get_char_c_to_continue;
	//std::cin >> get_char_c_to_continue;
	//if ( get_char_c_to_continue == 'c' ) {
	//	leapComm.lc_send("hellow");
	//}
 // }
    LeapClient::LeapGestureManager leapGestureManager;
	Controller controller;

	controller.addListener( leapGestureManager );

	std::cin.get();

	controller.removeListener( leapGestureManager );

	std::cin.get();
    return 0;
}
Ejemplo n.º 17
0
void StartLeapData()
{
	controller.addListener(listener);
}
Ejemplo n.º 18
0
int main(int argc, char **argv)
{

	/*while (1)
	{
		if (GetAsyncKeyState(27))
			return 0;
		for (int i = 2; i < 500; i++)
		{
			if (GetAsyncKeyState(i))
				cout << i << endl;
		}
	}*/

	//NF = new frame (protection prise de nouvelle image leap motion
	//CC = calcule des commandes a appliquer en fonction des donnees leap motion
	//AC = applicaton des commandes au parrot
	static pthread_mutex_t	mutex_prot_NF_CC = PTHREAD_MUTEX_INITIALIZER; //protection echange position main
	static pthread_mutex_t	mutex_prot_CC_AC = PTHREAD_MUTEX_INITIALIZER; //protection echange commande
	static pthread_mutex_t	mutex_prot_AC_CC = PTHREAD_MUTEX_INITIALIZER; //protection echange level

	static pthread_mutex_t	mutex_mess_NF = PTHREAD_MUTEX_INITIALIZER; //message fin acquisition position main
	static pthread_mutex_t	mutex_mess_CC = PTHREAD_MUTEX_INITIALIZER; //message fin calcul commande
	static pthread_mutex_t	mutex_mess_AC = PTHREAD_MUTEX_INITIALIZER; //message fin utilisation donnees
#if !MULTI_THREAD
	static pthread_mutex_t	mutex_mess_main = PTHREAD_MUTEX_INITIALIZER; //message preparation terminee
#endif

	static pthread_cond_t	cond_mess_NF = PTHREAD_COND_INITIALIZER; //message fin acquisition position main
	static pthread_cond_t	cond_mess_CC = PTHREAD_COND_INITIALIZER; //message fin calcul commande
	static pthread_cond_t	cond_mess_AC = PTHREAD_COND_INITIALIZER; //message fin utilisation donnees
#if !MULTI_THREAD
	static pthread_cond_t	cond_mess_main = PTHREAD_COND_INITIALIZER; //message preparation terminee
#endif


#if MULTI_THREAD
	SampleListener listener(&mutex_prot_NF_CC, &mutex_mess_NF, &cond_mess_NF);
#else
	SampleListener listener(&mutex_prot_NF_CC, &mutex_mess_NF, &cond_mess_NF, &mutex_mess_AC, &cond_mess_AC, &cond_mess_main);
#endif

	EventTrad eventTrad(&listener, &mutex_prot_CC_AC, &mutex_prot_NF_CC, &mutex_mess_CC, &cond_mess_CC, &mutex_mess_NF, &cond_mess_NF,0);
	listener.setEventTrad(&eventTrad);


#if MULTI_THREAD
	MyARDrone ardrone(&eventTrad, &mutex_prot_CC_AC, &mutex_mess_CC, &cond_mess_CC);
#else
	MyARDrone ardrone(&eventTrad, &mutex_prot_CC_AC, &mutex_mess_CC, &cond_mess_CC, &mutex_mess_AC, &cond_mess_AC);
#endif

	if (ardrone.init() == -1)
		return -1;

	ardrone.print();
	Controller controller;

	pthread_t threadCC;
	pthread_t threadAC;
	pthread_create(&threadAC, NULL, ardrone.compute, (void*)&ardrone);
	pthread_create(&threadCC, NULL, eventTrad.compute, (void*)&eventTrad);
	controller.addListener(listener);
	
#if !MULTI_THREAD
	pthread_cond_wait(&cond_mess_main, &mutex_mess_main);
	pthread_cond_signal(&cond_mess_AC);
#endif

	pthread_join(threadCC, NULL);

#if MULTI_THREAD
	//eventTrad.launch();
#endif


	// See you
#if PARROT
   ardrone.close();
#endif
   controller.removeListener(listener);
   return 0;
}
Ejemplo n.º 19
0
int WINAPI WinMain(	HINSTANCE	hInstance,							// Instance
					HINSTANCE	hPrevInstance,						// Previous Instance
					LPSTR		lpCmdLine,							// Command Line Parameters
					int			nCmdShow)							// Window Show State
{
	MSG		msg;													// Windows Message Structure
	BOOL	done=FALSE;												// Bool Variable To Exit Loop

	pModel = new MilkshapeModel();									// Memory To Hold The Model
	if ( pModel->loadModelData( "data/Hand_1.0.ms3d" ) == false )		// Loads The Model And Checks For Errors
	{
		MessageBox( NULL, "Couldn't load the model data\\Hand_bones_2.0.ms3d", "Error", MB_OK | MB_ICONERROR );
		return 0;													// If Model Didn't Load Quit
	}

	/*在这里调用setupJoint,初始化骨骼和顶点位置*/
	pModel->SetupJointMatrices();

	// Ask The User Which Screen Mode They Prefer
	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	{
		fullscreen=FALSE;											// Windowed Mode
	}

	// Create Our OpenGL Window
	if (!CreateGLWindow("ShowMeYourHand",640,480,16,fullscreen))
	{
		return 0;													// Quit If Window Was Not Created
	}
	controller.addListener(listener);
	
	while(!done)													// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))					// Is There A Message Waiting?
		{
			if (msg.message==WM_QUIT)								// Have We Received A Quit Message?
			{
				done=TRUE;											// If So done=TRUE
			}
			else													// If Not, Deal With Window Messages
			{
				TranslateMessage(&msg);								// Translate The Message
				DispatchMessage(&msg);								// Dispatch The Message
			}
		}
		else														// If There Are No Messages
		{
			// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()
			if ((active && !DrawGLScene()) || keys[VK_ESCAPE])		// Active?  Was There A Quit Received?
			{
				done=TRUE;											// ESC or DrawGLScene Signalled A Quit
			}
			else													// Not Time To Quit, Update Screen
			{
				SwapBuffers(hDC);									// Swap Buffers (Double Buffering)
			}

			if (keys[VK_F1])										// Is F1 Being Pressed?
			{
				keys[VK_F1]=FALSE;									// If So Make Key FALSE
				KillGLWindow();										// Kill Our Current Window
				fullscreen=!fullscreen;								// Toggle Fullscreen / Windowed Mode
				// Recreate Our OpenGL Window
				if (!CreateGLWindow("VivianJia's OpenGL Studio",640,480,16,fullscreen))
				{
					return 0;										// Quit If Window Was Not Created
				}
			}
		}

		//控制模型移动
		if(keys[VK_UP]){
			ypos +=  0.2f;
		}

		if(keys[VK_DOWN]){
			ypos -=  0.2f;
		}

		if(keys[VK_LEFT]){
			xpos -=  0.2f;
		}

		if(keys[VK_RIGHT]){
			xpos +=  0.2f;
		}

		if(keys['W']) {
			zpos += 0.2f;
		}
		if(keys['S']) {
			zpos -= 0.2f;
		}

		//控制模型旋转
		if(keys[VK_PRIOR]) {
			yrot += 0.2f;
		}
		if(keys[VK_NEXT]){
			yrot -= 0.2f;
		}
		if(keys[VK_HOME]){
			xrot += 0.2f;
		}
		if(keys[VK_END]){
			xrot -= 0.2f;
		}

		if(keys[VK_INSERT]){
			zrot += 0.2f;
		}
		if(keys[VK_DELETE]){
			zrot -= 0.2f;
		}

		if(keys['p']){
			
		}
	}

	// Shutdown
	KillGLWindow();													// Kill The Window
	return (msg.wParam);											// Exit The Program
}