Exemplo n.º 1
0
void C_CFPlayer::CalcInEyeCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov)
{
	C_CFPlayer *pTarget = ToCFPlayer(GetObserverTarget());

	if ( !pTarget ) 
	{
		// just copy a save in-map position
		VectorCopy( EyePosition(), eyeOrigin );
		VectorCopy( EyeAngles(), eyeAngles );
		return;
	};

	if ( pTarget->ShouldForceThirdPerson() )
	{
		CalcChaseCamView( eyeOrigin, eyeAngles, fov );
		return;
	}

	fov = GetFOV();	// TODO use tragets FOV

	m_flObserverChaseDistance = 0.0;

	eyeAngles = pTarget->EyeAngles();
	eyeOrigin = pTarget->EyePosition();

	// Apply punch angle
	VectorAdd( eyeAngles, GetPunchAngle(), eyeAngles );

	engine->SetViewAngles( eyeAngles );
}
Exemplo n.º 2
0
bool C_CFPlayer::IsFirstPersonSpectating( C_BaseEntity* pTarget )
{
	if (!IsObserver())
		return false;

	if (GetObserverMode() != OBS_MODE_IN_EYE)
		return false;

	if (!GetObserverTarget())
		return false;

	if (GetObserverTarget() != pTarget)
		return false;

	if (ToCFPlayer(pTarget) && ToCFPlayer(pTarget)->ShouldForceThirdPerson())
		return false;

	return true;
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : int
//-----------------------------------------------------------------------------
int CBasePlayer::GetDefaultFOV( void ) const
{
#if defined( CLIENT_DLL )
	if ( GetObserverMode() == OBS_MODE_IN_EYE )
	{
		C_BasePlayer *pTargetPlayer = dynamic_cast<C_BasePlayer*>( GetObserverTarget() );

		if ( pTargetPlayer && !pTargetPlayer->IsObserver() )
		{
			return pTargetPlayer->GetDefaultFOV();
		}
	}
#endif

	int iFOV = ( m_iDefaultFOV == 0 ) ? g_pGameRules->DefaultFOV() : m_iDefaultFOV;

	return iFOV;
}
Exemplo n.º 4
0
void C_CFPlayer::CalcChaseCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov)
{
	C_CFPlayer *pTarget = ToCFPlayer(GetObserverTarget());

	if ( !pTarget ) 
	{
		// just copy a save in-map position
		VectorCopy( EyePosition(), eyeOrigin );
		VectorCopy( EyeAngles(), eyeAngles );
		return;
	};

	// If our target isn't visible, we're at a camera point of some kind.
	// Instead of letting the player rotate around an invisible point, treat
	// the point as a fixed camera.
	if ( !pTarget->GetBaseAnimating() && !pTarget->GetModel() )
	{
		CalcRoamingView( eyeOrigin, eyeAngles, fov );
		return;
	}

	// The following code was ripped from CCFInput::CAM_ThirdPersonNormalThink.
	// Should probably delete it and move that code to C_CFPlayer so that it can be used here too.

	eyeAngles = pTarget->EyeAngles();

	Vector vecEngineForward, vecEngineRight, vecEngineUp;
	AngleVectors(eyeAngles, &vecEngineForward, &vecEngineRight, &vecEngineUp);

	Vector vecEngineForward2D;
	AngleVectors(QAngle(0, eyeAngles[YAW], 0), &vecEngineForward2D);

	// Don't use EyePosition() because that changes depending on the animation.
	Vector vecCameraCenter = pTarget->GetAbsOrigin() + VEC_VIEW;

	m_bThirdPositionMelee = true;
	if (pTarget->GetPrimaryWeapon() && !pTarget->GetPrimaryWeapon()->IsMeleeWeapon())
		m_bThirdPositionMelee = false;
	if (pTarget->GetSecondaryWeapon() && !pTarget->GetSecondaryWeapon()->IsMeleeWeapon())
		m_bThirdPositionMelee = false;

	Vector vecRearRightPosition = vecCameraCenter + vecEngineRight * cvar->FindVar("cam_right")->GetFloat() - vecEngineForward * cvar->FindVar("cam_back")->GetFloat();
	Vector vecRearMeleePosition = vecCameraCenter + vecEngineRight * cvar->FindVar("cam_right_melee")->GetFloat() - vecEngineForward * cvar->FindVar("cam_back_melee")->GetFloat();

	m_flThirdPositionMeleeWeight = Approach(m_bThirdPositionMelee?0:1, m_flThirdPositionMeleeWeight, gpGlobals->frametime * (1/cvar->FindVar("cam_switchtime")->GetFloat()));

	float flWeight = Gain(m_flThirdPositionMeleeWeight, 0.8f);

	eyeOrigin = vecRearMeleePosition * (1-flWeight) + vecRearRightPosition * flWeight;

	if ( pTarget )
	{
		trace_t trace;

		// Trace back to see if the camera is in a wall.
		CTraceFilterNoNPCsOrPlayer traceFilter( pTarget, COLLISION_GROUP_NONE );
		UTIL_TraceHull( vecCameraCenter, eyeOrigin,
			Vector(-9,-9,-9), Vector(9,9,9),
			MASK_SOLID, &traceFilter, &trace );

		if( trace.fraction < 1.0 )
			eyeOrigin = trace.endpos;
	}

	fov = GetFOV();
}