Exemple #1
0
void autoLevelTimer(int dummy)
{
	win.autoLevel(smoothAutoLevelScale, smoothAutoLevelMaxPhi);
	glutPostRedisplay();

	if (smoothAutoLevel)
		glutTimerFunc(smoothAutoLevelInterval, autoLevelTimer, 0);
}
Exemple #2
0
void keyboard(unsigned char key, int x, int y)
{
	switch (key)
	{
		case 'w':
			std::cout << "DOWN" << std::endl;
			win.rotateAroundAxis(0, rotationDegree);
			break;
		case 's':
			std::cout << "UP" << std::endl;
			win.rotateAroundAxis(0, -rotationDegree);
			break;

		case 'a':
			std::cout << "LEFT" << std::endl;
			win.rotateAroundAxis(1, -rotationDegree);
			break;
		case 'd':
			std::cout << "RIGHT" << std::endl;
			win.rotateAroundAxis(1, rotationDegree);
			break;

		case 'q':
			std::cout << "LEFT ROLL" << std::endl;
			win.rotateAroundAxis(2, -rotationDegree);
			break;
		case 'e':
			std::cout << "RIGHT ROLL" << std::endl;
			win.rotateAroundAxis(2, rotationDegree);
			break;

		case 'j':
			std::cout << "Moving forward." << std::endl;
			win.moveAlongAxis(2, movingStep);
			break;
		case 'k':
			std::cout << "Moving backward." << std::endl;
			win.moveAlongAxis(2, -movingStep);
			break;

		case 'h':
			std::cout << "Moving left." << std::endl;
			win.moveAlongAxis(0, movingStep);
			break;
		case 'l':
			std::cout << "Moving right." << std::endl;
			win.moveAlongAxis(0, -movingStep);
			break;

		case 'r':
			std::cout << "Reset." << std::endl;
			win.reset();
			break;

		case 'm':
			mouseLook = !mouseLook;
			if (mouseLook)
			{
				glutSetCursor(GLUT_CURSOR_NONE);

				// Init the algorithm: Warp to center
				glutWarpPointer(win.w() * 0.5, win.h() * 0.5);

				std::cout << "Mouse look activated." << std::endl;
			}
			else
			{
				glutSetCursor(GLUT_CURSOR_INHERIT);
				std::cout << "Mouse look deactivated." << std::endl;
			}
			break;

		case 'n':
			smoothAutoLevel = !smoothAutoLevel;
			if (smoothAutoLevel)
			{
				std::cout << "Smooth Auto-Leveling activated." << std::endl;

				glutTimerFunc(smoothAutoLevelInterval, autoLevelTimer, 0);
			}
			else
				std::cout << "Smooth Auto-Leveling deactivated." << std::endl;
			break;

		case 'N':
			win.toggleDirectAutoLevel();
			if (win.doesDirectAutoLevel())
				std::cout << "Direct Auto-Leveling activated." << std::endl;
			else
				std::cout << "Direct Auto-Leveling deactivated." << std::endl;
			break;

		case 'i':
			mouseInverted = !mouseInverted;
			if (mouseInverted)
				std::cout << "Mouse inverted." << std::endl;
			else
				std::cout << "Mouse not inverted." << std::endl;
			break;

		case ' ':
			std::cout << "Smooth Auto-Leveling. "
				<< "Press 'n' to toggle a timer!" << std::endl;
			win.autoLevel(smoothAutoLevelScale, smoothAutoLevelMaxPhi);
			break;

		case 27:
			exit(EXIT_SUCCESS);
			break;
	}

	glutPostRedisplay();
}