本文整理汇总了C++中UTIL_VecToYaw函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_VecToYaw函数的具体用法?C++ UTIL_VecToYaw怎么用?C++ UTIL_VecToYaw使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UTIL_VecToYaw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UTIL_VecToYaw
bool CNPC_Infected::OverrideMoveFacing( const AILocalMoveGoal_t &move, float flInterval )
{
// required movement direction
float flMoveYaw = UTIL_VecToYaw( move.dir );
// FIXME: move this up to navigator so that path goals can ignore these overrides.
Vector dir;
float flInfluence = GetFacingDirection( dir );
dir = move.facing * (1 - flInfluence) + dir * flInfluence;
VectorNormalize( dir );
// ideal facing direction
float idealYaw = UTIL_AngleMod( UTIL_VecToYaw( dir ) );
// FIXME: facing has important max velocity issues
GetMotor()->SetIdealYawAndUpdate( idealYaw );
// find movement direction to compensate for not being turned far enough
float flDiff = UTIL_AngleDiff( flMoveYaw, GetLocalAngles().y );
// Setup the 9-way blend parameters based on our speed and direction.
Vector2D vCurMovePose( 0, 0 );
vCurMovePose.x = cos( DEG2RAD( flDiff ) ) * 1.0f; //flPlaybackRate;
vCurMovePose.y = -sin( DEG2RAD( flDiff ) ) * 1.0f; //flPlaybackRate;
SetPoseParameter( gm_nMoveXPoseParam, vCurMovePose.x );
SetPoseParameter( gm_nMoveYPoseParam, vCurMovePose.y );
// ==== Update Lean pose parameters
if ( gm_nLeanYawPoseParam >= 0 )
{
float targetLean = GetPoseParameter( gm_nMoveYPoseParam ) * 30.0f;
float curLean = GetPoseParameter( gm_nLeanYawPoseParam );
if( curLean < targetLean )
curLean += MIN(fabs(targetLean-curLean), GetAnimTimeInterval()*12.0f); //was 15.0f
else
curLean -= MIN(fabs(targetLean-curLean), GetAnimTimeInterval()*12.0f); //was 15.0f
SetPoseParameter( gm_nLeanYawPoseParam, curLean );
}
if( gm_nLeanPitchPoseParam >= 0 )
{
float targetLean = GetPoseParameter( gm_nMoveXPoseParam ) * -20.0f; //was -30.0f
float curLean = GetPoseParameter( gm_nLeanPitchPoseParam );
if( curLean < targetLean )
curLean += MIN(fabs(targetLean-curLean), GetAnimTimeInterval()*10.0f); //was 15.0f
else
curLean -= MIN(fabs(targetLean-curLean), GetAnimTimeInterval()*10.0f); //was 15.0f
SetPoseParameter( gm_nLeanPitchPoseParam, curLean );
}
return true;
}
示例2: UTIL_VecToYaw
//-----------------------------------------------------------------------------
// Purpose: Draw box oriented to a Vector direction
//-----------------------------------------------------------------------------
void NDebugOverlay::BoxDirection(const Vector &origin, const Vector &mins, const Vector &maxs, const Vector &orientation, int r, int g, int b, int a, float duration)
{
// convert forward vector to angles
QAngle f_angles = vec3_angle;
f_angles.y = UTIL_VecToYaw( orientation );
BoxAngles( origin, mins, maxs, f_angles, r, g, b, a, duration );
}
示例3: UTIL_VecToYaw
void CAI_Motor::MoveFacing( const AILocalMoveGoal_t &move )
{
if ( GetOuter()->OverrideMoveFacing( move, GetMoveInterval() ) )
return;
// required movement direction
float flMoveYaw = UTIL_VecToYaw( move.dir );
int nSequence = GetSequence();
float fSequenceMoveYaw = GetSequenceMoveYaw( nSequence );
if ( fSequenceMoveYaw == NOMOTION )
{
fSequenceMoveYaw = 0;
}
if (!HasPoseParameter( nSequence, "move_yaw" ))
{
SetIdealYawAndUpdate( UTIL_AngleMod( flMoveYaw - fSequenceMoveYaw ) );
}
else
{
// FIXME: move this up to navigator so that path goals can ignore these overrides.
Vector dir;
float flInfluence = GetFacingDirection( dir );
dir = move.facing * (1 - flInfluence) + dir * flInfluence;
VectorNormalize( dir );
// ideal facing direction
float idealYaw = UTIL_AngleMod( UTIL_VecToYaw( dir ) );
// FIXME: facing has important max velocity issues
SetIdealYawAndUpdate( idealYaw );
// find movement direction to compensate for not being turned far enough
float flDiff = UTIL_AngleDiff( flMoveYaw, GetLocalAngles().y );
SetPoseParameter( "move_yaw", flDiff );
/*
if ((GetOuter()->m_debugOverlays & OVERLAY_NPC_SELECTED_BIT))
{
Msg( "move %.1f : diff %.1f : ideal %.1f\n", flMoveYaw, flDiff, m_IdealYaw );
}
*/
}
}
示例4: GetAbsOrigin
float CASW_Sentry_Top::GetYawTo(CBaseEntity* pEnt)
{
if (!pEnt)
return m_fDeployYaw;
Vector diff = pEnt->WorldSpaceCenter() - GetAbsOrigin();
if (diff.x == 0 && diff.y == 0 && diff.z == 0)
return m_fDeployYaw;
return UTIL_VecToYaw(diff);
}
示例5: UTIL_VecToYaw
//-----------------------------------------------------------------------------
// Purpose:
// Input : &vecTarget -
// Output : float
//-----------------------------------------------------------------------------
float CNPC_Bug_Warrior::CalcIdealYaw( const Vector &vecTarget )
{
//If we can see our enemy but not reach them, face them always
if ( ( GetEnemy() != NULL ) && ( HasCondition( COND_SEE_ENEMY ) && HasCondition( COND_ENEMY_UNREACHABLE ) ) )
{
return UTIL_VecToYaw ( GetEnemy()->GetAbsOrigin() - GetAbsOrigin() );
}
return BaseClass::CalcIdealYaw( vecTarget );
}
示例6: UTIL_VecToYaw
bool CASW_Jump_Trigger::ReasonableJump(CASW_Alien_Jumper *pJumper, int iJumpNum)
{
if (!pJumper)
return false;
if (m_bOneJumpPerAlien && pJumper->m_bTriggerJumped)
return false;
if (!pJumper->GetEnemy()) // let him jump if he has no enemy
return true;
if (!m_bCheckEnemyDirection) // let him jump if he doesn't care about the direction of his enemy
return true;
// if he does have an enemy, check it's in the direction of the jump
float fEnemyYaw = UTIL_VecToYaw(pJumper->GetEnemy()->GetAbsOrigin() - pJumper->GetAbsOrigin());
float fJumpYaw = UTIL_VecToYaw(m_vecJumpDestination[iJumpNum] - pJumper->GetAbsOrigin());
return fabs(UTIL_AngleDiff(fEnemyYaw, fJumpYaw)) < 90;
}
示例7: SetSolid
void CASW_Parasite::InfestColonist(CASW_Colonist* pColonist)
{
if (m_bDefanged || !pColonist) // no infesting if we've been defanged
return;
if (!IsOnFire()) // don't actually infest if we're on fire, since we'll die very shortly
pColonist->BecomeInfested(this);
// attach
int attachment = pColonist->LookupAttachment( "chest" );
if ( attachment )
{
//SetAbsAngles( GetOwnerEntity()->GetAbsAngles() );
SetSolid( SOLID_NONE );
SetMoveType( MOVETYPE_NONE );
QAngle current(0,0,0);
Vector diff = pColonist->GetAbsOrigin() - GetAbsOrigin();
float angle = UTIL_VecToYaw(diff);
angle -= pColonist->GetAbsAngles()[YAW]; // get the diff between our angle from the marine and the marine's facing;
current = GetAbsAngles();
SetParent( pColonist, attachment );
Vector vecPosition;
float fRaise = random->RandomFloat(0,20);
SetLocalOrigin( Vector( -fRaise * 0.2f, 0, fRaise ) );
SetLocalAngles( QAngle( 0, angle + asw_infest_angle.GetFloat(), 0 ) );
// play our infesting anim
if ( asw_parasite_inside.GetBool() )
{
SetActivity(ACT_RANGE_ATTACK2);
}
else
{
int iInfestAttack = LookupSequence("Infest_attack");
if (GetSequence() != iInfestAttack)
{
ResetSequence(iInfestAttack);
}
}
// don't do anymore thinking - need to think still to animate?
AddFlag( FL_NOTARGET );
SetThink( &CASW_Parasite::InfestThink );
SetTouch( NULL );
m_bInfesting = true;
}
else
{
FinishedInfesting();
}
}
示例8: GetEnemy
float CASW_Simple_Alien::GetIdealYaw()
{
if (m_bMoving)
{
if (m_iState == ASW_SIMPLE_ALIEN_ATTACKING && GetEnemy()
&& GetEnemy()->GetAbsOrigin().DistTo(GetAbsOrigin()) < GetFaceEnemyDistance())
{
return UTIL_VecToYaw(GetEnemy()->GetAbsOrigin() - GetAbsOrigin());
}
else
{
if (m_hMoveTarget.Get())
{
m_vecMoveTarget = m_hMoveTarget->GetAbsOrigin();
}
return UTIL_VecToYaw(m_vecMoveTarget - GetAbsOrigin());
}
}
return GetAbsAngles()[YAW];
}
示例9: GetPoseParameter
void CPropVehicleManhack::UpdateHead( void )
{
float yaw = GetPoseParameter( "head_yaw" );
float pitch = GetPoseParameter( "head_pitch" );
// If we should be watching our enemy, turn our head
CNPC_Manhack *pManhack=GetManhack();
if (pManhack != NULL)
{
Vector vehicleEyeOrigin;
QAngle vehicleEyeAngles;
GetAttachment( "vehicle_driver_eyes", vehicleEyeOrigin, vehicleEyeAngles );
// FIXME: cache this
Vector vBodyDir;
AngleVectors( vehicleEyeAngles, &vBodyDir );
Vector manhackDir = pManhack->GetAbsOrigin() - vehicleEyeOrigin;
VectorNormalize( manhackDir );
float angle = UTIL_VecToYaw( vBodyDir );
float angleDiff = UTIL_VecToYaw( manhackDir );
angleDiff = UTIL_AngleDiff( angleDiff, angle + yaw );
SetPoseParameter( "head_yaw", UTIL_Approach( yaw + angleDiff, yaw, 1 ) );
angle = UTIL_VecToPitch( vBodyDir );
angleDiff = UTIL_VecToPitch( manhackDir );
angleDiff = UTIL_AngleDiff( angleDiff, angle + pitch );
SetPoseParameter( "head_pitch", UTIL_Approach( pitch + angleDiff, pitch, 1 ) );
}
else
{
// Otherwise turn the head back to its normal position
SetPoseParameter( "head_yaw", UTIL_Approach( 0, yaw, 10 ) );
SetPoseParameter( "head_pitch", UTIL_Approach( 0, pitch, 10 ) );
}
}
示例10: if
bool CZombie::OnObstructingDoor( AILocalMoveGoal_t *pMoveGoal, CBaseDoor *pDoor, float distClear, AIMoveResult_t *pResult )
{
if ( BaseClass::OnObstructingDoor( pMoveGoal, pDoor, distClear, pResult ) )
{
if ( IsMoveBlocked( *pResult ) && pMoveGoal->directTrace.vHitNormal != vec3_origin )
{
m_hBlockingDoor = pDoor;
m_flDoorBashYaw = UTIL_VecToYaw( pMoveGoal->directTrace.vHitNormal * -1 );
}
return true;
}
return false;
}
示例11: Assert
//-----------------------------------------------------------------------------
// Purpose:
//
// Input : iSequence -
//
// Output : float -
//-----------------------------------------------------------------------------
float CAnimating::GetSequenceMoveYaw( int iSequence )
{
Vector vecReturn;
Assert( GetModelPtr() );
::GetSequenceLinearMotion( GetModelPtr(), iSequence, GetPoseParameterArray(), &vecReturn );
if (vecReturn.Length() > 0)
{
return UTIL_VecToYaw( vecReturn );
}
return NOMOTION;
}
示例12: switch
//-----------------------------------------------------------------------------
// Purpose:
//
//
// Output :
//-----------------------------------------------------------------------------
void CNPC_RollerDozer::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_ROLLERDOZER_CLEAR_DEBRIS:
if( gpGlobals->curtime > m_flWaitFinished )
{
m_hDebris = NULL;
m_flTimeDebrisSearch = gpGlobals->curtime;
TaskComplete();
}
else if( m_hDebris != NULL )
{
float yaw = UTIL_VecToYaw( m_hDebris->GetLocalOrigin() - GetLocalOrigin() );
Vector vecRight, vecForward;
AngleVectors( QAngle( 0, yaw, 0 ), &vecForward, &vecRight, NULL );
//Stop pushing if I'm going to push this object sideways or back towards the center of the cleanup area.
Vector vecCleanupDir = m_hDebris->GetLocalOrigin() - m_vecCleanupPoint;
VectorNormalize( vecCleanupDir );
if( DotProduct( vecForward, vecCleanupDir ) < -0.5 )
{
// HACKHACK !!!HACKHACK - right now forcing an unstick. Do this better (sjb)
// Clear the debris, suspend the search for debris, trick base class into unsticking me.
m_hDebris = NULL;
m_flTimeDebrisSearch = gpGlobals->curtime + 4;
m_iFail = 10;
TaskFail("Pushing Wrong Way");
}
m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, ROLLERDOZER_FORWARD_SPEED * 2 );
}
else
{
TaskFail("No debris!!");
}
break;
default:
BaseClass::RunTask( pTask );
break;
}
}
示例13: GetEnemyVelocity
float CASW_Sentry_Top_Flamer::GetYawTo(CBaseEntity* pEnt)
{
if (!pEnt)
return m_fDeployYaw;
Vector vEnemyVel = GetEnemyVelocity( pEnt );
// pEnt->GetVelocity( &vEnemyVel );
Vector vIdealAim = ProjectileIntercept( GetFiringPosition(),
GetProjectileVelocity(),
pEnt->WorldSpaceCenter(), vEnemyVel );
if ( vIdealAim.IsZero() )
return m_fDeployYaw;
else
return UTIL_VecToYaw(vIdealAim.Normalized());
}
示例14: Touch
void CPathCorner :: Touch( CBaseEntity *pOther )
{
entvars_t* pevToucher = pOther->pev;
if ( FBitSet ( pevToucher->flags, FL_MONSTER ) )
{// monsters don't navigate path corners based on touch anymore
return;
}
// If OTHER isn't explicitly looking for this path_corner, bail out
if ( pOther->m_pGoalEnt != this )
{
return;
}
// If OTHER has an enemy, this touch is incidental, ignore
if ( !FNullEnt(pevToucher->enemy) )
{
return; // fighting, not following a path
}
// UNDONE: support non-zero flWait
/*
if (m_flWait != 0)
ALERT(at_warning, "Non-zero path-cornder waits NYI");
*/
// Find the next "stop" on the path, make it the goal of the "toucher".
if (FStringNull(pev->target))
{
ALERT(at_warning, "PathCornerTouch: no next stop specified");
}
pOther->m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME ( NULL, STRING(pev->target) ) );
// If "next spot" was not found (does not exist - level design error)
if ( !pOther->m_pGoalEnt )
{
ALERT(at_console, "PathCornerTouch--%s couldn't find next stop in path: %s", STRING(pev->classname), STRING(pev->target));
return;
}
// Turn towards the next stop in the path.
pevToucher->ideal_yaw = UTIL_VecToYaw ( pOther->m_pGoalEnt->pev->origin - pevToucher->origin );
}
示例15: GetAbsOrigin
Vector& CASW_Simple_Alien::GetChaseDestination(CBaseEntity *pEnt)
{
static Vector vecDest = vec3_origin;
vecDest = pEnt->GetAbsOrigin();
if (!pEnt)
return vecDest;
Vector vecDiff = vecDest - GetAbsOrigin();
vecDiff.z = 0;
float dist = vecDiff.Length2D();
if (dist > GetZigZagChaseDistance()) // do we need to zig zag?
{
QAngle angSideways(0, UTIL_VecToYaw(vecDiff), 0);
Vector vecForward, vecRight, vecUp;
AngleVectors(angSideways, &vecForward, &vecRight, &vecUp);
vecDest = GetAbsOrigin() + vecForward * 92.0f + vecRight * (random->RandomFloat() * 144 - 72);
}
return vecDest;
}