本文整理汇总了C++中RemapValClamped函数的典型用法代码示例。如果您正苦于以下问题:C++ RemapValClamped函数的具体用法?C++ RemapValClamped怎么用?C++ RemapValClamped使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RemapValClamped函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deltaColor
//-----------------------------------------------------------------------------
// Purpose: Update all deltas that are not expired.
//-----------------------------------------------------------------------------
void CTextManager::Update( void )
{
for ( int i = 0; i < 10; i++ )
{
if ( m_aTexts[i].flDieTime < g_CurTime )
continue;
sf::Color deltaColor( 255, 15, 15, 255 );
float flLifetimePercent = ( m_aTexts[i].flDieTime - g_CurTime ) / 1.5f;
if ( flLifetimePercent < 0.5f )
{
deltaColor.a = (char)( 255.0f * ( flLifetimePercent / 0.5 ) );
}
if ( !m_aTexts[i].bMinus )
{
deltaColor.r = (char)RemapValClamped( flLifetimePercent, 0.0f, 1.0f, 255, 30 );
deltaColor.g = (char)RemapValClamped( flLifetimePercent, 0.0f, 1.0f, 30, 255 );
}
float flHeight = 50.0f;
float flXPos = m_aTexts[i].vecPos.x;
float flYPos = m_aTexts[i].vecPos.y - ( 1.0f - flLifetimePercent ) * flHeight;
sf::Text newText( m_aTexts[i].text, m_Font );
sf::FloatRect textBounds = newText.getLocalBounds();
newText.setOrigin( textBounds.width / 2.0f, textBounds.height );
newText.setPosition( flXPos, flYPos );
newText.setFillColor( deltaColor );
g_pGameLogic->GetWindow()->draw( newText );
}
}
示例2: r
void CLaser::PostRender() const
{
BaseClass::PostRender();
if (!GameServer()->GetRenderer()->IsRenderingTransparent())
return;
if (!m_bShouldRender)
return;
if (!m_hOwner)
return;
CRenderingContext r(DigitanksGame()->GetDigitanksRenderer(), true);
r.SetBlend(BLEND_ADDITIVE);
Vector vecForward, vecRight, vecUp;
float flLength = LaserLength();
CDigitank* pOwner = dynamic_cast<CDigitank*>(GetOwner());
Vector vecMuzzle = m_hOwner->GetGlobalOrigin();
Vector vecTarget = vecMuzzle + AngleVector(GetGlobalAngles()) * flLength;
if (pOwner)
{
Vector vecDirection = (pOwner->GetLastAim() - pOwner->GetGlobalOrigin()).Normalized();
vecTarget = vecMuzzle + vecDirection * flLength;
AngleVectors(VectorAngles(vecDirection), &vecForward, &vecRight, &vecUp);
vecMuzzle = pOwner->GetGlobalOrigin() + vecDirection * 3 + Vector(0, 0, 3);
}
float flBeamWidth = 1.5;
Vector avecRayColors[] =
{
Vector(1, 0, 0),
Vector(0, 1, 0),
Vector(0, 0, 1),
};
float flRayRamp = RemapValClamped((float)(GameServer()->GetGameTime() - GetSpawnTime()), 0.5f, 1.5f, 0.0f, 1);
float flAlphaRamp = RemapValClamped((float)(GameServer()->GetGameTime() - GetSpawnTime()), 1, 2, 1.0f, 0);
size_t iBeams = 21;
for (size_t i = 0; i < iBeams; i++)
{
float flUp = RemapVal((float)i, 0, (float)iBeams, -flLength, flLength);
Vector vecRay = LerpValue<Vector>(Vector(1, 1, 1), avecRayColors[i%3], flRayRamp);
Color clrRay = vecRay;
clrRay.SetAlpha((int)(200*flAlphaRamp));
r.SetColor(clrRay);
CRopeRenderer rope(DigitanksGame()->GetDigitanksRenderer(), s_hBeam, vecMuzzle, flBeamWidth);
rope.SetTextureOffset(((float)i/20) - GameServer()->GetGameTime() - GetSpawnTime());
rope.Finish(vecTarget + vecUp*flUp);
}
}
示例3: Vector
Vector CThirdPersonManager::GetDistanceFraction( void )
{
if ( IsOverridingThirdPerson() == true )
{
return Vector( m_flTargetFraction, m_flTargetFraction, m_flTargetFraction );
}
float flFraction = m_flFraction;
float flUpFraction = m_flUpFraction;
float flFrac = RemapValClamped( gpGlobals->curtime - m_flLerpTime, 0, CAMERA_OFFSET_LERP_TIME, 0, 1 );
flFraction = Lerp( flFrac, m_flFraction, m_flTargetFraction );
if ( flFrac == 1.0f )
{
m_flFraction = m_flTargetFraction;
}
flFrac = RemapValClamped( gpGlobals->curtime - m_flUpLerpTime, 0, CAMERA_UP_OFFSET_LERP_TIME, 0, 1 );
flUpFraction = 1.0f - Lerp( flFrac, m_flUpFraction, m_flTargetUpFraction );
if ( flFrac == 1.0f )
{
m_flUpFraction = m_flTargetUpFraction;
}
return Vector( flFraction, flFraction, flUpFraction );
}
示例4: RemapValClamped
void ClientModeSDKNormal::OverrideMouseInput( float *x, float *y )
{
C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer();
if (!pPlayer)
return;
float flSlowMultiplier = RemapValClamped(pPlayer->GetSlowMoMultiplier(), 0.4f, 1, m_slowmodamping.GetFloat(), 1);
*x *= flSlowMultiplier;
*y *= flSlowMultiplier;
*y *= m_verticaldamping.GetFloat();
C_WeaponSDKBase* pWeapon = pPlayer->GetActiveSDKWeapon();
if (pWeapon)
{
float flAimInMultiplier;
if (pWeapon->HasAimInSpeedPenalty())
flAimInMultiplier = RemapValClamped(pPlayer->m_Shared.GetAimIn(), 0, 1, 1, m_aimindamping.GetFloat());
else
flAimInMultiplier = RemapValClamped(pPlayer->m_Shared.GetAimIn(), 0, 1, 1, m_partialaimindamping.GetFloat());
*x *= flAimInMultiplier;
*y *= flAimInMultiplier;
}
BaseClass::OverrideMouseInput(x, y);
}
示例5: RemapValClamped
void CCPU::ModifyContext(class CRenderingContext* pContext) const
{
BaseClass::ModifyContext(pContext);
if (GameServer()->GetGameTime() - m_flConstructionStartTime < 3)
{
pContext->SetBlend(BLEND_ALPHA);
pContext->SetColor(Color(255, 255, 255));
pContext->SetAlpha(GetVisibility() * RemapValClamped((float)(GameServer()->GetGameTime() - m_flConstructionStartTime), 0.0f, 2.0f, 0.0f, 1.0f));
pContext->Translate(Vector(0, 0, RemapValClamped((float)(GameServer()->GetGameTime() - m_flConstructionStartTime), 0.0f, 3.0f, -3.0f, 0.0f)));
}
}
示例6: GetAbsOrigin
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_PropCombineBall::DrawMotionBlur( void )
{
float color[3];
Vector vecDir = GetAbsOrigin() - m_vecLastOrigin;
float speed = VectorNormalize( vecDir );
speed = clamp( speed, 0, 32 );
float stepSize = MIN( ( speed * 0.5f ), 4.0f );
Vector spawnPos = GetAbsOrigin();
Vector spawnStep = -vecDir * stepSize;
float base = RemapValClamped( speed, 4, 32, 0.0f, 1.0f );
CMatRenderContextPtr pRenderContext( materials );
pRenderContext->Bind( m_pBlurMaterial );
// Draw the motion blurred trail
for ( int i = 0; i < 8; i++ )
{
spawnPos += spawnStep;
color[0] = color[1] = color[2] = base * ( 1.0f - ( (float) i / 12.0f ) );
DrawHalo( m_pBlurMaterial, spawnPos, m_flRadius, color );
}
}
示例7: ToCFPlayer
void CStatusEffectSkinProxy::OnBind( C_BaseEntity *pEnt )
{
float flEffectMagnitude;
if (pEnt->IsPlayer() && ToCFPlayer(pEnt))
{
C_CFPlayer* pPlayer = ToCFPlayer(pEnt);
flEffectMagnitude = pPlayer->m_pStats->GetEffectFromBitmask(STATUSEFFECT_SLOWNESS);
}
else if (pEnt->IsNPC() && dynamic_cast<C_CFActor*>(pEnt))
{
flEffectMagnitude = dynamic_cast<C_CFActor*>(pEnt)->m_flEffectMagnitude;
}
else
return;
if (m_pDetailBlend)
{
float flCurrent = m_pDetailBlend->GetFloatValue();
float flGoal = RemapValClamped(flEffectMagnitude, 0.0f, 1.0f, 0.3f, 1.0f );
if (flEffectMagnitude < 0.01)
flGoal = 0.0f;
m_pDetailBlend->SetFloatValue( Approach(flGoal, flCurrent, gpGlobals->frametime/10) );
}
}
示例8: SparseConvolutionNoise
float SparseConvolutionNoise(Vector const &pnt, float (*pNoiseShapeFunction)(float) )
{
// computer integer lattice point
int ix=LatticeCoord(pnt.x);
int iy=LatticeCoord(pnt.y);
int iz=LatticeCoord(pnt.z);
// compute offsets within unit cube
float xfrac=pnt.x-floor(pnt.x);
float yfrac=pnt.y-floor(pnt.y);
float zfrac=pnt.z-floor(pnt.z);
float sum_out=0.;
for(int ox=-1; ox<=1; ox++)
for(int oy=-1; oy<=1; oy++)
for(int oz=-1; oz<=1; oz++)
{
sum_out += CellNoise( ix+ox, iy+oy, iz+oz,
xfrac-ox, yfrac-oy, zfrac-oz,
pNoiseShapeFunction );
}
#ifdef MEASURE_RANGE
fmin1=min(sum_out,fmin1);
fmax1=max(sum_out,fmax1);
#endif
return RemapValClamped( sum_out, .544487, 9.219176, 0.0, 1.0 );
}
示例9: VectorNormalize
//----------------------------------------------------
// Place dust at vector passed in
//----------------------------------------------------
void CFourWheelVehiclePhysics::PlaceWheelDust( int wheelIndex, bool ignoreSpeed )
{
Vector vecPos, vecVel;
m_pVehicle->GetWheelContactPoint( wheelIndex, vecPos );
vecVel.Random( -1.0f, 1.0f );
vecVel.z = random->RandomFloat( 0.3f, 1.0f );
VectorNormalize( vecVel );
// Higher speeds make larger dust clouds
float flSize;
if ( ignoreSpeed )
{
flSize = 1.0f;
}
else
{
flSize = RemapValClamped( m_nSpeed, DUST_SPEED, m_flMaxSpeed, 0.0f, 1.0f );
}
if ( flSize )
{
CEffectData data;
data.m_vOrigin = vecPos;
data.m_vNormal = vecVel;
data.m_flScale = flSize;
DispatchEffect( "WheelDust", data );
}
}
示例10: RemapValClamped
//-----------------------------------------------------------------------------
// Purpose:
// Output : inline float
//-----------------------------------------------------------------------------
inline float C_AlyxEmpEffect::GetStateDurationPercentage( void )
{
if ( m_flDuration == 0 )
return 0.0f;
return RemapValClamped( ( gpGlobals->curtime - m_flStartTime ), 0, m_flDuration, 0, 1.0f );;
}
示例11: DelayedAttack
//-----------------------------------------------------------------------------
// Purpose: Handle grenade detonate in-air (even when no ammo is left)
//-----------------------------------------------------------------------------
void CWeaponAR2::ItemPostFrame( void )
{
// See if we need to fire off our secondary round
if ( m_bShotDelayed && gpGlobals->curtime > m_flDelayedFire )
{
DelayedAttack();
}
// Update our pose parameter for the vents
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner )
{
CBaseViewModel *pVM = pOwner->GetViewModel();
if ( pVM )
{
if ( m_nVentPose == -1 )
{
m_nVentPose = pVM->LookupPoseParameter( "VentPoses" );
}
float flVentPose = RemapValClamped( m_nShotsFired, 0, 5, 0.0f, 1.0f );
pVM->SetPoseParameter( m_nVentPose, flVentPose );
}
}
BaseClass::ItemPostFrame();
}
示例12: ScriptInfo_CalculateFOV
//-----------------------------------------------------------------------------
// Purpose: Calculate the FOV for the intro sequence (needed by both server and client)
//-----------------------------------------------------------------------------
float ScriptInfo_CalculateFOV( float flFOVBlendStartTime, float flNextFOVBlendTime, int nFOV, int nNextFOV, bool bSplineRamp )
{
// Handle the spline case
if ( bSplineRamp )
{
//If we're past the zoom time, just take the new value and stop transitioning
float deltaTime = (float)( gpGlobals->curtime - flFOVBlendStartTime ) / ( flNextFOVBlendTime - flFOVBlendStartTime );
if ( deltaTime >= 1.0f )
return nNextFOV;
float flResult = SimpleSplineRemapVal( deltaTime, 0.0f, 1.0f, (float) nFOV, (float) nNextFOV );
// Msg("FOV BLENDING: curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime );
// Msg(" Perc: %.2f Start: %d End: %d FOV: %.2f\n", SimpleSplineRemapVal( deltaTime, 0.0f, 1.0f, nFOV, nNextFOV ), nFOV, nNextFOV, flResult );
return flResult;
}
// Common, linear blend
if ( (flNextFOVBlendTime - flFOVBlendStartTime) != 0 )
{
float flResult = RemapValClamped( gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime, (float) nFOV, (float) nNextFOV );
// Msg("FOV BLENDING: curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime );
// Msg(" Perc: %.2f Start: %d End: %d FOV: %.2f\n", RemapValClamped( gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime, 0.0, 1.0 ), nFOV, nNextFOV, flResult );
return flResult;
}
// Msg("FOV BLENDING: JUMPED TO NEXT FOV (%d)\n", nNextFOV );
return nNextFOV;
}
示例13: GetBulletSpread
virtual const Vector& GetBulletSpread( void )
{
// Handle NPCs first
static Vector npcCone = VECTOR_CONE_5DEGREES;
if ( GetOwner() && GetOwner()->IsNPC() )
return npcCone;
static Vector cone;
if ( pistol_use_new_accuracy.GetBool() )
{
float ramp = RemapValClamped( m_flAccuracyPenalty,
0.0f,
PISTOL_ACCURACY_MAXIMUM_PENALTY_TIME,
0.0f,
1.0f );
// We lerp from very accurate to inaccurate over time
VectorLerp( VECTOR_CONE_1DEGREES, VECTOR_CONE_6DEGREES, ramp, cone );
}
else
{
// Old value
cone = VECTOR_CONE_4DEGREES;
}
return cone;
}
示例14: RemapViewAngles
//-----------------------------------------------------------------------------
// Purpose:
// Input : pData -
// vehicleEyeAngles -
//-----------------------------------------------------------------------------
void RemapViewAngles( ViewSmoothingData_t *pData, QAngle &vehicleEyeAngles )
{
QAngle vecEyeAnglesRemapped;
// Clamp pitch.
RemapAngleRange_CurvePart_t ePitchCurvePart;
vecEyeAnglesRemapped.x = RemapAngleRange( pData->flPitchCurveZero, pData->flPitchCurveLinear, vehicleEyeAngles.x, &ePitchCurvePart );
vehicleEyeAngles.z = vecEyeAnglesRemapped.z = AngleNormalize( vehicleEyeAngles.z );
// Blend out the roll dampening as our pitch approaches 90 degrees, to avoid gimbal lock problems.
float flBlendRoll = 1.0;
if ( fabs( vehicleEyeAngles.x ) > 60 )
{
flBlendRoll = RemapValClamped( fabs( vecEyeAnglesRemapped.x ), 60, 80, 1, 0);
}
RemapAngleRange_CurvePart_t eRollCurvePart;
float flRollDamped = RemapAngleRange( pData->flRollCurveZero, pData->flRollCurveLinear, vecEyeAnglesRemapped.z, &eRollCurvePart );
vecEyeAnglesRemapped.z = Lerp( flBlendRoll, vecEyeAnglesRemapped.z, flRollDamped );
//Msg("PITCH ");
vehicleEyeAngles.x = ApplyViewLocking( vehicleEyeAngles.x, vecEyeAnglesRemapped.x, pData->pitchLockData, ePitchCurvePart );
//Msg("ROLL ");
vehicleEyeAngles.z = ApplyViewLocking( vehicleEyeAngles.z, vecEyeAnglesRemapped.z, pData->rollLockData, eRollCurvePart );
}
示例15: RemapValClamped
//-----------------------------------------------------------------------------
// Purpose:
// Output : inline float
//-----------------------------------------------------------------------------
inline float C_CitadelEnergyCore::GetStateDurationPercentage( void )
{
if ( m_flDuration == 0 )
return 0.0f;
return RemapValClamped( ( gpGlobals->curtime - m_flStartTime ), 0, m_flDuration, 0, 1.0f );;
}