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()
|
void Camera::reset()
|
||||||
{
|
{
|
||||||
setMode(CM_NORMAL);
|
setMode(CM_NORMAL);
|
||||||
m_last_pitch = 0.0f;
|
// m_xyz etc are set when the worlds has computed the right starting
|
||||||
m_xyz = m_kart->getXYZ();
|
// position of all karts and calls setInitialTransform for each camera.
|
||||||
m_hpr = Vec3(0,0,0);
|
|
||||||
sound_manager->positionListener(m_xyz, m_xyz);
|
|
||||||
} // reset
|
} // 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)
|
void Camera::update (float dt)
|
||||||
{
|
{
|
||||||
@ -202,7 +215,6 @@ void Camera::update (float dt)
|
|||||||
// Set the camera rotation
|
// Set the camera rotation
|
||||||
// -----------------------
|
// -----------------------
|
||||||
float sign = reverse ? 1.0f : -1.0f;
|
float sign = reverse ? 1.0f : -1.0f;
|
||||||
//const int num_players = race_manager->getNumLocalPlayers();
|
|
||||||
float pitch;
|
float pitch;
|
||||||
if(m_mode!=CM_CLOSEUP)
|
if(m_mode!=CM_CLOSEUP)
|
||||||
pitch = race_manager->getNumLocalPlayers()>1 ? sign * DEGREE_TO_RAD(10.0f)
|
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
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifndef HEADER_CAMERA_H
|
#ifndef HEADER_CAMERA_HPP
|
||||||
#define HEADER_CAMERA_H
|
#define HEADER_CAMERA_HPP
|
||||||
|
|
||||||
#include "utils/vec3.hpp"
|
#include "utils/vec3.hpp"
|
||||||
|
|
||||||
@ -62,6 +62,7 @@ public:
|
|||||||
Mode getMode();
|
Mode getMode();
|
||||||
void setScreenPosition (int pos);
|
void setScreenPosition (int pos);
|
||||||
void reset ();
|
void reset ();
|
||||||
|
void setInitialTransform();
|
||||||
void update (float dt);
|
void update (float dt);
|
||||||
void apply ();
|
void apply ();
|
||||||
} ;
|
} ;
|
||||||
|
@ -88,11 +88,11 @@ void Scene::remove(ssgEntity *kid)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Scene::reset()
|
void Scene::reset()
|
||||||
{
|
{
|
||||||
for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
|
/** Note: the cameras are reset in player_kart. This is necessary since
|
||||||
{
|
* the camera needs the correct starting position and rotation of the
|
||||||
(*i)->reset();
|
* kart (to avoid that the camera jumps in the first frame). */
|
||||||
}
|
|
||||||
} // reset
|
} // reset
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Scene::draw(float dt)
|
void Scene::draw(float dt)
|
||||||
{
|
{
|
||||||
|
@ -260,7 +260,8 @@ void World::resetAllKarts()
|
|||||||
// so that the karts can visualise the suspension.
|
// so that the karts can visualise the suspension.
|
||||||
for ( Karts::iterator i=m_kart.begin(); i!=m_kart.end(); i++)
|
for ( Karts::iterator i=m_kart.begin(); i!=m_kart.end(); i++)
|
||||||
(*i)->setSuspensionLength();
|
(*i)->setSuspensionLength();
|
||||||
|
for(unsigned int i=0; i<m_player_karts.size(); i++)
|
||||||
|
m_player_karts[i]->getCamera()->setInitialTransform();
|
||||||
} // resetAllKarts
|
} // resetAllKarts
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user