本文整理汇总了C++中QAngle类的典型用法代码示例。如果您正苦于以下问题:C++ QAngle类的具体用法?C++ QAngle怎么用?C++ QAngle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QAngle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERTSZ
//-----------------------------------------------------------------------------
// Purpose: Calculate m_vecVelocity and m_flNextThink to reach vecDest from
// GetLocalOrigin() traveling at flSpeed. Just like LinearMove, but rotational.
// Input : vecDestAngle -
// flSpeed -
//-----------------------------------------------------------------------------
void CBaseToggle::AngularMove( const QAngle &vecDestAngle, float flSpeed )
{
ASSERTSZ(flSpeed != 0, "AngularMove: no speed is defined!");
m_vecFinalAngle = vecDestAngle;
m_movementType = MOVE_TOGGLE_ANGULAR;
// Already there?
if (vecDestAngle == GetLocalAngles())
{
MoveDone();
return;
}
// set destdelta to the vector needed to move
QAngle vecDestDelta = vecDestAngle - GetLocalAngles();
// divide by speed to get time to reach dest
float flTravelTime = vecDestDelta.Length() / flSpeed;
const float MinTravelTime = 0.01f;
if ( flTravelTime < MinTravelTime )
{
// If we only travel for a short time, we can fail WillSimulateGamePhysics()
flTravelTime = MinTravelTime;
flSpeed = vecDestDelta.Length() / flTravelTime;
}
// set m_flNextThink to trigger a call to AngularMoveDone when dest is reached
SetMoveDoneTime( flTravelTime );
// scale the destdelta vector by the time spent traveling to get velocity
SetLocalAngularVelocity( vecDestDelta * (1.0 / flTravelTime) );
}
示例2: ApplyErrorToAngle
static void ApplyErrorToAngle(QAngle* angles, float margin)
{
QAngle error;
error.Random(-1.0f, 1.0f);
error *= margin;
angles->operator+=(error);
}
示例3: ToBasePlayer
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponDoubleShotgun::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
if (m_iClip1 >= 2)
{
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(WPN_DOUBLE);
pPlayer->DoMuzzleFlash();
SendWeaponAnim( ACT_VM_SECONDARYATTACK );
// Don't fire again until fire animation has completed
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_iClip1 -= 2;
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
FireBulletsInfo_t info( 40, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
info.m_pAttacker = pPlayer;
// Fire the bullets, and force the first shot to be perfectly accuracy
pPlayer->FireBullets( info );
QAngle punch;
punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 );
pPlayer->ViewPunch( punch );
if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
}
//m_bNeedPump = true;
}
else
{
if (m_bInReload)
{
Reload();
}
else
{
StartReload();
}
}
}
示例4: InputSetAngles
//------------------------------------------------------------------------------
// Input values
//------------------------------------------------------------------------------
void CBaseHelicopter::InputSetAngles( inputdata_t &inputdata )
{
const char *pAngles = inputdata.value.String();
QAngle angles;
UTIL_StringToVector( angles.Base(), pAngles );
SetAbsAngles( angles );
}
示例5: GetLastThink
//-----------------------------------------------------------------------------
// Purpose: Returns the magnitude of the entity's angular velocity.
//-----------------------------------------------------------------------------
float CPointAngularVelocitySensor::SampleAngularVelocity(CBaseEntity *pEntity)
{
if (pEntity->GetMoveType() == MOVETYPE_VPHYSICS)
{
IPhysicsObject *pPhys = pEntity->VPhysicsGetObject();
if (pPhys != NULL)
{
Vector vecVelocity;
AngularImpulse vecAngVelocity;
pPhys->GetVelocity(&vecVelocity, &vecAngVelocity);
QAngle angles;
pPhys->GetPosition( NULL, &angles );
float dt = gpGlobals->curtime - GetLastThink();
if ( dt == 0 )
dt = 0.1;
// HACKHACK: We don't expect a real 'delta' orientation here, just enough of an error estimate to tell if this thing
// is trying to move, but failing.
QAngle delta = angles - m_lastOrientation;
if ( ( delta.Length() / dt ) < ( vecAngVelocity.Length() * 0.01 ) )
{
return 0.0f;
}
m_lastOrientation = angles;
if ( m_bUseHelper == false )
{
return vecAngVelocity.Length();
}
else
{
Vector vLine = m_vecAxis - GetAbsOrigin();
VectorNormalize( vLine );
Vector vecWorldAngVelocity;
pPhys->LocalToWorldVector( &vecWorldAngVelocity, vecAngVelocity );
float flDot = DotProduct( vecWorldAngVelocity, vLine );
return flDot;
}
}
}
else
{
QAngle vecAngVel = pEntity->GetLocalAngularVelocity();
float flMax = MAX(fabs(vecAngVel[PITCH]), fabs(vecAngVel[YAW]));
return MAX(flMax, fabs(vecAngVel[ROLL]));
}
return 0;
}
示例6: InputSetAngles
//------------------------------------------------------------------------------
// Input values
//------------------------------------------------------------------------------
void CGlobalLight::InputSetAngles( inputdata_t &inputdata )
{
const char *pAngles = inputdata.value.String();
QAngle angles;
UTIL_StringToVector( angles.Base(), pAngles );
Vector vTemp;
AngleVectors( angles, &vTemp );
m_shadowDirection = vTemp;
}
示例7: ExplosionCreate
//------------------------------------------------------------------------------
// Pow!
//------------------------------------------------------------------------------
void CPropAPC2::ExplodeAndThrowChunk( const Vector &vecExplosionPos )
{
ExplosionCreate( vecExplosionPos, vec3_angle, this, 1000, 500.0f,
SF_ENVEXPLOSION_NODAMAGE | SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS |
SF_ENVEXPLOSION_NOSMOKE | SF_ENVEXPLOSION_NOFIREBALLSMOKE, 0 );
UTIL_ScreenShake( vecExplosionPos, 25.0, 150.0, 1.0, 750.0f, SHAKE_START );
// Drop a flaming, smoking chunk.
CGib *pChunk = CREATE_ENTITY( CGib, "gib" );
pChunk->Spawn( "models/gibs/hgibs.mdl" );
pChunk->SetBloodColor( DONT_BLEED );
QAngle vecSpawnAngles;
vecSpawnAngles.Random( -90, 90 );
pChunk->SetAbsOrigin( vecExplosionPos );
pChunk->SetAbsAngles( vecSpawnAngles );
int nGib = random->RandomInt( 0, APC_MAX_CHUNKS - 1 );
pChunk->Spawn( s_pChunkModelName[nGib] );
pChunk->SetOwnerEntity( this );
pChunk->m_lifeTime = random->RandomFloat( 6.0f, 8.0f );
pChunk->SetCollisionGroup( COLLISION_GROUP_DEBRIS );
IPhysicsObject *pPhysicsObject = pChunk->VPhysicsInitNormal( SOLID_VPHYSICS, pChunk->GetSolidFlags(), false );
// Set the velocity
if ( pPhysicsObject )
{
pPhysicsObject->EnableMotion( true );
Vector vecVelocity;
QAngle angles;
angles.x = random->RandomFloat( -40, 0 );
angles.y = random->RandomFloat( 0, 360 );
angles.z = 0.0f;
AngleVectors( angles, &vecVelocity );
vecVelocity *= random->RandomFloat( 300, 900 );
vecVelocity += GetAbsVelocity();
AngularImpulse angImpulse;
angImpulse = RandomAngularImpulse( -180, 180 );
pChunk->SetAbsVelocity( vecVelocity );
pPhysicsObject->SetVelocity(&vecVelocity, &angImpulse );
}
CEntityFlame *pFlame = CEntityFlame::Create( pChunk, false );
if ( pFlame != NULL )
{
pFlame->SetLifetime( pChunk->m_lifeTime );
}
pChunk->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
}
示例8: ToBasePlayer
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponShotgun::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
pPlayer->DoMuzzleFlash();
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
// Don't fire again until fire animation has completed
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_iClip1 -= 1;
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
FireBulletsInfo_t info( 7, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
info.m_pAttacker = pPlayer;
// Fire the bullets, and force the first shot to be perfectly accuracy
pPlayer->FireBullets( info );
#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
#ifndef CLIENT_DLL
// DM: Hellow? NPCs... look here! I'm shooting!
pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 1.0 );
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_SHOTGUN, 0.2 );
#endif
#endif //SecobMod__Enable_Fixed_Multiplayer_AI
QAngle punch;
punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 );
pPlayer->ViewPunch( punch );
if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
}
m_bNeedPump = true;
}
示例9: GetOwner
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponShieldGrenade::ThrowGrenade( void )
{
CBasePlayer *pPlayer = dynamic_cast<CBasePlayer*>( GetOwner() );
if ( !pPlayer )
return;
BaseClass::WeaponSound(WPN_DOUBLE);
// Calculate launch velocity (3 seconds for max distance)
float flThrowTime = min( (gpGlobals->curtime - m_flStartedThrowAt), 3.0 );
float flSpeed = 800 + (200 * flThrowTime);
// If the player's crouched, roll the grenade
if ( pPlayer->GetFlags() & FL_DUCKING )
{
// Launch the grenade
Vector vecForward;
QAngle vecAngles = pPlayer->EyeAngles();
// Throw it up just a tad
vecAngles.x = -1;
AngleVectors( vecAngles, &vecForward, NULL, NULL);
Vector vecOrigin;
VectorLerp( pPlayer->EyePosition(), pPlayer->GetAbsOrigin(), 0.25f, vecOrigin );
vecOrigin += (vecForward * 16);
vecForward = vecForward * flSpeed;
QAngle vecGrenAngles;
vecGrenAngles.Init( 0, vecAngles.y, 0 );
#if !defined( CLIENT_DLL )
CreateShieldGrenade( vecOrigin, vecGrenAngles, vecForward, vec3_angle, pPlayer, SHIELD_GRENADE_LIFETIME );
#endif
}
else
{
// Launch the grenade
Vector vecForward;
QAngle vecAngles = pPlayer->EyeAngles();
AngleVectors( vecAngles, &vecForward, NULL, NULL);
Vector vecOrigin = pPlayer->EyePosition();
vecOrigin += (vecForward * 16);
vecForward = vecForward * flSpeed;
QAngle vecGrenAngles;
vecGrenAngles.Init( 0, vecAngles.y, 0 );
#if !defined( CLIENT_DLL )
CreateShieldGrenade( vecOrigin, vecGrenAngles, vecForward, vec3_angle, pPlayer, SHIELD_GRENADE_LIFETIME );
#endif
}
pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
}
示例10: InputSetAngles
//------------------------------------------------------------------------------
// Purpose: Sets the angles to use for the secondary fog direction.
//------------------------------------------------------------------------------
void CFogController::InputSetAngles( inputdata_t &inputdata )
{
const char *pAngles = inputdata.value.String();
QAngle angles;
UTIL_StringToVector( angles.Base(), pAngles );
Vector vTemp;
AngleVectors( angles, &vTemp );
SetAbsAngles( angles );
AngleVectors( GetAbsAngles(), &m_fog.dirPrimary.GetForModify() );
m_fog.dirPrimary.GetForModify() *= -1.0f;
}
示例11: PostDataUpdate
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_ObjectSentrygun::PostDataUpdate( DataUpdateType_t updateType )
{
BaseClass::PostDataUpdate( updateType );
if ( m_bLastTurtled != m_bTurtled )
{
if ( m_bTurtled )
{
m_flStartedTurtlingAt = gpGlobals->curtime;
m_flStartedUnTurtlingAt = 0;
}
else
{
m_flStartedUnTurtlingAt = gpGlobals->curtime;
m_flStartedTurtlingAt = 0;
}
}
if ( m_nLastAnimationParity != m_nAnimationParity )
{
m_flCycle = 0.0f;
}
bool changed = false;
QAngle angleDiff;
angleDiff = ( GetAbsAngles() - m_angPrevLocalAngles );
for (int i = 0;i < 3; i++ )
{
angleDiff[i] = UTIL_AngleMod( angleDiff[ i ] );
}
if ( angleDiff.Length() > 0.1f )
{
changed = true;
}
if ( updateType == DATA_UPDATE_CREATED || changed )
{
// Orient it
m_vecCurAngles.y = UTIL_AngleMod( GetLocalAngles().y );
RecomputeOrientation();
}
else if ( m_nPrevOrientationParity != m_nOrientationParity )
{
if ( changed )
{
RecomputeOrientation();
}
}
}
示例12: AddDetailToLump
static void AddDetailToLump( const char* pModelName, const Vector& pt, const QAngle& angles, int nOrientation )
{
Assert( pt.IsValid() && angles.IsValid() );
// Make sure the model is valid...
if (!IsModelValid(pModelName))
return;
if (s_DetailObjectLump.Count() == 65535)
{
++s_nDetailOverflow;
return;
}
// Insert an element into the object dictionary if it aint there...
int i = s_DetailObjectLump.AddToTail( );
DetailObjectLump_t& objectLump = s_DetailObjectLump[i];
objectLump.m_DetailModel = AddDetailDictLump( pModelName );
VectorCopy( angles, objectLump.m_Angles );
VectorCopy( pt, objectLump.m_Origin );
objectLump.m_Leaf = ComputeDetailLeaf(pt);
objectLump.m_Lighting.r = 255;
objectLump.m_Lighting.g = 255;
objectLump.m_Lighting.b = 255;
objectLump.m_Lighting.exponent = 0;
objectLump.m_LightStyles = 0;
objectLump.m_LightStyleCount = 0;
objectLump.m_Orientation = nOrientation;
objectLump.m_Type = DETAIL_PROP_TYPE_MODEL;
}
示例13: QAngle
void Aimbot::Smooth(C_BasePlayer* player, QAngle& angle, CUserCmd* cmd)
{
if (!Settings::Aimbot::Smooth::enabled)
return;
if (Settings::AntiAim::Pitch::enabled || Settings::AntiAim::Yaw::enabled)
return;
if (!shouldAim || !player)
return;
if (Settings::Aimbot::silent)
return;
QAngle viewAngles = QAngle(0.f, 0.f, 0.f);
engine->GetViewAngles(viewAngles);
QAngle delta = angle - viewAngles;
Math::NormalizeAngles(delta);
float smooth = powf(Settings::Aimbot::Smooth::value, 0.4f); // Makes more slider space for actual useful values
smooth = std::min(0.99f, smooth);
if (Settings::Aimbot::Smooth::Salting::enabled)
Salt(smooth);
QAngle toChange = QAngle();
int type = (int) Settings::Aimbot::Smooth::type;
if (type == (int) SmoothType::SLOW_END)
toChange = delta - delta * smooth;
else if (type == (int) SmoothType::CONSTANT || type == (int) SmoothType::FAST_END)
{
float coeff = (1.0f - smooth) / delta.Length() * 4.f;
if (type == (int) SmoothType::FAST_END)
coeff = powf(coeff, 2.f) * 10.f;
coeff = std::min(1.f, coeff);
toChange = delta * coeff;
}
angle = viewAngles + toChange;
}
示例14: smn_TRTraceRayEx
static cell_t smn_TRTraceRayEx(IPluginContext *pContext, const cell_t *params)
{
cell_t *startaddr, *endaddr;
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
Vector StartVec, EndVec;
Ray_t ray;
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
switch (params[4])
{
case RayType_EndPoint:
{
EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
break;
}
case RayType_Infinite:
{
QAngle DirAngles;
DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
AngleVectors(DirAngles, &EndVec);
/* Make it unitary and get the ending point */
EndVec.NormalizeInPlace();
EndVec = StartVec + EndVec * MAX_TRACE_LENGTH;
break;
}
}
sm_trace_t *tr = new sm_trace_t;
ray.Init(StartVec, EndVec);
enginetrace->TraceRay(ray, params[3], &g_HitAllFilter, tr);
tr->UpdateEntRef();
HandleError herr;
Handle_t hndl;
if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
{
delete tr;
return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
}
return hndl;
}
示例15: atan2
//-----------------------------------------------------------------------------
// Primary gun
//-----------------------------------------------------------------------------
void CPropAPC::AimPrimaryWeapon( const Vector &vecWorldTarget )
{
EntityMatrix parentMatrix;
parentMatrix.InitFromEntity( this, m_nMachineGunBaseAttachment );
Vector target = parentMatrix.WorldToLocal( vecWorldTarget );
float quadTarget = target.LengthSqr();
float quadTargetXY = target.x*target.x + target.y*target.y;
// Target is too close! Can't aim at it
if ( quadTarget > m_vecBarrelPos.LengthSqr() )
{
// We're trying to aim the offset barrel at an arbitrary point.
// To calculate this, I think of the target as being on a sphere with
// it's center at the origin of the gun.
// The rotation we need is the opposite of the rotation that moves the target
// along the surface of that sphere to intersect with the gun's shooting direction
// To calculate that rotation, we simply calculate the intersection of the ray
// coming out of the barrel with the target sphere (that's the new target position)
// and use atan2() to get angles
// angles from target pos to center
float targetToCenterYaw = atan2( target.y, target.x );
float centerToGunYaw = atan2( m_vecBarrelPos.y, sqrt( quadTarget - (m_vecBarrelPos.y*m_vecBarrelPos.y) ) );
float targetToCenterPitch = atan2( target.z, sqrt( quadTargetXY ) );
float centerToGunPitch = atan2( -m_vecBarrelPos.z, sqrt( quadTarget - (m_vecBarrelPos.z*m_vecBarrelPos.z) ) );
QAngle angles;
angles.Init( -RAD2DEG(targetToCenterPitch+centerToGunPitch), RAD2DEG( targetToCenterYaw + centerToGunYaw ), 0 );
SetPoseParameter( "vehicle_weapon_yaw", angles.y );
SetPoseParameter( "vehicle_weapon_pitch", angles.x );
StudioFrameAdvance();
float curPitch = GetPoseParameter( "vehicle_weapon_pitch" );
float curYaw = GetPoseParameter( "vehicle_weapon_yaw" );
m_bInFiringCone = (fabs(curPitch - angles.x) < 1e-3) && (fabs(curYaw - angles.y) < 1e-3);
}
else
{
m_bInFiringCone = false;
}
}