当前位置: 首页>>代码示例>>C++>>正文


C++ Orientation::GetBackward方法代码示例

本文整理汇总了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);
		}
    }
}
开发者ID:FreeAllegiance,项目名称:Allegiance-R7-With-R4-Engine,代码行数:67,代码来源:fsship.cpp


注:本文中的Orientation::GetBackward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。