Remove camera tilting in flying mode.

This commit is contained in:
hiker
2014-03-04 16:56:03 +11:00
parent 3e478265bc
commit f549b729df
3 changed files with 22 additions and 9 deletions

View File

@@ -28,6 +28,7 @@
#include "io/xml_node.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/explosion_animation.hpp"
#include "karts/kart.hpp"
#include "karts/kart_properties.hpp"
#include "karts/skidding.hpp"
#include "modes/world.hpp"
@@ -548,12 +549,19 @@ void Camera::positionCamera(float dt, float above_kart, float cam_angle,
wanted_target - m_camera->getPosition());
}
}
// Rotate the up vector (0,1,0) by the rotation ... which is just column 1
Vec3 up = m_kart->getTrans().getBasis().getColumn(1);
float f = 0.04f; // weight for new up vector to reduce shaking
m_camera->setUpVector( f * up.toIrrVector() +
(1.0f-f) * m_camera->getUpVector() );
Kart *kart = dynamic_cast<Kart*>(m_kart);
if (kart && !kart->isFlying())
{
// Rotate the up vector (0,1,0) by the rotation ... which is just column 1
Vec3 up = m_kart->getTrans().getBasis().getColumn(1);
float f = 0.04f; // weight for new up vector to reduce shaking
f = 0;
m_camera->setUpVector(f * up.toIrrVector() +
(1.0f - f) * m_camera->getUpVector());
} // kart && !flying
else
m_camera->setUpVector(core::vector3df(0, 1, 0));
} // positionCamera
// ----------------------------------------------------------------------------

View File

@@ -424,6 +424,9 @@ public:
TerrainInfo *getTerrainInfo() { return m_terrain_info; }
// ------------------------------------------------------------------------
virtual void setOnScreenText(const wchar_t *text);
// ------------------------------------------------------------------------
/** For debugging only: check if a kart is flying. */
bool isFlying() const { return m_flying; }
}; // Kart

View File

@@ -105,17 +105,19 @@ void Moveable::flyUp()
{
m_body->setGravity(btVector3(0.0, 8.0, 0.0));
m_body->applyCentralImpulse(btVector3(0.0, 100.0, 0.0));
}
} // flyUp
// ----------------------------------------------------------------------------
void Moveable::flyDown()
{
m_body->applyCentralImpulse(btVector3(0.0, -100.0, 0.0));
}
} // flyDown
// ----------------------------------------------------------------------------
void Moveable::stopFlying()
{
m_body->setGravity(btVector3(0.0, -World::getWorld()->getTrack()->getGravity(), 0.0));
}
} // stopFlying
//-----------------------------------------------------------------------------
/** Updates the current position and rotation from the corresponding physics