コード例 #1
0
ファイル: BlendedEffect.cpp プロジェクト: eBunny/EmberProject
//---------------------------------
void CFOVEffect::Reset()
{
    IActor *pClientActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
    if (pClientActor)
        {
            CPlayer *pPlayer = (CPlayer *)pClientActor;
            pPlayer->GetActorParams().viewFoVScale = m_goalFOV;
        }
}
コード例 #2
0
ファイル: BlendedEffect.cpp プロジェクト: eBunny/EmberProject
//---------------------------------
void CFOVEffect::Update(float point)
{
    m_currentFOV = (point * (m_goalFOV - m_startFOV)) + m_startFOV;
    IActor *pClientActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
    if (pClientActor)
        {
            CPlayer *pPlayer = (CPlayer *)pClientActor;
            pPlayer->GetActorParams().viewFoVScale = m_currentFOV;
        }
}
コード例 #3
0
//------------------------------------------------------------------------
void CVehicleMountedWeapon::CorrectRipperEntityPosition(float timeStep)
{
	IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId);
	if(pVehicle)
	{
		const IEntity* pVehicleEnt = pVehicle->GetEntity();

		Vec3 posDiff(ZERO);
		IActor* pOwner = GetOwnerActor();
		if (pOwner && pOwner->IsPlayer())
		{
			CPlayer* pPlayer	 = static_cast<CPlayer*>(pOwner); 
			const Matrix34& wMat = pVehicleEnt->GetWorldTM(); 
			Vec3 vehiclePos		 = wMat.GetTranslation();
			Vec3 currWSpaceRipUserOffset = wMat.TransformPoint(m_localRipUserOffset);

			posDiff = currWSpaceRipUserOffset - m_previousWSpaceOffsetPosition;

			// Don't want to overwrite anyone else changes with an absolute 'set'
			pOwner->GetEntity()->SetPos(pOwner->GetEntity()->GetWorldPos() + posDiff); 

			m_previousWSpaceOffsetPosition = currWSpaceRipUserOffset;

			//Update view limit direction based on change in vehicle rotation
			if(pPlayer->IsClient())
			{
				SViewLimitParams &viewLimits = pPlayer->GetActorParams().viewLimits;
				if(viewLimits.GetViewLimitRangeH()) //Don't do this unless we are currently horizontally constrained
				{
					Quat vehicleRotation(wMat);
					Quat rotationChange = vehicleRotation * m_previousVehicleRotation.GetInverted();

					Vec3 viewLimitDir = rotationChange * viewLimits.GetViewLimitDir();
					viewLimitDir.z = 0.f;
					viewLimitDir.Normalize();

					viewLimits.SetViewLimit(viewLimitDir, 0.01f, 0.01f, 0.f, 0.f, SViewLimitParams::eVLS_Item);

					m_previousVehicleRotation = vehicleRotation;
				}

				//Reset the pitch/roll view angles over time
				Quat viewDirFinal = pPlayer->GetViewQuatFinal();
				Ang3 viewAngles(viewDirFinal);
				float xAdjustment = (float)__fsel(viewAngles.x, max(-viewAngles.x, -0.5f * timeStep), min(-viewAngles.x, 0.5f * timeStep));
				float yAdjustment = (float)__fsel(viewAngles.y, max(-viewAngles.y, -0.5f * timeStep), min(-viewAngles.y, 0.5f * timeStep));

				if(xAdjustment || yAdjustment)
				{
					pPlayer->AddViewAngles(Ang3(xAdjustment, yAdjustment, 0.f));
				}
			}
		}
	}
}
コード例 #4
0
//---------------------------------
float CScreenEffects::GetCurrentFOV()
{
	
	if (m_ownerActor->IsPlayer())
	{
		CPlayer *player = (CPlayer *)m_ownerActor;
		SActorParams *params = player->GetActorParams();
		return params->viewFoVScale;
	}
	return 1.0f;
}
コード例 #5
0
//---------------------------------
void CFOVEffect::Update(float point)
{
	m_currentFOV = (point * (m_goalFOV - m_startFOV)) + m_startFOV;
	IActor *client = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerID);
	if (client && client->IsPlayer())
	{
		CPlayer *player = (CPlayer *)client;
		SActorParams *params = player->GetActorParams();
		params->viewFoVScale = m_currentFOV;
	}
}
コード例 #6
0
//---------------------------------
void CFOVEffect::Init()
{
	IActor *client = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_ownerID);
	if (client && client->IsPlayer())
	{
		CPlayer *player = (CPlayer *)client;
		SActorParams *params = player->GetActorParams();
		m_startFOV = params->viewFoVScale;
		m_currentFOV = m_startFOV;
	}
}
コード例 #7
0
ファイル: BlendedEffect.cpp プロジェクト: eBunny/EmberProject
//---------------------------------
void CFOVEffect::Init()
{
    //TODO: Do not modify actor params this way...
    IActor *pClientActor = gEnv->pGame->GetIGameFramework()->GetClientActor();
    if (pClientActor)
        {
            CPlayer *pPlayer = (CPlayer *)pClientActor;
            m_startFOV = pPlayer->GetActorParams().viewFoVScale;
            m_currentFOV = m_startFOV;
        }
}
コード例 #8
0
//---------------------------------
void CScreenEffects::ResetScreen()
{
	if (m_ownerActor->IsClient())
	{
		gEnv->p3DEngine->SetPostEffectParam("FilterRadialBlurring_Amount", 0.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_Saturation", 1.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_Brightness", 1.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_Contrast", 1.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_ColorC", 0.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_ColorM", 0.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_ColorY", 0.0f);
		gEnv->p3DEngine->SetPostEffectParam("Global_ColorK", 0.0f);
		gEnv->p3DEngine->SetPostEffectParam("BloodSplats_Active", false);
		gEnv->p3DEngine->SetPostEffectParam("BloodSplats_Type", false);
		gEnv->p3DEngine->SetPostEffectParam("BloodSplats_Amount", 0.0f);

		if (m_ownerActor->IsPlayer())
		{
			CPlayer *player = (CPlayer *)m_ownerActor;
			SActorParams *params = player->GetActorParams();
			params->viewFoVScale = 1.0f;
		}
	}
}
コード例 #9
0
ファイル: PlayerStateJump.cpp プロジェクト: aronarts/FireNET
void CPlayerStateJump::StartJump( CPlayer& player, const bool isHeavyWeapon, const float fVerticalSpeedModifier )
{
	const SActorPhysics& actorPhysics = player.GetActorPhysics();
	const SPlayerStats& stats = *player.GetActorStats();
	const float onGroundTime = 0.2f;

	float g = actorPhysics.gravity.len();

	const float jumpHeightScale = 1.0f;
	const float jumpHeight = player.GetActorParams().jumpHeight * jumpHeightScale;

	float playerZ = player.GetEntity()->GetWorldPos().z;
	float expectedJumpEndHeight = playerZ + jumpHeight;

	pe_player_dimensions dimensions;
	IPhysicalEntity *pPhysics = player.GetEntity()->GetPhysics();
	if (pPhysics && pPhysics->GetParams(&dimensions))
	{
		float physicsBottom = dimensions.heightCollider - dimensions.sizeCollider.z;
		if (dimensions.bUseCapsule)
		{
			physicsBottom -= dimensions.sizeCollider.x;
		}
		expectedJumpEndHeight += physicsBottom;
	}

	float jumpSpeed = 0.0f;

 	if (g > 0.0f)
	{
		jumpSpeed = sqrt_tpl(2.0f*jumpHeight*(1.0f/g)) * g;

		if( isHeavyWeapon )
		{
			jumpSpeed *= g_pGameCVars->pl_movement.nonCombat_heavy_weapon_speed_scale;
		}
	}

	//this is used to easily find steep ground
	float slopeDelta = (Vec3Constants<float>::fVec3_OneZ - actorPhysics.groundNormal).len();

	SetJumpState(player, JState_Jump);

	Vec3 jumpVec(ZERO);

	bool bNormalJump = true;
	
	player.PlaySound(CPlayer::ESound_Jump);

	OnSpecialMove(player, IPlayerEventListener::eSM_Jump);

	CCCPOINT_IF( player.IsClient(),   PlayerMovement_LocalPlayerNormalJump);
	CCCPOINT_IF(!player.IsClient(), PlayerMovement_NonLocalPlayerNormalJump);

	{
		// This was causing the vertical jumping speed to be much slower.
		float verticalMult = max(1.0f - m_jumpLock, 0.3f);

		const Quat baseQuat = player.GetBaseQuat();
		jumpVec += baseQuat.GetColumn2() * jumpSpeed * verticalMult;
		jumpVec.z += fVerticalSpeedModifier;

#ifdef STATE_DEBUG
		if (g_pGameCVars->pl_debugInterpolation > 1)
		{
			CryWatch("Jumping: vec from player BaseQuat only = (%f, %f, %f)", jumpVec.x, jumpVec.y, jumpVec.z);
		}
#endif
		
		if (g_pGameCVars->pl_adjustJumpAngleWithFloorNormal && actorPhysics.groundNormal.len2() > 0.0f)
		{
			float vertical = clamp_tpl((actorPhysics.groundNormal.z - 0.25f) / 0.5f, 0.0f, 1.0f);
			Vec3 modifiedJumpDirection = LERP(actorPhysics.groundNormal, Vec3(0,0,1), vertical);
			jumpVec = modifiedJumpDirection * jumpVec.len();
		}

#ifdef STATE_DEBUG
		if (g_pGameCVars->pl_debugInterpolation > 1)
		{
			CryWatch("Jumping (%f, %f, %f)", jumpVec.x, jumpVec.y, jumpVec.z);
		}
#endif
	}

	NETINPUT_TRACE(player.GetEntityId(), jumpVec);

	FinalizeVelocity( player, jumpVec );

	if (!player.IsRemote())
	{
		player.HasJumped(player.GetMoveRequest().velocity);
	}

	IPhysicalEntity* pPhysEnt = player.GetEntity()->GetPhysics();
	if (pPhysEnt != NULL)
	{
		SAnimatedCharacterParams params = player.m_pAnimatedCharacter->GetParams();
		pe_player_dynamics pd;
		pd.kAirControl = player.GetAirControl()* g_pGameCVars->pl_jump_control.air_control_scale;
		pd.kAirResistance = player.GetAirResistance() * g_pGameCVars->pl_jump_control.air_resistance_scale;

		params.inertia = player.GetInertia() * g_pGameCVars->pl_jump_control.air_inertia_scale;

		if(player.IsRemote() && (g_pGameCVars->pl_velocityInterpAirControlScale > 0))
		{
			pd.kAirControl = g_pGameCVars->pl_velocityInterpAirControlScale;
		}

		pPhysEnt->SetParams(&pd);

		// Let Animated character handle the inertia
		player.SetAnimatedCharacterParams(params);
	}

#if 0
	if (debugJumping)
	{
		Vec3 entityPos = m_player.GetEntity()->GetWorldPos();
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos, ColorB(255,255,255,255), entityPos, ColorB(255,255,0,255), 2.0f);
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos+Vec3(0,0,2), ColorB(255,255,255,255), entityPos+Vec3(0,0,2) + desiredVel, ColorB(0,255,0,255), 2.0f);
		gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos, ColorB(255,255,255,255), entityPos + jumpVec, ColorB(0,255,255,255), 2.0f);
		gEnv->pRenderer->DrawLabel(entityPos - entityRight * 1.0f + Vec3(0,0,3.0f), 1.5f, "Velo[%2.3f = %2.3f, %2.3f, %2.3f]", m_request.velocity.len(), m_request.velocity.x, m_request.velocity.y, m_request.velocity.z);
	}
#endif

	m_expectedJumpEndHeight = expectedJumpEndHeight;
	m_bSprintJump = player.IsSprinting();
}