add user option (config.xml) to substitute look back camera by a camera that follows the ball in soccer mode

This commit is contained in:
luffah 2020-04-16 18:10:20 +02:00
parent 2ca815ace4
commit 914f1a6a77
2 changed files with 10 additions and 2 deletions

View File

@ -976,6 +976,11 @@ namespace UserConfigParams
PARAM_DEFAULT( FloatUserConfigParam(40.0, "camera-angle", &m_spectator,
"Angle between ground, kart and camera.") );
// ---- Special settings for soccer mode
PARAM_PREFIX BoolUserConfigParam m_reverse_look_use_soccer_cam
PARAM_DEFAULT( BoolUserConfigParam(false, "reverse-look-use-soccer-cam",
"Use ball camera in soccer mode, instead of reverse") );
// ---- Handicap
PARAM_PREFIX GroupUserConfigParam m_handicap
PARAM_DEFAULT( GroupUserConfigParam("Handicap",

View File

@ -354,7 +354,10 @@ void CameraNormal::positionCamera(float dt, float above_kart, float cam_angle,
float tan_up = tanf(cam_angle);
switch(getMode())
Camera::Mode mode = getMode();
if (UserConfigParams::m_reverse_look_use_soccer_cam && getMode() == CM_REVERSE) mode=CM_SPECTATOR_SOCCER;
switch(mode)
{
case CM_SPECTATOR_SOCCER:
{
@ -363,7 +366,7 @@ void CameraNormal::positionCamera(float dt, float above_kart, float cam_angle,
{
Vec3 ball_pos = soccer_world->getBallPosition();
Vec3 to_target=(ball_pos-wanted_target);
wanted_position = wanted_target + Vec3(0, fabsf(distance)*tan_up+above_kart, 0) + (to_target.normalize() * distance);
wanted_position = wanted_target + Vec3(0, fabsf(distance)*tan_up+above_kart, 0) + (to_target.normalize() * distance * (getMode() == CM_REVERSE ? -1:1));
m_camera->setPosition(wanted_position.toIrrVector());
m_camera->setTarget(wanted_target.toIrrVector());
return;