本文整理汇总了C++中CBaseCombatWeapon::GetIronsightPositionOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseCombatWeapon::GetIronsightPositionOffset方法的具体用法?C++ CBaseCombatWeapon::GetIronsightPositionOffset怎么用?C++ CBaseCombatWeapon::GetIronsightPositionOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseCombatWeapon
的用法示例。
在下文中一共展示了CBaseCombatWeapon::GetIronsightPositionOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcIronsights
void CBaseViewModel::CalcIronsights( Vector &pos, QAngle &ang )
{
CBaseCombatWeapon *pWeapon = GetOwningWeapon();
if (!pWeapon)
return;
//get delta time for interpolation
float delta = (gpGlobals->curtime - pWeapon->m_flIronsightedTime) * 2.5f; //modify this value to adjust how fast the interpolation is
float exp = (pWeapon->IsIronsighted()) ?
(delta > 1.0f) ? 1.0f : delta : //normal blending
(delta > 1.0f) ? 0.0f : 1.0f - delta; //reverse interpolation
if (exp <= 0.001f) //fully not ironsighted; save performance
return;
Vector newPos = pos;
QAngle newAng = ang;
Vector vForward, vRight, vUp, vOffset;
AngleVectors(newAng, &vForward, &vRight, &vUp);
vOffset = pWeapon->GetIronsightPositionOffset();
newPos += vForward * vOffset.x;
newPos += vRight * vOffset.y;
newPos += vUp * vOffset.z;
newAng += pWeapon->GetIronsightAngleOffset();
//fov is handled by CBaseCombatWeapon
pos += (newPos - pos) * exp;
ang += (newAng - ang) * exp;
}
示例2: CalcIronsights
//BG2 -Added for Iron Sights Testing. Credits to Jorg for the code. -HairyPotter
void CBaseViewModel::CalcIronsights( Vector &pos, QAngle &ang )
{
//CBaseCombatWeapon *pWeapon = GetOwningWeapon();
CBaseCombatWeapon *pWeapon = m_hWeapon.Get();
if ( !pWeapon )
return;
//get delta time for interpolation
float time = pWeapon->IsIronsighted() ? IRONSIGHTS_ANGLE_IN_TIME : IRONSIGHTS_ANGLE_OUT_TIME;
float delta( ( gpGlobals->curtime - pWeapon->m_flIronsightedTime ) / time );
float exp = ( pWeapon->IsIronsighted() ) ?
( delta > 1.0f ) ? 1.0f : delta : //normal blending
( delta > 1.0f ) ? 0.0f : 1.0f - delta; //reverse interpolation
if( exp <= 0.0f ) //fully not ironsighted; save performance
return;
if( exp > 1.0f )
exp = 1.0f;
Vector newPos = pos;
QAngle newAng = ang;
Vector vForward, vRight, vUp, vOffset;
AngleVectors( newAng, &vForward, &vRight, &vUp );
vOffset = pWeapon->GetIronsightPositionOffset();
newPos += vForward * vOffset.x;
newPos += vRight * vOffset.y;
newPos += vUp * vOffset.z;
newAng += pWeapon->GetIronsightAngleOffset(); //This also handles the pitch...
//fov is handled by CBaseCombatWeapon
pos += ( newPos - pos ) * exp;
ang += ( newAng - ang ) * exp;
}