本文整理汇总了C++中Orientation::GetBackward方法的典型用法代码示例。如果您正苦于以下问题:C++ Orientation::GetBackward方法的具体用法?C++ Orientation::GetBackward怎么用?C++ Orientation::GetBackward使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orientation
的用法示例。
在下文中一共展示了Orientation::GetBackward方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HitWarp
void CFSShip::HitWarp(IwarpIGC * pwarp)
{
//Ignore jumps that happen too closely together
if (m_warpState == warpReady)
{
// Andon - Added check for aleph mass limits
if (m_pShip->GetMass() <= pwarp->MassLimit() || !IsPlayer() && pwarp->MassLimit() > 0 || pwarp->MassLimit() < 0)
{
if (IsPlayer())
{
m_warpState = warpNoUpdate;
}
IwarpIGC * pwarpDest = pwarp->GetDestination();
assert (pwarpDest);
IclusterIGC * pclusterDest = pwarpDest->GetCluster();
ShipStatusWarped(pwarp);
Orientation alephOrientation = pwarpDest->GetOrientation();
const Vector& v = m_pShip->GetVelocity();
float speed2 = v.LengthSquared();
float speed = float(sqrt(speed2));
if (speed2 > 0)
{
float error;
{
//How close is the ship coming to the center of the warp?
Vector dp = pwarp->GetPosition() - m_pShip->GetPosition();
float t = (dp * v) / speed2;
float d = (dp - t * v).LengthSquared();
float r = pwarp->GetRadius();
error = (d / (r*r)) + 0.125f; //Error ranges from 0.125 to 1.125
// yp: to prevent 'spin of death' in massive ships.
// This works and is explained in that the more massive the ship the less effect going through the aleph should have
// on its rotational velocity. The massive amount of inertia should decrease changes in rotational velocity.
if(m_pShip->GetMass() > 300.0f)
{
error = error * (300.0f / m_pShip->GetMass()); // the greater the mass is above 750 the less error will be applied.
}
// yp end
}
alephOrientation.Pitch(random(-error, error));
alephOrientation.Yaw(random(-error, error));
m_pShip->SetCurrentTurnRate(c_axisRoll,
m_pShip->GetCurrentTurnRate(c_axisRoll) +
random(pi * 0.5f * error, pi * 1.5f * error)); //Must be less than 2.0 * pi
}
m_pShip->SetOrientation(alephOrientation);
const Vector& backward = alephOrientation.GetBackward();
speed = -(speed + pwarp->GetMission()->GetFloatConstant(c_fcidExitWarpSpeed));
m_pShip->SetVelocity(backward * speed);
m_pShip->SetPosition(pwarpDest->GetPosition() +
(alephOrientation.GetUp() * random(2.0f, 5.0f)) +
(alephOrientation.GetRight() * random(2.0f, 5.0f)) -
(m_pShip->GetRadius() + 5.0f) * backward);
GetIGCShip()->SetCluster(pclusterDest);
}
}
}