本文整理汇总了C++中IPhysicalWorld::GetPhysicalEntityById方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicalWorld::GetPhysicalEntityById方法的具体用法?C++ IPhysicalWorld::GetPhysicalEntityById怎么用?C++ IPhysicalWorld::GetPhysicalEntityById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPhysicalWorld
的用法示例。
在下文中一共展示了IPhysicalWorld::GetPhysicalEntityById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateFlow
void CTornado::UpdateFlow()
{
IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem();
assert(pVehicleSystem);
float frameTime(gEnv->pTimer->GetFrameTime());
IPhysicalWorld *ppWorld = gEnv->pPhysicalWorld;
Vec3 pos(GetEntity()->GetWorldPos());
//first, check the entities in range
m_nextEntitiesCheck -= frameTime;
if (m_nextEntitiesCheck<0.0f)
{
m_nextEntitiesCheck = 1.0f;
Vec3 radiusVec(m_radius,m_radius,0);
IPhysicalEntity **ppList = NULL;
int numEnts = ppWorld->GetEntitiesInBox(pos-radiusVec,pos+radiusVec+Vec3(0,0,m_cloudHeight*0.5f),ppList,ent_sleeping_rigid|ent_rigid|ent_living);
m_spinningEnts.clear();
for (int i=0;i<numEnts;++i)
{
// add check for spectating players...
EntityId id = ppWorld->GetPhysicalEntityId(ppList[i]);
CActor* pActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
if(!pActor || !pActor->GetSpectatorMode())
{
m_spinningEnts.push_back(id);
}
}
//OutputDistance();
}
//mess entities around
for (size_t i=0;i<m_spinningEnts.size();++i)
{
IPhysicalEntity *ppEnt = ppWorld->GetPhysicalEntityById(m_spinningEnts[i]);
if (ppEnt)
{
pe_status_pos spos;
pe_status_dynamics sdyn;
if (!ppEnt->GetStatus(&spos) || !ppEnt->GetStatus(&sdyn))
continue;
//gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(spos.pos,2.0f,ColorB(255,0,255,255));
Vec3 delta(pos - spos.pos);
delta.z = 0.0f;
float dLen(delta.len());
float forceMult(max(0.0f,(m_radius-dLen)/m_radius));
if (dLen>0.001f)
delta /= dLen;
else
delta.zero();
Vec3 upVector(0,0,1);
float spinImpulse(m_spinImpulse);
float attractionImpulse(m_attractionImpulse);
float upImpulse(m_upImpulse);
if (ppEnt->GetType() == PE_LIVING)
{
upImpulse *= 0.75f;
attractionImpulse *= 0.35f;
spinImpulse *= 1.5f;
}
if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(m_spinningEnts[i]))
{
IVehicleMovement* pMovement = pVehicle->GetMovement();
if (pMovement && pMovement->GetMovementType() == IVehicleMovement::eVMT_Air)
{
SVehicleMovementEventParams params;
params.fValue = forceMult;
pMovement->OnEvent(IVehicleMovement::eVME_Turbulence, params);
}
}
Vec3 spinForce( (delta % upVector) * spinImpulse );
Vec3 attractionForce(delta * attractionImpulse);
Vec3 upForce(0,0,upImpulse);
pe_action_impulse aimpulse;
aimpulse.impulse = (spinForce + attractionForce + upForce) * (forceMult * sdyn.mass * frameTime);
aimpulse.angImpulse = (upVector + (delta % upVector)) * (gf_PI * 0.33f * forceMult * sdyn.mass * frameTime);
aimpulse.iApplyTime = 0;
ppEnt->Action(&aimpulse);
//.........这里部分代码省略.........