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


C++ CBaseCombatWeapon::GetIronsightPositionOffset方法代码示例

本文整理汇总了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;
}
开发者ID:SCell555,项目名称:hl2-asw-port,代码行数:32,代码来源:baseviewmodel_shared.cpp

示例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;
}
开发者ID:newroob,项目名称:bg2-2007,代码行数:38,代码来源:baseviewmodel_shared.cpp


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