24 const unsigned int mouse_key_bit)
28 assert(camera_ptr_ !=
nullptr);
31 if ((mouse_key_bit & MOUSE_INPUT_LEFT) && (mouse_key_bit & MOUSE_INPUT_RIGHT))
33 if (abs(cursor_dif_x) > abs(cursor_dif_y))
39 cursor_dif_x * kCameraMoveSpeed * -1, { 0, 0, 1 });
41 Quaternion res = camera_ptr_->GetCameraQuat() * move_quaternion_x;
45 camera_ptr_->SetCameraQuat(res);
51 cursor_dif_y * kCameraMoveSpeed * -1, { 0, 1, 0 });
53 Quaternion res = camera_ptr_->GetCameraQuat() * move_quaternion_y;
57 camera_ptr_->SetCameraQuat(res);
60 else if (mouse_key_bit & MOUSE_INPUT_MIDDLE)
65 if (abs(cursor_dif_x) > 0)
71 cursor_dif_x * kCameraMoveSpeed * -1, { 0, 0, 1 });
73 Quaternion res = camera_ptr_->GetCameraQuat() * move_quaternion_x;
77 camera_ptr_->SetCameraQuat(res);
80 if (abs(cursor_dif_y) > 0)
84 cursor_dif_y * kCameraMoveSpeed * -1, { 0, 1, 0 });
86 Quaternion res = camera_ptr_->GetCameraQuat() * move_quaternion_y;
90 camera_ptr_->SetCameraQuat(res);
93 else if (mouse_key_bit & MOUSE_INPUT_LEFT)
96 const int mouse_move =
97 abs(cursor_dif_x) > abs(cursor_dif_y) ? cursor_dif_x : cursor_dif_y;
102 mouse_move * kCameraMoveSpeed * -1.0f, { 1, 0, 0 });
105 (camera_ptr_->GetCameraQuat() * move_quaternion).GetNormalized();
107 camera_ptr_->SetCameraQuat(res);
111 mouse_key_bit & MOUSE_INPUT_RIGHT &&
112 Squared(cursor_dif_x) + Squared(cursor_dif_y) > Squared(kMouseMoveMargin))
115 if (camera_ptr_->GetCameraViewMode() !=
119 camera_ptr_->SetCameraViewMode(
124 Vector3 move_vec_x = { 0, 0, 0 };
126 if (abs(cursor_dif_x) > 0)
128 move_vec_x = { 0, cursor_dif_x * kCameraTargetMoveSpeed * -1, 0 };
130 move_vec_x =
RotateVector3(move_vec_x, camera_ptr_->GetCameraQuat());
133 Vector3 move_vec_y = { 0, 0, 0 };
135 if (abs(cursor_dif_y) > 0)
137 move_vec_y = { 0, 0, cursor_dif_y * kCameraTargetMoveSpeed };
139 move_vec_y =
RotateVector3(move_vec_y, camera_ptr_->GetCameraQuat());
143 Vector3 now_target_pos = camera_ptr_->GetFreeTargetPos();
145 now_target_pos = now_target_pos + move_vec_x + move_vec_y;
147 camera_ptr_->SetFreeTargetPos(now_target_pos);