Example #1
0
void InputProcessor::processInputs(float elapsed_time)
{ 
	filter.advanceTime(elapsed_time);

	InputActions* actions = input_manager.getInput();
	
	// camera controls: 
	float fwd_thrust=0.0f;
	float hrz_thrust=0.0f;
	float vrt_thrust=0.0f;
	float yaw_thrust=0.0f;
	float pitch_thrust=0.0f;
	float roll_thrust=0.0f;
	bool move_camera = false;

	if (actions->mouse_button_state[0]) { fwd_thrust += 0.1f; move_camera= true; }
	if (actions->mouse_button_state[1]) { fwd_thrust -= 0.1f; move_camera= true; }
	//yaw_thrust = actions->mouse_xaxis/10.0f;
	//pitch_thrust = actions->mouse_yaxis/10.0f;

	for (short i=0; i<actions->num_keys_pressed; i++)
	{
		switch (filter.testInput(actions->keys_pressed[i]))
		{
		case ESC: exit(0); break;
		case 'w': fwd_thrust += 0.3f; move_camera= true; break;
		case 's': fwd_thrust -= 0.3f; move_camera= true; break;
		case 'q': vrt_thrust += 0.3f; move_camera= true; break;
		case 'e': vrt_thrust -= 0.3f; move_camera= true; break;
		case 'a': hrz_thrust += 1.3f; move_camera= true; break;
		case 'd': hrz_thrust -= 1.3f; move_camera= true; break;
		case 'i': pitch_thrust += 0.05f; move_camera= true;  break;
		case 'k': pitch_thrust -= 0.05f; move_camera= true; break;
		case 'j': yaw_thrust += 0.05f; move_camera= true; break;
		case 'l': yaw_thrust -= 0.05f; move_camera= true; break;
		case 'u': roll_thrust += 0.05f; move_camera= true; break;
		case 'o': roll_thrust -= 0.05f; move_camera= true; break;
		case '1': anim_ctrl.togglePause(); break;
		case '2': anim_ctrl.singleStep(); break;
		case '9': setCameraLeft(); break;
		case '8': setCameraFrontLeft(); break;
		case '7': setCameraFront(); break;
		}
	}
	if (move_camera)
	{
		camera.move(0.02f, fwd_thrust, hrz_thrust, vrt_thrust, yaw_thrust, pitch_thrust, roll_thrust);
	}
}
Example #2
0
void AppCamera::initializeCamera(int window_width, int window_height)
{
	camera.projectionParameters(
		40.0,									// vertical FOV
		float(window_width)/window_height,		// aspect ratio
		1.0,									// near plane
		1000.0);								// far plane
	camera.viewParameters(
		Vector3D(10.0f,5.0f,-10.0f),	// eye point
		Vector3D(0.0f,0.0f,0.0f),		// lookat point
		Vector3D(0.0f,1.0f,0.0f));		// up vector
	
	// initial position
	setCameraLeft();
}
Example #3
0
int main(int argc, char **argv) {
	char * image = NULL;
	char * activity = NULL;
	switch(argc){
		case 3:
			if (strcmp(argv[1],"-in")==0){
				image= argv[2];
				activity = NULL;
			}else{
				perror("Wrong parameters");
				exit(-1);
			}
			break;
		case 5:
			if (strcmp(argv[1],"-in")==0 && strcmp(argv[3],"-z")==0){
				image= argv[2];
				activity = argv[4];
			}else{
				if (strcmp(argv[1],"-z")==0 && strcmp(argv[3],"-in")==0){
					activity = argv[2];
					image= argv[4];
				}else{
					perror("Wrong parameters");
					exit(-1);
				}
			}
			break;
		default:
			perror("Wrong parameters");
			exit(-1);
			break;
	}

	QApplication app(argc, argv);

	RenderWidget *widget = new RenderWidget(image, activity);


	QPushButton front("vorn");
	QObject::connect( &front, SIGNAL( clicked() ),
			widget, SLOT( setCameraFront() ) );
	front.show();

	QPushButton back("hinten");
	QObject::connect( &back, SIGNAL( clicked() ),
			widget, SLOT( setCameraBack() ) );
	back.show();

	QPushButton right("rechts");
	QObject::connect( &right, SIGNAL( clicked() ),
			widget, SLOT( setCameraRight() ) );
	right.show();

	QPushButton left("links");
	QObject::connect( &left, SIGNAL( clicked() ),
			widget, SLOT( setCameraLeft() ) );
	left.show();

	QPushButton top("oben");
	QObject::connect( &top, SIGNAL( clicked() ),
			widget, SLOT( setCameraTop() ) );
	top.show();

	QPushButton bottom("unten");
	QObject::connect( &bottom, SIGNAL( clicked() ),
			widget, SLOT( setCameraBottom() ) );
	bottom.show();

	widget->show();	
	return app.exec();
}