本文整理汇总了C++中IEntity::GetForwardDir方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntity::GetForwardDir方法的具体用法?C++ IEntity::GetForwardDir怎么用?C++ IEntity::GetForwardDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity::GetForwardDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetProbableHit
bool CControlledLocator::GetProbableHit(EntityId weaponId, const IFireMode* pFireMode, Vec3& hit)
{
bool ret = false;
IEntity *entity = gEnv->pEntitySystem->GetEntity(weaponId);
if (entity)
{
const Vec3 &dir = entity->GetForwardDir();
hit = entity->GetWorldTM().GetTranslation() + dir * WEAPON_CONTROLLED_HIT_RANGE;
ret = true;
}
return ret;
}
示例2: DebugOnInputEvent
//--------------------------------------------------------------------------------------------------
// Name: DebugOnInputEvent
// Desc: Called when input events happen in debug builds
//--------------------------------------------------------------------------------------------------
void CExplosionGameEffect::DebugOnInputEvent(int keyId)
{
// Initialise static version of effect
static CExplosionGameEffect explosionGameEffect;
if(!explosionGameEffect.IsFlagSet(GAME_EFFECT_INITIALISED))
{
explosionGameEffect.Initialise();
explosionGameEffect.SetFlag(GAME_EFFECT_DEBUG_EFFECT,true);
explosionGameEffect.SetFlag(GAME_EFFECT_AUTO_RELEASE,true);
explosionGameEffect.SetActive(true);
}
// Get player pos
Vec3 playerDir(0.0f,0.0f,0.0f);
Vec3 playerPos(0.0f,0.0f,0.0f);
EntityId localClientId = gEnv->pGame->GetIGameFramework()->GetClientActorId();
if(localClientId != 0)
{
IEntity* playerEntity = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(localClientId)->GetEntity();
playerDir = playerEntity->GetForwardDir();
playerPos = playerEntity->GetPos();
}
// Distance from player controlled by keyboard
static float distFromPlayer = 0.0f;
static float distStep = 1.0f;
switch(keyId)
{
case eKI_NP_Multiply:
{
distFromPlayer += distStep;
break;
}
case eKI_NP_Divide:
{
distFromPlayer -= distStep;
break;
}
case eKI_NP_0:
{
distFromPlayer = 0.0f;
break;
}
case eKI_NP_1:
{
// Frag
SExplosionContainer explosionContainer;
ExplosionInfo& explosionInfo = explosionContainer.m_explosionInfo;
explosionInfo.pParticleEffect = gEnv->pParticleManager->FindEffect("Crysis2_weapon_explosives.frag.concrete");
explosionInfo.pos = playerPos + (playerDir * distFromPlayer);
explosionInfo.dir.Set(0.0f,-1.0f,0.0f);
explosionInfo.effect_scale = 1.0f;
explosionInfo.pressure = 1000.0f;
explosionInfo.maxblurdistance = 10.0;
explosionInfo.radius = 15.0;
explosionInfo.blindAmount = 0.0f;
explosionInfo.flashbangScale = 8.0f;
explosionInfo.damage = 5.0f;
explosionInfo.hole_size = 0.0f;
explosionGameEffect.Explode(explosionContainer);
break;
}
case eKI_NP_2:
{
// Flashbang
SExplosionContainer explosionContainer;
ExplosionInfo& explosionInfo = explosionContainer.m_explosionInfo;
explosionInfo.pParticleEffect = gEnv->pParticleManager->FindEffect("Crysis2_weapon_explosives.grenades.flash_explosion");
explosionInfo.pos = playerPos + (playerDir * distFromPlayer);
explosionInfo.dir.Set(0.0f,-1.0f,0.0f);
explosionInfo.effect_scale = 1.0f;
explosionInfo.pressure = 1000.0f;
explosionInfo.maxblurdistance = 10.0;
explosionInfo.radius = 15.0;
explosionInfo.blindAmount = 0.66f;
explosionInfo.flashbangScale = 8.0f;
explosionInfo.damage = 5.0f;
explosionInfo.hole_size = 0.0f;
explosionGameEffect.Explode(explosionContainer);
break;
}
case eKI_NP_3:
{
// L-Tag
SExplosionContainer explosionContainer;
ExplosionInfo& explosionInfo = explosionContainer.m_explosionInfo;
explosionInfo.pParticleEffect = gEnv->pParticleManager->FindEffect("Crysis2_weapon_fx.l-tag.rico_explosion");
explosionInfo.pos = playerPos + (playerDir * distFromPlayer);
explosionInfo.dir.Set(0.0f,-1.0f,0.0f);
explosionInfo.effect_scale = 1.0f;
explosionInfo.pressure = 1000.0f;
explosionInfo.maxblurdistance = 10.0;
explosionInfo.radius = 15.0;
explosionInfo.blindAmount = 0.0f;
explosionInfo.flashbangScale = 8.0f;
//.........这里部分代码省略.........
示例3: Update
/// Used to update any time dependent state (such as timeouts)
void CFlowNode_FeatureTest::Update(float deltaTime)
{
if(m_running)
{
m_timeRunning += deltaTime;
CryWatch("$7[FG FeatureTest]$o Running test '%s'", Name());
const string &description = GetPortString(&m_actInfo, eInputPorts_Description);
if(!description.empty())
CryWatch("$7[FG FeatureTest]$o %s", description.c_str());
const float maxTime = GetPortFloat(&m_actInfo, eInputPorts_MaxTime);
IEntity *pFollowEntity = NULL;
// Firstly, attempt to get the camera entity (index: -1)
bool bHasEntry = GetEntityAtIndex(-1, pFollowEntity);
if(!bHasEntry && !pFollowEntity)
{
// If there's an entity being tested, force the view camera to follow it (if no camera entity defined)
// This needs to be implemented in a cleaner way and allow other options for non-entity based tests.
bHasEntry = GetEntityAtIndex(m_entitySeqIndex, pFollowEntity);
// If no sequence entity defined
if(!bHasEntry && !pFollowEntity)
{
// Look for another suitable (active) entity to follow
for(int i = 0; i < SEQ_ENTITY_COUNT; ++i)
{
GetEntityAtIndex(i, pFollowEntity);
if(pFollowEntity && pFollowEntity->IsActive())
{
break;
}
}
}
}
if(pFollowEntity)
{
CCamera &viewCamera = gEnv->pSystem->GetViewCamera();
Vec3 vPos(0,0,0);
Vec3 vDir(0,0,0);
AABB bounds;
pFollowEntity->GetWorldBounds(bounds);
Vec3 vTarget;
vTarget = bounds.GetCenter();
vPos = vTarget + (pFollowEntity->GetForwardDir().GetNormalizedSafe() * -2.5f) + Vec3(0.0f, 0.0f, 1.0f);
vDir = (vTarget - vPos).GetNormalizedSafe();
float fRoll(0.0f);
viewCamera.SetMatrix(CCamera::CreateOrientationYPR(CCamera::CreateAnglesYPR(vDir, fRoll)));
viewCamera.SetPosition(vPos);
}
// If a valid max time has been set
if(maxTime > 0.0f)
{
// If test has exceeded max time
if(m_timeRunning >= maxTime)
{
OnTestResult(false, string().Format("Test failed: Test exceeded maximum time (%f).", maxTime).c_str());
}
}
}
}