本文整理汇总了C++中CActor::AddAngularImpulse方法的典型用法代码示例。如果您正苦于以下问题:C++ CActor::AddAngularImpulse方法的具体用法?C++ CActor::AddAngularImpulse怎么用?C++ CActor::AddAngularImpulse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActor
的用法示例。
在下文中一共展示了CActor::AddAngularImpulse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddAngularImpulse
int CScriptBind_Actor::AddAngularImpulse(IFunctionHandler *pH,Ang3 vAngular,float deceleration,float duration)
{
CActor *pActor = GetActor(pH);
if (pActor)
pActor->AddAngularImpulse(vAngular,deceleration,duration);
return pH->EndFunction();
}
示例2: ProcessClientExplosionScreenFX
//-------------------------------------------
void CGameRules::ProcessClientExplosionScreenFX(const ExplosionInfo &explosionInfo)
{
IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
if (pClientActor)
{
//Distance
float dist = (pClientActor->GetEntity()->GetWorldPos() - explosionInfo.pos).len();
//Is the explosion in Player's FOV (let's suppose the FOV a bit higher, like 80)
CActor *pActor = (CActor *)pClientActor;
SMovementState state;
if (IMovementController *pMV = pActor->GetMovementController())
{
pMV->GetMovementState(state);
}
Vec3 eyeToExplosion = explosionInfo.pos - state.eyePosition;
eyeToExplosion.Normalize();
bool inFOV = (state.eyeDirection.Dot(eyeToExplosion) > 0.68f);
// if in a vehicle eyeDirection is wrong
if(pActor && pActor->GetLinkedVehicle())
{
Vec3 eyeDir = static_cast<CPlayer*>(pActor)->GetVehicleViewDir();
inFOV = (eyeDir.Dot(eyeToExplosion) > 0.68f);
}
//All explosions have radial blur (default 30m radius, to make Sean happy =))
float maxBlurDistance = (explosionInfo.maxblurdistance>0.0f)?explosionInfo.maxblurdistance:30.0f;
if (maxBlurDistance>0.0f && g_pGameCVars->g_radialBlur>0.0f && m_explosionScreenFX && explosionInfo.radius>0.5f)
{
if (inFOV && dist < maxBlurDistance)
{
ray_hit hit;
int col = gEnv->pPhysicalWorld->RayWorldIntersection(explosionInfo.pos , -eyeToExplosion*dist, ent_static | ent_terrain, rwi_stop_at_pierceable|rwi_colltype_any, &hit, 1);
//If there was no obstacle between flashbang grenade and player
if(!col)
{
if (CScreenEffects* pSE = pActor->GetScreenEffects())
{
float blurRadius = (-1.0f/maxBlurDistance)*dist + 1.0f;
gEnv->p3DEngine->SetPostEffectParam("FilterRadialBlurring_Radius", blurRadius);
gEnv->p3DEngine->SetPostEffectParam("FilterRadialBlurring_Amount", 1.0f);
IBlendedEffect *pBlur = CBlendedEffect<CPostProcessEffect>::Create(CPostProcessEffect(pClientActor->GetEntityId(),"FilterRadialBlurring_Amount", 0.0f));
IBlendType *pLinear = CBlendType<CLinearBlend>::Create(CLinearBlend(1.0f));
pSE->StartBlend(pBlur, pLinear, 1.0f, CScreenEffects::eSFX_GID_RBlur);
pSE->SetUpdateCoords("FilterRadialBlurring_ScreenPosX","FilterRadialBlurring_ScreenPosY", explosionInfo.pos);
}
float distAmp = 1.0f - (dist / maxBlurDistance);
if (gEnv->pInput)
gEnv->pInput->ForceFeedbackEvent( SFFOutputEvent(eDI_XI, eFF_Rumble_Basic, 0.5f, distAmp*3.0f, 0.0f));
}
}
}
//Flashbang effect
if(dist<explosionInfo.radius && inFOV &&
(!strcmp(explosionInfo.effect_class,"flashbang") || !strcmp(explosionInfo.effect_class,"FlashbangAI")))
{
ray_hit hit;
int col = gEnv->pPhysicalWorld->RayWorldIntersection(explosionInfo.pos , -eyeToExplosion*dist, ent_static | ent_terrain, rwi_stop_at_pierceable|rwi_colltype_any, &hit, 1);
//If there was no obstacle between flashbang grenade and player
if(!col)
{
float power = explosionInfo.flashbangScale;
power *= max(0.0f, 1 - (dist/explosionInfo.radius));
float lookingAt = (eyeToExplosion.Dot(state.eyeDirection.normalize()) + 1)*0.5f;
power *= lookingAt;
SAFE_GAMEAUDIO_SOUNDMOODS_FUNC(AddSoundMood(SOUNDMOOD_EXPLOSION,MIN(power*40.0f,100.0f)));
gEnv->p3DEngine->SetPostEffectParam("Flashbang_Time", 1.0f + (power * 4));
gEnv->p3DEngine->SetPostEffectParam("FlashBang_BlindAmount",explosionInfo.blindAmount);
gEnv->p3DEngine->SetPostEffectParam("Flashbang_DifractionAmount", (power * 2));
gEnv->p3DEngine->SetPostEffectParam("Flashbang_Active", 1);
}
}
else if(inFOV && (dist < explosionInfo.radius))
{
if (explosionInfo.damage>10.0f || explosionInfo.pressure>100.0f)
{
//Add some angular impulse to the client actor depending on distance, direction...
float dt = (1.0f - dist/explosionInfo.radius);
dt = dt * dt;
float angleZ = gf_PI*0.15f*dt;
float angleX = gf_PI*0.15f*dt;
pActor->AddAngularImpulse(Ang3(Random(-angleX*0.5f,angleX),0.0f,Random(-angleZ,angleZ)),0.0f,dt*2.0f);
}
}
float fDist2=(pClientActor->GetEntity()->GetWorldPos()-explosionInfo.pos).len2();
if (fDist2<250.0f*250.0f)
//.........这里部分代码省略.........
示例3: ProcessClientExplosionScreenFX
//-------------------------------------------
void CGameRules::ProcessClientExplosionScreenFX(const ExplosionInfo &explosionInfo)
{
IActor *pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
if (pClientActor)
{
//Distance
float dist = (pClientActor->GetEntity()->GetWorldPos() - explosionInfo.pos).len();
//Is the explosion in Player's FOV (let's suppose the FOV a bit higher, like 80)
CActor *pActor = (CActor *)pClientActor;
SMovementState state;
if (IMovementController *pMV = pActor->GetMovementController())
{
pMV->GetMovementState(state);
}
Vec3 eyeToExplosion = explosionInfo.pos - state.eyePosition;
eyeToExplosion.Normalize();
bool inFOV = (state.eyeDirection.Dot(eyeToExplosion) > 0.68f);
//All explosions have radial blur (default 30m radius, to make Sean happy =))
float maxBlurDistance = (explosionInfo.maxblurdistance > 0.0f) ? explosionInfo.maxblurdistance : 30.0f;
if (maxBlurDistance > 0.0f && g_pGameCVars->g_radialBlur > 0.0f && m_explosionScreenFX && explosionInfo.radius > 0.5f)
{
if (inFOV && dist < maxBlurDistance)
{
ray_hit hit;
int col = gEnv->pPhysicalWorld->RayWorldIntersection(explosionInfo.pos , -eyeToExplosion * dist, ent_static | ent_terrain, rwi_stop_at_pierceable | rwi_colltype_any, &hit, 1);
//If there was no obstacle between flashbang grenade and player
if(!col)
{
float distAmp = 1.0f - (dist / maxBlurDistance);
if (gEnv->pInput)
{
gEnv->pInput->ForceFeedbackEvent( SFFOutputEvent(eDI_XI, eFF_Rumble_Basic, 0.5f, distAmp * 3.0f, 0.0f));
}
}
}
}
//Flashbang effect
if(dist < explosionInfo.radius && inFOV &&
(!strcmp(explosionInfo.effect_class, "flashbang") || !strcmp(explosionInfo.effect_class, "FlashbangAI")))
{
ray_hit hit;
int col = gEnv->pPhysicalWorld->RayWorldIntersection(explosionInfo.pos , -eyeToExplosion * dist, ent_static | ent_terrain, rwi_stop_at_pierceable | rwi_colltype_any, &hit, 1);
//If there was no obstacle between flashbang grenade and player
if(!col)
{
float power = explosionInfo.flashbangScale;
power *= max(0.0f, 1 - (dist / explosionInfo.radius));
float lookingAt = (eyeToExplosion.Dot(state.eyeDirection.normalize()) + 1) * 0.5f;
power *= lookingAt;
gEnv->p3DEngine->SetPostEffectParam("Flashbang_Time", 1.0f + (power * 4));
gEnv->p3DEngine->SetPostEffectParam("FlashBang_BlindAmount", explosionInfo.blindAmount);
gEnv->p3DEngine->SetPostEffectParam("Flashbang_DifractionAmount", (power * 2));
gEnv->p3DEngine->SetPostEffectParam("Flashbang_Active", 1);
}
}
else if(inFOV && (dist < explosionInfo.radius))
{
if (explosionInfo.damage > 10.0f || explosionInfo.pressure > 100.0f)
{
//Add some angular impulse to the client actor depending on distance, direction...
float dt = (1.0f - dist / explosionInfo.radius);
dt = dt * dt;
float angleZ = gf_PI * 0.15f * dt;
float angleX = gf_PI * 0.15f * dt;
pActor->AddAngularImpulse(Ang3(Random(-angleX * 0.5f, angleX), 0.0f, Random(-angleZ, angleZ)), 0.0f, dt * 2.0f);
}
}
}
}
示例4: Shoot
//.........这里部分代码省略.........
CheckNearMisses(hit, pos, fdir, WEAPON_HIT_RANGE, m_pShared->shotgunparams.spread);
bool serverSpawn = m_pWeapon->IsServerSpawn(ammo);
// SHOT HERE
for(int i = 0; i < m_pShared->shotgunparams.pellets; i++)
{
CProjectile *pAmmo = m_pWeapon->SpawnAmmo(ammo, false);
if(pAmmo)
{
dir = ApplySpread(fdir, m_pShared->shotgunparams.spread);
int hitTypeId = g_pGame->GetGameRules()->GetHitTypeId(m_pShared->fireparams.hit_type.c_str());
pAmmo->SetParams(m_pWeapon->GetOwnerId(), m_pWeapon->GetHostId(), m_pWeapon->GetEntityId(), m_pShared->shotgunparams.pelletdamage, hitTypeId, playerIsShooter?m_pShared->fireparams.damage_drop_per_meter:0.0f, m_pShared->fireparams.damage_drop_min_distance);
pAmmo->SetDestination(m_pWeapon->GetDestination());
pAmmo->Launch(pos, dir, vel);
if((!m_pShared->tracerparams.geometry.empty() || !m_pShared->tracerparams.effect.empty()) && (ammoCount==GetClipSize() || (ammoCount%m_pShared->tracerparams.frequency==0)))
{
EmitTracer(pos,hit,false);
}
m_projectileId = pAmmo->GetEntity()->GetId();
}
}
m_pWeapon->OnShoot(m_pWeapon->GetOwnerId(), 0, ammo, pos, dir, vel);
if(m_pWeapon->IsServer())
{
const char *ammoName = ammo != NULL ? ammo->GetName() : NULL;
g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(m_pWeapon->GetOwner(), GameplayEvent(eGE_WeaponShot, ammoName, m_pShared->shotgunparams.pellets, (void *)m_pWeapon->GetEntityId()));
}
MuzzleFlashEffect(true);
RejectEffect();
m_fired = true;
m_next_shot += m_next_shot_dt;
m_zoomtimeout = m_next_shot + 0.5f;
ammoCount--;
if(playerIsShooter)
{
if(pActor->InZeroG())
{
IEntityPhysicalProxy *pPhysicsProxy = (IEntityPhysicalProxy *)pActor->GetEntity()->GetProxy(ENTITY_PROXY_PHYSICS);
SMovementState ms;
pActor->GetMovementController()->GetMovementState(ms);
CPlayer *plr = (CPlayer *)pActor;
if(m_recoilparams.back_impulse > 0.0f)
{
Vec3 impulseDir = ms.aimDirection * -1.0f;
Vec3 impulsePos = ms.pos;
float impulse = m_recoilparams.back_impulse;
pPhysicsProxy->AddImpulse(-1, impulsePos, impulseDir * impulse * 100.0f, true, 1.0f);
}
if(m_recoilparams.angular_impulse > 0.0f)
{
float impulse = m_recoilparams.angular_impulse;
pActor->AddAngularImpulse(Ang3(0,impulse,0), 1.0f);
}
}
if(pActor->IsClient())
if(gEnv->pInput)
gEnv->pInput->ForceFeedbackEvent(SFFOutputEvent(eDI_XI, eFF_Rumble_Basic, 0.15f, 0.0f, fabsf(m_recoilparams.back_impulse)*3.0f));
}
if(m_pShared->fireparams.clip_size != -1)
{
if(m_pShared->fireparams.clip_size!=0)
m_pWeapon->SetAmmoCount(ammo, ammoCount);
else
m_pWeapon->SetInventoryAmmoCount(ammo, ammoCount);
}
if((ammoCount<1) && !m_pShared->fireparams.slider_layer.empty())
{
const char *slider_back_layer = m_pShared->fireparams.slider_layer.c_str();
m_pWeapon->PlayLayer(slider_back_layer, CItem::eIPAF_Default|CItem::eIPAF_NoBlend);
}
if(OutOfAmmo())
{
m_pWeapon->OnOutOfAmmo(ammo);
if(autoreload)
{
m_pWeapon->GetScheduler()->TimerAction(m_pWeapon->GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleReload>::Create(m_pWeapon), false);
}
}
m_pWeapon->RequestShoot(ammo, pos, dir, vel, hit, 1.0f, 0, false);
return true;
}