Exemple #1
0
void CPlayerRotation::ProcessNormal( float frameTime )
{
#ifdef ENABLE_NAN_CHECK
	//create a matrix perpendicular to the ground
	Vec3 up(0,0,1);
	//..or perpendicular to the linked object Z
	SLinkStats *pLinkStats = &m_player.m_linkStats;
	if (pLinkStats->linkID && pLinkStats->flags & SLinkStats::LINKED_FREELOOK)
	{
		IEntity *pLinked = pLinkStats->GetLinked();
		if (pLinked)
			up = pLinked->GetRotation().GetColumn2();
	}
	
	const Vec3 right(m_baseQuat.GetColumn0());
	const Vec3 forward((up % right).GetNormalized());

	PR_CHECKQNAN_VEC(up);
	PR_CHECKQNAN_VEC(right);
#endif //ENABLE_NAN_CHECK

	const Ang3 vNewDeltaAngles = m_deltaAngles * m_player.m_stats.flashBangStunMult;

#ifdef PLAYER_MOVEMENT_DEBUG_ENABLED
	m_player.DebugGraph_AddValue("AimDeltaH", vNewDeltaAngles.z);
	m_player.DebugGraph_AddValue("AimDeltaV", vNewDeltaAngles.x);
#endif

	Ang3 newViewAngles;
	newViewAngles.Set(m_viewAngles.x + vNewDeltaAngles.x, m_viewAngles.y, m_viewAngles.z + vNewDeltaAngles.z);
	newViewAngles += m_externalAngles;

	//These values need to be used because the player rotation is a quat and quaternions wrap on 720 degrees
	newViewAngles.z = (float)__fsel(  newViewAngles.z - (2.0f * gf_PI2),  newViewAngles.z - (4.0f * gf_PI2), newViewAngles.z);
	newViewAngles.z = (float)__fsel(-(newViewAngles.z + (2.0f * gf_PI2)), newViewAngles.z + (4.0f * gf_PI2), newViewAngles.z);
	
	m_viewAngles = newViewAngles;
		
	if (m_player.CanTurnBody())
	{
		m_baseQuat = Quat::CreateRotationZ(newViewAngles.z);
	}
	
	newViewAngles.y += m_viewRoll;
	m_viewQuat.SetRotationXYZ(newViewAngles);
	
	m_deltaAngles = vNewDeltaAngles;

	if(!m_player.GetLinkedVehicle())
	{
		CHANGED_NETWORK_STATE_REF(m_player, CPlayer::ASPECT_INPUT_CLIENT);
	}
}
    CActionLedgeGrab(CPlayer &player, const QuatT &ledgeLoc, SLedgeTransitionData::EOnLedgeTransition transition, bool endCrouched, bool comingFromOnGround, bool comingFromSprint)
        : TPlayerAction(PP_PlayerActionUrgent, PlayerMannequin.fragmentIDs.ledgeGrab),
          m_player(player),
          m_targetViewDirTime(0.2f),
          m_transitionType(transition),
          m_endCrouched(endCrouched),
          m_comingFromOnGround(comingFromOnGround),
          m_comingFromSprint(comingFromSprint),
          m_haveUnHolsteredWeapon(false)
    {
        SetParam("TargetPos", ledgeLoc);

        Ang3 viewAng;
        viewAng.SetAnglesXYZ( ledgeLoc.q );
        viewAng.y = 0.0f;
        m_targetViewDir = Quat::CreateRotationXYZ( viewAng );
    }
Ang3 CVehicleSeatActionOrientateBoneToView::GetDesiredViewAngles(const Vec3& lookPos, const Vec3& aimPos) const
{
	Vec3 forwardDir = (aimPos - lookPos).GetNormalized();
	Vec3 upDir = Vec3(0.f, 0.f, 1.f);
	Vec3 sideDir = forwardDir.Cross(upDir);
	sideDir.Normalize();
	upDir = sideDir.Cross(forwardDir);
	upDir.Normalize();

	Matrix34 matrix;
	matrix.SetFromVectors(sideDir, forwardDir, upDir, Vec3(0.f, 0.f, 0.f));

	Ang3 lookAngles;
	lookAngles.SetAnglesXYZ(matrix);

	return lookAngles;
}
Exemple #4
0
void VrInput::weaponOrientation(Ang3 &angle)
{
	// Reorienting to engine standards for angles
	angle.Set(DEG2RAD(-_weaponAngle.z), DEG2RAD(-_weaponAngle.x), DEG2RAD(_weaponAngle.y));
}
Exemple #5
0
void VrInput::headOrientation(Ang3 &angle)
{
	angle.Set(DEG2RAD(-_headAngle.x), DEG2RAD(_headAngle.z), DEG2RAD(_headAngle.y));
}