Removed the camera jump which happens on some tracks (e.g. snow
mountain) at the start of a race. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@3088 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0c5aae7b1b
commit
d49f009213
@ -149,12 +149,25 @@ Camera::Mode Camera::getMode()
|
||||
void Camera::reset()
|
||||
{
|
||||
setMode(CM_NORMAL);
|
||||
m_last_pitch = 0.0f;
|
||||
m_xyz = m_kart->getXYZ();
|
||||
m_hpr = Vec3(0,0,0);
|
||||
sound_manager->positionListener(m_xyz, m_xyz);
|
||||
// m_xyz etc are set when the worlds has computed the right starting
|
||||
// position of all karts and calls setInitialTransform for each camera.
|
||||
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Saves the current kart position as initial starting position for the
|
||||
* camera.
|
||||
*/
|
||||
void Camera::setInitialTransform()
|
||||
{
|
||||
btTransform t = m_kart->getBody()->getCenterOfMassTransform();
|
||||
m_xyz = t.getOrigin();
|
||||
Coord c(t);
|
||||
m_hpr = c.getHPR();
|
||||
m_last_pitch = m_hpr.getPitch();
|
||||
sound_manager->positionListener(m_xyz, m_xyz);
|
||||
} // updateKartPosition
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Camera::update (float dt)
|
||||
{
|
||||
@ -202,7 +215,6 @@ void Camera::update (float dt)
|
||||
// Set the camera rotation
|
||||
// -----------------------
|
||||
float sign = reverse ? 1.0f : -1.0f;
|
||||
//const int num_players = race_manager->getNumLocalPlayers();
|
||||
float pitch;
|
||||
if(m_mode!=CM_CLOSEUP)
|
||||
pitch = race_manager->getNumLocalPlayers()>1 ? sign * DEGREE_TO_RAD(10.0f)
|
||||
|
@ -19,8 +19,8 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_CAMERA_H
|
||||
#define HEADER_CAMERA_H
|
||||
#ifndef HEADER_CAMERA_HPP
|
||||
#define HEADER_CAMERA_HPP
|
||||
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
@ -54,16 +54,17 @@ protected:
|
||||
float m_final_time; // time when final camera mode started
|
||||
|
||||
private:
|
||||
void finalCamera (float dt); // handle the final camera
|
||||
void finalCamera (float dt); // handle the final camera
|
||||
public:
|
||||
Camera (int camera_index, const Kart* kart);
|
||||
~Camera ();
|
||||
void setMode (Mode mode_); /** Set the camera to the given mode */
|
||||
Camera (int camera_index, const Kart* kart);
|
||||
~Camera ();
|
||||
void setMode (Mode mode_); /** Set the camera to the given mode */
|
||||
Mode getMode();
|
||||
void setScreenPosition(int pos);
|
||||
void reset ();
|
||||
void update (float dt);
|
||||
void apply ();
|
||||
void setScreenPosition (int pos);
|
||||
void reset ();
|
||||
void setInitialTransform();
|
||||
void update (float dt);
|
||||
void apply ();
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
@ -88,11 +88,11 @@ void Scene::remove(ssgEntity *kid)
|
||||
//-----------------------------------------------------------------------------
|
||||
void Scene::reset()
|
||||
{
|
||||
for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
|
||||
{
|
||||
(*i)->reset();
|
||||
}
|
||||
/** Note: the cameras are reset in player_kart. This is necessary since
|
||||
* the camera needs the correct starting position and rotation of the
|
||||
* kart (to avoid that the camera jumps in the first frame). */
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Scene::draw(float dt)
|
||||
{
|
||||
|
@ -260,7 +260,8 @@ void World::resetAllKarts()
|
||||
// so that the karts can visualise the suspension.
|
||||
for ( Karts::iterator i=m_kart.begin(); i!=m_kart.end(); i++)
|
||||
(*i)->setSuspensionLength();
|
||||
|
||||
for(unsigned int i=0; i<m_player_karts.size(); i++)
|
||||
m_player_karts[i]->getCamera()->setInitialTransform();
|
||||
} // resetAllKarts
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user