scenes/inf585/project/src/main.cpp
// Function called every time the mouse is moved
Function called every time the mouse is moved
Function called every time the mouse is moved
void mouse_move_callback(GLFWwindow* window, double xpos, double ypos)
{
	vec2 const  p1 = glfw_get_mouse_cursor(window, xpos, ypos);
	vec2 const& p0 = user.mouse_prev;
	glfw_state state = glfw_current_state(window);
	auto& camera = scene.camera;
	if(!user.cursor_on_gui){
		if(state.mouse_click_left && !state.key_ctrl)
			scene.camera.manipulator_rotate_trackball(p0, p1);
		if(state.mouse_click_left && state.key_ctrl)
			camera.manipulator_translate_in_plane(p1-p0);
		if(state.mouse_click_right)
			camera.manipulator_scale_distance_to_center( (p1-p0).y );
	}
	user.mouse_prev = p1;
}
void mouse_move_callback ( GLFWwindow * window , double xpos , double ypos ) { vec2 const p1 = glfw_get_mouse_cursor ( window , xpos , ypos ) ; vec2 const & p0 = user . mouse_prev ; glfw_state state = glfw_current_state ( window ) ; auto & camera = scene . camera ; if ( ! user . cursor_on_gui ) { if ( state . mouse_click_left && ! state . key_ctrl ) scene . camera . manipulator_rotate_trackball ( p0 , p1 ) ; if ( state . mouse_click_left && state . key_ctrl ) camera . manipulator_translate_in_plane ( p1 - p0 ) ; if ( state . mouse_click_right ) camera . manipulator_scale_distance_to_center ( ( p1 - p0 ) . y ) ; } user . mouse_prev = p1 ; }
Function called every time the mouse is moved
Function called every time the mouse is moved
// Handle camera rotation