Fixed pitch and roll of items (esp. chewing gums).

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4989 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-03-12 12:21:00 +00:00
parent 37b842e4c0
commit 9889050ce2

View File

@ -53,18 +53,18 @@ void Vec3::degreeToRad()
*/
void Vec3::setPitchRoll(const Vec3 &normal)
{
const float X =-sin(m_x);
const float Y = cos(m_x);
const float X = sin(m_x);
const float Z = cos(m_x);
// Compute the angle between the normal of the plane and the line to
// (x,y,0). (x,y,0) is normalised, so are the coordinates of the plane,
// simplifying the computation of the scalar product.
float pitch = ( normal.getX()*X + normal.getZ()*Y ); // use ( x,y,0)
float roll = (-normal.getX()*Y + normal.getZ()*X ); // use (-y,x,0)
float pitch = ( normal.getX()*X + normal.getZ()*Z ); // use ( x,0,z)
float roll = (-normal.getX()*Z + normal.getZ()*X ); // use (-z,0,x)
// The actual angle computed above is between the normal and the (x,y,0)
// line, so to compute the actual angles 90 degrees must be subtracted.
m_y = acosf(pitch) - NINETY_DEGREE_RAD;
m_z = acosf(roll) - NINETY_DEGREE_RAD;
m_z =-acosf(roll) + NINETY_DEGREE_RAD;
} // setPitchRoll
// ----------------------------------------------------------------------------