From: <mbj...@us...> - 2011-02-20 05:11:32
|
Revision: 7739 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7739&view=rev Author: mbjornstk Date: 2011-02-20 05:11:26 +0000 (Sun, 20 Feb 2011) Log Message: ----------- 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. Modified Paths: -------------- main/trunk/src/config/user_config.hpp main/trunk/src/graphics/camera.cpp main/trunk/src/graphics/camera.hpp main/trunk/src/main.cpp Modified: main/trunk/src/config/user_config.hpp =================================================================== --- main/trunk/src/config/user_config.hpp 2011-02-19 11:44:44 UTC (rev 7738) +++ main/trunk/src/config/user_config.hpp 2011-02-20 05:11:26 UTC (rev 7739) @@ -360,6 +360,9 @@ 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.") ); Modified: main/trunk/src/graphics/camera.cpp =================================================================== --- main/trunk/src/graphics/camera.cpp 2011-02-19 11:44:44 UTC (rev 7738) +++ main/trunk/src/graphics/camera.cpp 2011-02-20 05:11:26 UTC (rev 7739) @@ -62,6 +62,13 @@ 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 @@ { 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: Modified: main/trunk/src/graphics/camera.hpp =================================================================== --- main/trunk/src/graphics/camera.hpp 2011-02-19 11:44:44 UTC (rev 7738) +++ main/trunk/src/graphics/camera.hpp 2011-02-20 05:11:26 UTC (rev 7739) @@ -51,6 +51,11 @@ 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 @@ /** 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. */ Modified: main/trunk/src/main.cpp =================================================================== --- main/trunk/src/main.cpp 2011-02-19 11:44:44 UTC (rev 7738) +++ main/trunk/src/main.cpp 2011-02-20 05:11:26 UTC (rev 7739) @@ -247,6 +247,7 @@ " --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 @@ { 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]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |