void ParticleSystem :: DrawSystem( void ) { Vector normal, forward, right, up; GetViewAngles( normal ); AngleVectors( normal, forward, right, up ); particle* pParticle = m_pActiveParticle; for( pParticle = m_pActiveParticle; pParticle; pParticle = pParticle->nextpart ) { DrawParticle( pParticle, right, up ); } }
//========================================================= // FInViewCone - returns true is the passed vector is in // the caller's forward view cone. //========================================================= bool CEntity::FInViewCone(Vector *pOrigin, float fov) { if (fov <= 0) fov = GetFov(); Vector forward; GetViewAngles().AngleVectors(&forward); Vector vecLOS = (*pOrigin - GetGunPosition()).Normalize(); float flDot = DotProduct(vecLOS, forward); return (flDot >= cos((fov / 2) * (M_PI / 180))); }
bool ParticleSystem::ParticleIsVisible( particle* part ) { vec3_t normal, forward, right, up; GetViewAngles( normal ); AngleVectors( normal, forward, right, up ); Vector vec = ( part->origin - v_origin ); Vector vecDir = vec.Normalize( ); float distance = vec.Length(); if ( DotProduct ( vecDir, forward ) < 0.0f ) return false; return true; }
void CEntity::ChangeAngles(const Vector &idealangles, float speed) { #if 0 pev->v_angle = pev->angles = idealangles; pev->v_angle.x *= -1; pev->angles.x /= 3; #else Vector v_deviation = Vector(-idealangles.x, idealangles.y, idealangles.z) - GetViewAngles(); v_deviation.ClampAngles(); float da_deadly_math = exp(log(speed / 2) * g_pServer->GetMsec() / 50); // Thanks Tobias Heimann and Johannes Lampel for this one pev->yaw_speed = (pev->yaw_speed * da_deadly_math + speed * v_deviation.y * (1 - da_deadly_math)) * g_pServer->GetMsec() / 50; pev->pitch_speed = (pev->pitch_speed * da_deadly_math + speed * v_deviation.x * (1 - da_deadly_math)) * g_pServer->GetMsec() / 50; // influence of y movement on x axis and vice versa (less influence than x on y since it's // easier and more natural for the bot to "move its mouse" horizontally than vertically) pev->pitch_speed += pev->yaw_speed / 4.5; pev->yaw_speed += pev->pitch_speed / 3; if (fabs(pev->pitch_speed) >= fabs(v_deviation.x) && pev->pitch_speed * v_deviation.x >= 0) pev->pitch_speed = v_deviation.x; if (fabs(pev->yaw_speed) >= fabs(v_deviation.y) && pev->yaw_speed * v_deviation.y >= 0) pev->yaw_speed = v_deviation.y; pev->v_angle.y += pev->yaw_speed; pev->v_angle.x += pev->pitch_speed; // set the body angles to point the gun correctly pev->angles.x = -pev->v_angle.x / 3; pev->angles.y = pev->v_angle.y; #endif pev->v_angle.ClampAngles(); pev->angles.ClampAngles(); }
bool Client::IsInViewCone (const Vector &pos) const { engine->BuildGlobalVectors (GetViewAngles ()); return ((pos - GetHeadOrigin ()).Normalize () | g_pGlobals->v_forward) >= cosf (Math::DegreeToRadian ((GetFOV () > 0.0f ? GetFOV () : 90.0f) * 0.5f)); }
////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // CLIENT ////////////////////////////////////////////////////////////////////////// float Client::GetShootingConeDeviation (const Vector &pos) const { engine->BuildGlobalVectors (GetViewAngles ()); return g_pGlobals->v_forward | (pos - GetHeadOrigin ()).Normalize (); }