当前位置: 首页>>代码示例>>C++>>正文


C++ IPhysicalEntity::Action方法代码示例

本文整理汇总了C++中IPhysicalEntity::Action方法的典型用法代码示例。如果您正苦于以下问题:C++ IPhysicalEntity::Action方法的具体用法?C++ IPhysicalEntity::Action怎么用?C++ IPhysicalEntity::Action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPhysicalEntity的用法示例。


在下文中一共展示了IPhysicalEntity::Action方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IgnoreCollision

void CBaseGrabHandler::IgnoreCollision(EntityId eID,unsigned int flags,bool ignore)
{
	IEntity *pGrab = gEnv->pEntitySystem->GetEntity(eID);
	IPhysicalEntity *ppGrab = pGrab ? pGrab->GetPhysics() : NULL;

	if(!ppGrab) return;

	if(ignore)
	{
		// NOTE Dez 14, 2006: <pvl> this whole block just fills in
		// a request structure and passes it to physics
		IEntity *pEnt = m_pActor->GetEntity();

		pe_action_add_constraint ac;
		ac.flags = constraint_inactive|constraint_ignore_buddy;
		ac.pBuddy = pEnt->GetPhysics();
		ac.pt[0].Set(0,0,0);

		ICharacterInstance *pCharacter = pEnt->GetCharacter(0);
		IPhysicalEntity *pPhysEnt = pCharacter?pCharacter->GetISkeletonPose()->GetCharacterPhysics(-1):NULL;

		if(pPhysEnt)
		{
			pe_simulation_params sp;
			pPhysEnt->GetParams(&sp);

			if(sp.iSimClass <= 2)
				ac.pBuddy = pPhysEnt;
		}

		ppGrab->Action(&ac);
	}
	else
	{
		// NOTE Dez 14, 2006: <pvl> the same as the other branch - just
		// fill in a request and pass it to the physics engine
		pe_action_update_constraint uc;
		uc.bRemove = 1;

		ppGrab->Action(&uc);
	}

	// NOTE Dez 14, 2006: <pvl> flag manipulation is basically a legacy
	// code - probably not used anymore, scheduled for removal.
	if(flags)
	{
		pe_params_part pp;
		pp.flagsAND = pp.flagsColliderAND = ~flags;
		pp.flagsOR = pp.flagsColliderOR = flags * (ignore?0:1);

		pe_status_nparts status_nparts;

		for(pp.ipart = ppGrab->GetStatus(&status_nparts)-1; pp.ipart>=0; pp.ipart--)
			ppGrab->SetParams(&pp);
	}
}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:56,代码来源:GrabHandler.cpp

示例2: OnDetectObjectEmbedded

void CIntersectionAssistanceUnit::OnDetectObjectEmbedded()
{
    m_embedState = eES_Embedded;

    // How do we react to the bad news?
    if(m_resolutionPolicy == eRP_DeleteObject)
        {
            CGameRules *pGameRules=g_pGame->GetGameRules();
            assert(pGameRules);
            if (pGameRules)
                {
                    pGameRules->ScheduleEntityRemoval(m_subjectEntityId, 0.0f, true);
                }
        }
    else
        {
            IEntity* pEntity = gEnv->pEntitySystem->GetEntity(m_subjectEntityId);
            if(pEntity)
                {
                    IPhysicalEntity* pPhysical = pEntity->GetPhysics();
                    if(pPhysical)
                        {
                            // Force entity to sleep (for now)
                            pe_action_awake pa;
                            pa.bAwake = 0;
                            pPhysical->Action( &pa );
                        }
                }
        }
}
开发者ID:eBunny,项目名称:EmberProject,代码行数:30,代码来源:IntersectionAssistanceUnit.cpp

示例3: StartDrop

bool CBaseGrabHandler::StartDrop()
{
	IEntity *pGrab = gEnv->pEntitySystem->GetEntity(m_grabStats.grabId);
	IPhysicalEntity *pGrabPhys = pGrab ? pGrab->GetPhysics() : NULL;

	if (pGrabPhys && m_grabStats.throwVector.len2()>0.01f)
	{	
		pe_action_set_velocity asv;
		asv.v = m_grabStats.throwVector;

		asv.w.x = -1.0f + (cry_rand()/(float)RAND_MAX*(float)(2.0f));
		asv.w.y = -1.0f + (cry_rand()/(float)RAND_MAX*(float)(2.0f));
		asv.w.z = -1.0f + (cry_rand()/(float)RAND_MAX*(float)(2.0f));
		asv.w.NormalizeSafe();
		asv.w *= 2.0f;

		pGrabPhys->Action(&asv);
	}

	if (m_grabStats.grabId>0)
	{
		m_grabStats.dropId = m_grabStats.grabId;
		m_grabStats.resetFlagsDelay = 1.0f;

		m_pActor->CreateScriptEvent("droppedObject",(float)m_grabStats.grabId);

		if (pGrab) DisableGrabbedAnimatedCharacter (false);
	}

	m_grabStats.Reset();

	return true;
}
开发者ID:AiYong,项目名称:CryGame,代码行数:33,代码来源:GrabHandler.cpp

示例4: Update

void CBaseGrabHandler::Update(float frameTime)
{

	//we have to restore the grabbed object collision flag at some point after the throw.
	if(m_grabStats.dropId>0)
	{
		m_grabStats.resetFlagsDelay -= frameTime;

		if(m_grabStats.resetFlagsDelay<0.001f)
		{
			IgnoreCollision(m_grabStats.dropId,m_grabStats.collisionFlags,false);
			m_grabStats.dropId = 0;
		}
	}

	if(m_grabStats.grabId<1)
		return;

	if(m_pActor->GetHealth()<=0)
	{
		StartDrop();
		return;
	}

	IEntity *pGrab = gEnv->pEntitySystem->GetEntity(m_grabStats.grabId);

	if(pGrab)
	{
		bool grabbing(m_grabStats.grabDelay>0.001f);

		if(!grabbing || m_grabStats.usingAnimation)
			UpdatePosVelRot(frameTime);
	}
	else
	{
		//in case the grabber lost the grabbed object, reset the ignore collision flags

		// FIXME Dez 14, 2006: <pvl> the following should be done by
		// calling IgnoreCollisions() but that function requires
		// id of the grabbed object => needs refactoring
		IPhysicalEntity *pActorPhys = m_pActor->GetEntity()->GetPhysics();

		if(pActorPhys)
		{
			pe_action_update_constraint uc;
			uc.bRemove = 1;

			pActorPhys->Action(&uc);
		}
	}

	// TODO Sep 13, 2007: <pvl> I strongly suspect releaseIKTime is redundant now.
	// NOTE Sep 13, 2007: <pvl> note that all timeouts are dodgy here since there's
	// no guarantee that the grabbing/throwing animation starts playing immediately
	// after the grabbing command is issued.
	if(m_grabStats.releaseIKTime>0.001f && m_grabStats.grabDelay < 0.001f)
		m_grabStats.releaseIKTime -= frameTime;
}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:58,代码来源:GrabHandler.cpp

示例5: AwakeCoaches

void CFlowConvoyNode::AwakeCoaches() //awake the physics
{
	pe_action_awake aa; 
	aa.bAwake=1;
	for (size_t i = 0; i < m_coaches.size(); ++i)
	{
		IPhysicalEntity* pPhysics = m_coaches[i].m_pEntity->GetPhysics();
		pPhysics->Action(&aa);
	}
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:10,代码来源:FlowConvoyNode.cpp

示例6: OnRagdollized

void CReplayActor::OnRagdollized()
{
	if(!m_ragdollImpulse.impulse.IsZero())
	{
		IPhysicalEntity* pPhys = GetEntity()->GetPhysics();
		CRY_ASSERT(pPhys && pPhys->GetType()==PE_ARTICULATED);
		pPhys->Action(&m_ragdollImpulse);
	}
	m_ragdollImpulse.impulse.zero();
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:10,代码来源:ReplayActor.cpp

示例7: ApplyRagdollImpulse

void CReplayActor::ApplyRagdollImpulse( pe_action_impulse& impulse )
{
	IPhysicalEntity* pPhys = GetEntity()->GetPhysics();
	if(!pPhys || pPhys->GetType()!=PE_ARTICULATED)
	{
		m_ragdollImpulse = impulse;
	}
	else
	{
		pPhys->Action(&impulse);
	}
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:12,代码来源:ReplayActor.cpp

示例8: OnDamageEvent

//------------------------------------------------------------------------
void CVehicleDamageBehaviorImpulse::OnDamageEvent(EVehicleDamageBehaviorEvent event, const SVehicleDamageBehaviorEventParams& behaviorParams)
{
	if (event == eVDBE_Hit || event == eVDBE_VehicleDestroyed || event == eVDBE_ComponentDestroyed)  
	{
		IEntity* pEntity = m_pVehicle->GetEntity();
		CRY_ASSERT(pEntity);

		IPhysicalEntity* pPhysEntity = pEntity->GetPhysics();
		if (!pPhysEntity)
			return;

		pe_status_dynamics dyn;
		pPhysEntity->GetStatus(&dyn);
		float vehicleMass = dyn.mass;

		float r = cry_random(0.0f, 2.f);
		float impulseForce = cry_random(m_forceMin, m_forceMax) * vehicleMass;		

    Vec3 impulseDir(m_impulseDir);
    if (!m_worldSpace)
      impulseDir = m_pVehicle->GetEntity()->GetWorldTM().TransformVector(impulseDir);

		pe_action_impulse actionImpulse;
		Vec3& impulse = actionImpulse.impulse;
		Vec3& angImpulse = actionImpulse.angImpulse;

		impulse = impulseDir * impulseForce;
		angImpulse = m_pVehicle->GetEntity()->GetWorldTM().TransformVector(m_angImpulse);

		if (r <= 0.75f)
		{
			float r1 = cry_random(-0.35f, 0.35f);

			angImpulse += dyn.v * r1 * max(1.0f, dyn.w.GetLength());
			angImpulse *= vehicleMass;
		}
		else
		{
			float r1 = cry_random(-0.25f, 0.25f);
			float r2 = cry_random(-0.5f, 0.5f);

			impulse.z += abs(dyn.v.y) * r1 * vehicleMass;
			angImpulse.x += dyn.v.y * r2 * vehicleMass * max(1.0f, dyn.w.GetLength() * 1.5f);
		}

		if (m_pImpulseLocation)
			actionImpulse.point = m_pImpulseLocation->GetWorldSpaceTranslation();

		pPhysEntity->Action(&actionImpulse);
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:52,代码来源:VehicleDamageBehaviorImpulse.cpp

示例9: UpdateInterpolation

void CNetPlayerInput::UpdateInterpolation()
{
	Vec3 desiredPosition = m_curInput.position;
	Vec3 desiredVelocity = m_curInput.deltaMovement * g_pGameCVars->pl_netSerialiseMaxSpeed;

	// Use the physics pos as the entity position is a frame behind at this point
	IPhysicalEntity * pent = m_pPlayer->GetEntity()->GetPhysics();
	pe_status_pos psp;
	pent->GetStatus(&psp);
	Vec3 entPos = psp.pos;

	pe_status_living psl;
	psl.velGround.zero();
	pent->GetStatus(&psl);
	
	float dt = gEnv->pTimer->GetFrameTime();

	// New data?
	if (m_newInterpolation)
		m_lerper.AddNewPoint(m_curInput.position, desiredVelocity, entPos, m_curInput.standingOn);

	bool bInAirOrJumping = m_pPlayer->GetActorStats()->inAir > 0.01f || m_pPlayer->GetActorStats()->onGround < 0.01f;

	// Predict
	CNetLerper::SPrediction prediction;
	m_lerper.Update(gEnv->pTimer->GetFrameTime(), entPos, prediction, psl.velGround, bInAirOrJumping);

	// Update lerp velocity
	m_lerpVel = prediction.lerpVel;

	// Should Snap
	if (prediction.shouldSnap)
	{
		m_pPlayer->GetEntity()->SetPos(prediction.predictedPos);

		pe_action_set_velocity actionVel;
		actionVel.v = prediction.lerpVel;
		pent->Action(&actionVel);
	}

#if !defined(_RELEASE)
	// Debug Draw
	if (g_pGameCVars->pl_debugInterpolation)
		m_lerper.DebugDraw(prediction, entPos, m_newInterpolation);
	else
		SAFE_DELETE(m_lerper.m_debug);
#endif

	m_newInterpolation = false;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:50,代码来源:NetPlayerInput.cpp

示例10: DeathBlow

//-----------------------------------------------------------------------
void CSpectacularKill::DeathBlow(CActor& targetActor)
{
	CRY_ASSERT_MESSAGE(m_isBusy, "spectacular kill should be in progress when triggering the death blow");
	if (!m_isBusy)
		return;

	if (targetActor.IsDead())
		return;

	Vec3 targetDir = targetActor.GetEntity()->GetForwardDir();

	{
		HitInfo hitInfo;
		hitInfo.shooterId = m_pOwner->GetEntityId();
		hitInfo.targetId = targetActor.GetEntityId();
		hitInfo.damage = 99999.0f; // CERTAIN_DEATH
		hitInfo.dir = targetDir;
		hitInfo.normal = -hitInfo.dir; // this has to be in an opposite direction from the hitInfo.dir or the hit is ignored as a 'backface' hit
		hitInfo.type = CGameRules::EHitType::StealthKill;

		g_pGame->GetGameRules()->ClientHit(hitInfo);
	}

	// WARNING: RagDollize resets the entity's rotation!
	//  [7/30/2010 davidr] FixMe: If the entity isn't dead here (because is immortal or any other reason) ragdollizing it will
	// leave it on an inconsistent state (usually only reproducible on debug scenarios)
	targetActor.GetGameObject()->SetAspectProfile(eEA_Physics, eAP_Ragdoll);

	// Give a small nudge in the hit direction to make the target fall over
	const SSpectacularKillParams* pSpectacularKillParams = GetParamsForClass(targetActor.GetEntity()->GetClass());
	CRY_ASSERT(pSpectacularKillParams);
	if (pSpectacularKillParams && (pSpectacularKillParams->impulseScale > 0.0f) && (pSpectacularKillParams->impulseBone != -1))
	{
		const float killDeathBlowVelocity = pSpectacularKillParams->impulseScale; // desired velocity after impulse in meters per second

		IPhysicalEntity* pTargetPhysics = targetActor.GetEntity()->GetPhysics();
		if (pTargetPhysics)
		{
			pe_simulation_params simulationParams;
			pTargetPhysics->GetParams(&simulationParams);

			pe_action_impulse impulse;
			impulse.partid = pSpectacularKillParams->impulseBone;
			impulse.impulse = targetDir*killDeathBlowVelocity*simulationParams.mass; // RagDollize reset the entity's rotation so I have to use the value I cached earlier
			pTargetPhysics->Action(&impulse);
		}
	}

	m_deathBlowState = eDBS_Done;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:51,代码来源:SpectacularKill.cpp

示例11: ResetVelocity

	void ResetVelocity(SActivationInfo* pActInfo)
	{
		IEntity* pGraphEntity = pActInfo->pEntity;
		if (pGraphEntity)
		{
			IPhysicalEntity* pPhysicalEntity = pGraphEntity->GetPhysics();
			if (pPhysicalEntity && pPhysicalEntity->GetType() != PE_STATIC)
			{
				pe_action_set_velocity setVel;
				setVel.v.zero();
				setVel.w.zero();
				pPhysicalEntity->Action(&setVel);
			}
		}
	}
开发者ID:joewan,项目名称:pycmake,代码行数:15,代码来源:OwnerAngularRotationNode.cpp

示例12: RaiseWeapon

void CFists::RaiseWeapon(bool raise, bool faster /*= false*/)
{
	//Only when colliding something while running
	if(raise && (GetCurrentAnimState()==eFAS_RUNNING || GetCurrentAnimState()==eFAS_JUMPING) && !IsWeaponRaised())
	{
		if((m_fm && m_fm->IsFiring())||(m_melee && m_melee->IsFiring()))
			return;

		PlayAction(g_pItemStrings->raise);

		SetDefaultIdleAnimation( eIGS_FirstPerson,g_pItemStrings->idle_relaxed);
		SetWeaponRaised(true);

		//Also give the player some impulse into the opposite direction
		CActor *pPlayer = GetOwnerActor();
		Vec3		pos;
		if(pPlayer)
		{
			IPhysicalEntity* playerPhysics = pPlayer->GetEntity()->GetPhysics();
			if(playerPhysics)
			{
				IMovementController *pMC = pPlayer->GetMovementController();
				if(pMC)
				{
					SMovementState state;
					pMC->GetMovementState(state);
					
					pe_action_impulse impulse;
					impulse.iApplyTime = 1;
					impulse.impulse = -state.eyeDirection*600.0f;
					playerPhysics->Action(&impulse);

					pos = state.eyePosition + state.eyeDirection*0.5f;
				}
				
			}
		}

		GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true);

		//Sound and FX feedback
		CollisionFeeback(pos,m_currentAnimState);
	}
	else if(!raise)
		SetWeaponRaised(false);

}
开发者ID:AiYong,项目名称:CryGame,代码行数:47,代码来源:Fists.cpp

示例13: RecoilImpulse

void CRecoil::RecoilImpulse(const Vec3& firingPos, const Vec3& firingDir)
{
	if (m_recoilParams.impulse > 0.f)
	{
		EntityId id = (m_pWeapon->GetHostId()) ? m_pWeapon->GetHostId() : m_pWeapon->GetOwnerId();
		IEntity* pEntity = gEnv->pEntitySystem->GetEntity(id);
		IPhysicalEntity* pPhysicalEntity = pEntity ? pEntity->GetPhysics() : NULL;

		if (pPhysicalEntity)
		{        
			pe_action_impulse impulse;
			impulse.impulse = -firingDir * m_recoilParams.impulse; 
			impulse.point = firingPos;
			pPhysicalEntity->Action(&impulse);
		}
	}
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:17,代码来源:Recoil.cpp

示例14: UpdateStumble

void CLocalPlayerComponent::UpdateStumble( const float frameTime )
{
	IEntity * pEntity = m_rPlayer.GetEntity();

	IPhysicalEntity * pPhysEntity = pEntity->GetPhysics();

	if ( pPhysEntity )
	{
		pe_status_dynamics dynamics;
		pPhysEntity->GetStatus( &dynamics );
		if ( m_playerStumble.Update( frameTime, dynamics ) )
		{
			pe_action_impulse ai; 
			ai.impulse = m_playerStumble.GetCurrentActionImpulse();
			pPhysEntity->Action( &ai );
		}
	}
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:18,代码来源:LocalPlayerComponent.cpp

示例15: Update

//------------------------------------------------------------------------
void CVehicleActionEntityAttachment::Update(const float deltaTime)
{
	if(m_isAttached)
		return;

	IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
	assert(pEntitySystem);

	IEntity *pEntity = pEntitySystem->GetEntity(m_entityId);

	if(!pEntity)
		return;

	IPhysicalEntity *pPhysEntity = pEntity->GetPhysics();

	if(!pPhysEntity)
		return;

	pe_simulation_params paramsSim;
	float gravity;

	if(pPhysEntity->GetParams(&paramsSim))
		gravity = abs(paramsSim.gravity.z);
	else
		gravity = 9.82f;

	pe_status_dynamics dyn;

	if(pPhysEntity->GetStatus(&dyn))
	{
		pe_action_impulse impulse;
		impulse.impulse  = Matrix33(pEntity->GetWorldTM()) * Vec3(0.0f, 0.0f, 1.0f) * g_parachuteForce * gravity;
		impulse.impulse = impulse.impulse - dyn.v;
		impulse.impulse *= dyn.mass * deltaTime;
		impulse.iSource = 3;

		pPhysEntity->Action(&impulse);
	}

	m_timer -= deltaTime;

	if(m_timer <= 0.0f || dyn.v.z >= 0.0f)
		m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_NoUpdate);
}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:45,代码来源:VehicleActionEntityAttachment.cpp


注:本文中的IPhysicalEntity::Action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。