Apply camera changes provided by Jesse Smith to have v0.6 camera option.

Feel free to fix any C++ style issues, this saves you fighting with patch or
can be undone quickly by reverting this single commit.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7739 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
mbjornstk 2011-02-20 05:11:26 +00:00
parent 915a9d9864
commit b8a0ab32b4
4 changed files with 55 additions and 2 deletions

View File

@ -360,6 +360,9 @@ namespace UserConfigParams
PARAM_DEFAULT( IntUserConfigParam(0, "reverse_look_threshold",
"If the kart is driving backwards faster than this value,\n"
"switch automatically to reverse camera (set to 0 to disable).") );
PARAM_PREFIX IntUserConfigParam m_camera_style
PARAM_DEFAULT( IntUserConfigParam(1, "camera_style", "Camera Style") );
PARAM_PREFIX StringUserConfigParam m_item_style
PARAM_DEFAULT( StringUserConfigParam("items", "item_style", "Name of the .items file to use.") );

View File

@ -62,6 +62,13 @@ Camera::Camera(int camera_index, const Kart* kart)
m_position_speed = 8.0f;
m_target_speed = 10.0f;
m_rotation_range = 0.4f;
// TODO: Make this per user too if the one above goes that way.
switch(UserConfigParams::m_camera_style)
{
case 1: m_camera_style = CS_CLASSIC; break;
case 0:
default: m_camera_style = CS_MODERN; break;
}
reset();
} // Camera
@ -339,8 +346,36 @@ void Camera::update(float dt)
{
case CM_NORMAL:
{
computeNormalCameraPosition(&wanted_position, &wanted_target);
smoothMoveCamera(dt, wanted_position, wanted_target);
switch (m_camera_style)
{
// 0.7 flexible link
case CS_MODERN:
{
computeNormalCameraPosition(&wanted_position, &wanted_target);
smoothMoveCamera(dt, wanted_position, wanted_target);
break;
}
// More like the 0.6 STK way
case CS_CLASSIC:
{
// wanted_target.setY(wanted_target.getY()+ 0.75f);
wanted_target.setY(wanted_target.getY()+ 0.30f);
float angle_around = m_kart->getHeading();
float angle_up = m_kart->getKartProperties()->getCameraBackwardUpAngle()
- m_kart->getPitch() ;
angle_around += 3.14; // face forward
wanted_position.setX( sin(angle_around));
wanted_position.setY( sin(angle_up) );
wanted_position.setZ( cos(angle_around));
wanted_position *= m_distance * 1.5f;
wanted_position += wanted_target;
smoothMoveCamera(dt, wanted_position, wanted_target);
m_camera->setPosition(wanted_position.toIrrVector());
m_camera->setTarget(wanted_target.toIrrVector());
break;
}
}
break;
}
case CM_FALLING:

View File

@ -51,6 +51,11 @@ public:
CM_FALLING
};
enum Style {
CS_MODERN, //!< Flexible link between kart and camera
CS_CLASSIC, //!< Fixed position style, like STK v0.6
};
private:
/** The camera scene node. */
scene::ICameraSceneNode *m_camera;
@ -97,6 +102,10 @@ private:
/** Velocity of the target of the camera, only used for end camera. */
core::vector3df m_target_velocity;
/* Whether we should use the pre-0.7 camera style or the
* modern style. Should default to modern. */
Style m_camera_style;
/** A class that stores information about the different end cameras
* which can be specified in the scene.xml file. */

View File

@ -247,6 +247,7 @@ void cmdLineHelp (char* invocation)
" --gfx=n Play other graphical effects like impact stars dance,\n"
" water animations or explosions (Enable: 1, Disable: 0).\n"
" --weather=n Show weather effects like rain or snow (0 or 1 as --gfx).\n"
" --camera-style=n Flexible (0) or hard like v0.6 (1) kart-camera link.\n"
// should not be used by unaware users:u
// " --profile Enable automatic driven profile mode for 20 seconds.\n"
// " --profile=n Enable automatic driven profile mode for n seconds.\n"
@ -489,6 +490,11 @@ int handleCmdLine(int argc, char **argv)
{
UserConfigParams::m_show_steering_animations = n;
}
else if ( sscanf(argv[i], "--camera-style=%d", &n) )
{
UserConfigParams::m_camera_style = n;
}
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
{
const KartProperties *prop = kart_properties_manager->getKart(argv[i+1]);