void Camera::move2D(int x, int y){
    //compute the mouse delta from the previous mouse position
	QVector3D mouse_delta = mouse_position_ - QVector3D(x, y, 0);
	//if the camera is moving, meaning that the mouse was clicked and dragged, change the pitch and heading
	if (move_camera_) {
		changeYaw(mouse_sensitivity_ * mouse_delta.x());
		changePitch(mouse_sensitivity_ * mouse_delta.y());
	}
	mouse_position_ = QVector3D(x, y, 0);
}
Пример #2
0
void motion(int x, int y)
{	
	
    float dx, dy;
    dx = (float)( mouse_old_x-x);
    dy = (float)( mouse_old_y-y);

	 if( dx !=0 || dy!=0)
	 {
		if (mouse_buttons == GLUT_RIGHT_BUTTON)  // Rotate
			{
				//cout<<"mouse left button";
				changeYaw(dx * 0.01);
				changePitch(-dy * 0.01);
			}
			else if (mouse_buttons == GLUT_MIDDLE_BUTTON) // Zoom
			{
				changeAltitude(-dy * 0.01);
			}    

			if (mouse_buttons ==  GLUT_LEFT_BUTTON) // camera move
			{
				changeRadius(-dy*0.01f);
			}
		mouse_old_x = x;
		mouse_old_y = y;
		//cudaDeviceReset();
		//pathtracerReset();
	//	deletePBO(&pbo);
		//runCuda(); 
		
		for(int i=0; i<renderCam->resolution.x*renderCam->resolution.y; i++){
		renderCam->image[i] = glm::vec3(0,0,0);
		}
		iterations=0;
		glutPostRedisplay();
	 }
}