Merge branch 'fpsCam'
This commit is contained in:
commit
3d7518b1d0
@ -652,11 +652,38 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( BoolUserConfigParam(
|
||||
CONSOLE_DEFAULT, "log_errors", "Enable logging to console.") );
|
||||
|
||||
// ---- Camera
|
||||
PARAM_PREFIX GroupUserConfigParam m_camera
|
||||
PARAM_DEFAULT( GroupUserConfigParam("camera",
|
||||
"(Debug) camera settings.") );
|
||||
|
||||
PARAM_PREFIX IntUserConfigParam m_reverse_look_threshold
|
||||
PARAM_DEFAULT( IntUserConfigParam(0, "reverse_look_threshold",
|
||||
&m_camera,
|
||||
"If the kart is driving backwards faster than this value,\n"
|
||||
"switch automatically to reverse camera (set to 0 to disable).") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_direction_speed
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.003f, "fspcam_rotation_speed",
|
||||
&m_camera,
|
||||
"How fast the first person camera's direction speed changes when\n"
|
||||
"moving the mouse (means acceleration).") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_smooth_direction_max_speed
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.04f, "fspcam_smooth_rotation_max_speed",
|
||||
&m_camera,
|
||||
"How fast the first person camera's direction can change.") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_angular_velocity
|
||||
PARAM_DEFAULT( FloatUserConfigParam(0.02f, "fspcam_angular_velocity",
|
||||
&m_camera,
|
||||
"How fast the first person camera's rotation speed changes.") );
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_fspcam_max_angular_velocity
|
||||
PARAM_DEFAULT( FloatUserConfigParam(1.0f, "fspcam_max_angular_velocity",
|
||||
&m_camera,
|
||||
"How fast the first person camera can rotate.") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_item_style
|
||||
PARAM_DEFAULT( StringUserConfigParam("items", "item_style",
|
||||
"Name of the .items file to use.") );
|
||||
@ -672,6 +699,7 @@ namespace UserConfigParams
|
||||
PARAM_DEFAULT( StringUserConfigParam("Peach.stkskin", "skin_file",
|
||||
"Name of the skin to use") );
|
||||
|
||||
// ---- Handicap
|
||||
PARAM_PREFIX GroupUserConfigParam m_handicap
|
||||
PARAM_DEFAULT( GroupUserConfigParam("Handicap",
|
||||
"Everything related to handicaps.") );
|
||||
|
@ -90,6 +90,7 @@ Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
|
||||
m_target_velocity = core::vector3df(0, 0, 0);
|
||||
m_target_direction = core::vector3df(0, 0, 1);
|
||||
m_target_up_vector = core::vector3df(0, 1, 0);
|
||||
m_direction_velocity = core::vector3df(0, 0, 0);
|
||||
m_angular_velocity = 0;
|
||||
m_target_angular_velocity = 0;
|
||||
m_max_velocity = 15;
|
||||
@ -500,13 +501,13 @@ void Camera::update(float dt)
|
||||
// Angular velocity
|
||||
if (m_angular_velocity < m_target_angular_velocity)
|
||||
{
|
||||
m_angular_velocity += 0.02f;
|
||||
m_angular_velocity += UserConfigParams::m_fspcam_angular_velocity;
|
||||
if (m_angular_velocity > m_target_angular_velocity)
|
||||
m_angular_velocity = m_target_angular_velocity;
|
||||
}
|
||||
else if (m_angular_velocity > m_target_angular_velocity)
|
||||
{
|
||||
m_angular_velocity -= 0.02f;
|
||||
m_angular_velocity -= UserConfigParams::m_fspcam_angular_velocity;
|
||||
if (m_angular_velocity < m_target_angular_velocity)
|
||||
m_angular_velocity = m_target_angular_velocity;
|
||||
}
|
||||
@ -524,17 +525,25 @@ void Camera::update(float dt)
|
||||
diff = m_target_direction - direction;
|
||||
if (diff.X != 0 || diff.Y != 0 || diff.Z != 0)
|
||||
{
|
||||
if (diff.getLengthSQ() > 0.02f * 0.02f)
|
||||
diff.setLength(0.02f);
|
||||
direction += diff;
|
||||
diff.setLength(UserConfigParams::m_fspcam_direction_speed);
|
||||
m_direction_velocity += diff;
|
||||
if (m_direction_velocity.getLengthSQ() >
|
||||
UserConfigParams::m_fspcam_smooth_direction_max_speed *
|
||||
UserConfigParams::m_fspcam_smooth_direction_max_speed)
|
||||
m_direction_velocity.setLength(
|
||||
UserConfigParams::m_fspcam_smooth_direction_max_speed);
|
||||
direction += m_direction_velocity;
|
||||
m_target_direction = direction;
|
||||
}
|
||||
|
||||
// Camera rotation
|
||||
diff = m_target_up_vector - up;
|
||||
if (diff.X != 0 || diff.Y != 0 || diff.Z != 0)
|
||||
{
|
||||
if (diff.getLengthSQ() > 0.02f * 0.02f)
|
||||
diff.setLength(0.02f);
|
||||
if (diff.getLengthSQ() >
|
||||
UserConfigParams::m_fspcam_angular_velocity *
|
||||
UserConfigParams::m_fspcam_angular_velocity)
|
||||
diff.setLength(UserConfigParams::m_fspcam_angular_velocity);
|
||||
up += diff;
|
||||
}
|
||||
}
|
||||
|
@ -132,6 +132,9 @@ private:
|
||||
/** The target direction for the camera, only used for the first person camera. */
|
||||
core::vector3df m_target_direction;
|
||||
|
||||
/** The speed at which the direction changes, only used for the first person camera. */
|
||||
core::vector3df m_direction_velocity;
|
||||
|
||||
/** The up vector the camera should have, only used for the first person camera. */
|
||||
core::vector3df m_target_up_vector;
|
||||
|
||||
|
@ -214,7 +214,8 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ? 1 : 0);
|
||||
active_cam->setAngularVelocity(value ?
|
||||
UserConfigParams::m_fspcam_max_angular_velocity : 0);
|
||||
break;
|
||||
}
|
||||
case KEY_KEY_E:
|
||||
@ -223,7 +224,8 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
UserConfigParams::m_camera_debug != 3) break;
|
||||
|
||||
Camera *active_cam = Camera::getActiveCamera();
|
||||
active_cam->setAngularVelocity(value ? -1 : 0);
|
||||
active_cam->setAngularVelocity(value ?
|
||||
-UserConfigParams::m_fspcam_max_angular_velocity : 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -965,12 +967,13 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
core::vector2df screen_size = irr_driver->getCurrentScreenSize();
|
||||
int mid_x = (int) screen_size.X / 2;
|
||||
int mid_y = (int) screen_size.Y / 2;
|
||||
//const int wheel = event.MouseInput.Wheel;
|
||||
// Relative mouse movement
|
||||
int diff_x = event.MouseInput.X - m_mouse_val_x;
|
||||
int diff_y = event.MouseInput.Y - m_mouse_val_y;
|
||||
float mouse_x = ((float) diff_x) / 150;
|
||||
float mouse_y = ((float) diff_y) / -150;
|
||||
float mouse_x = ((float) diff_x) *
|
||||
UserConfigParams::m_fspcam_direction_speed;
|
||||
float mouse_y = ((float) diff_y) *
|
||||
-UserConfigParams::m_fspcam_direction_speed;
|
||||
// No movement the first time it's used
|
||||
// At the moment there's also a hard limit because the mouse
|
||||
// gets reset to the middle of the screen and sometimes there
|
||||
|
Loading…
Reference in New Issue
Block a user