本文整理汇总了C++中CMovementRequest::ClearAimTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ CMovementRequest::ClearAimTarget方法的具体用法?C++ CMovementRequest::ClearAimTarget怎么用?C++ CMovementRequest::ClearAimTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMovementRequest
的用法示例。
在下文中一共展示了CMovementRequest::ClearAimTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateMoveRequest
void CNetPlayerInput::UpdateMoveRequest()
{
CMovementRequest moveRequest;
SMovementState moveState;
m_pPlayer->GetMovementController()->GetMovementState(moveState);
Quat worldRot = m_pPlayer->GetBaseQuat(); // m_pPlayer->GetEntity()->GetWorldRotation();
Vec3 deltaMovement = worldRot.GetInverted().GetNormalized() * m_curInput.deltaMovement;
// absolutely ensure length is correct
deltaMovement = deltaMovement.GetNormalizedSafe(ZERO) * m_curInput.deltaMovement.GetLength();
moveRequest.AddDeltaMovement( deltaMovement );
if( IsDemoPlayback() )
{
Vec3 localVDir(m_pPlayer->GetViewQuatFinal().GetInverted() * m_curInput.lookDirection);
Ang3 deltaAngles(asinf(localVDir.z),0,atan2_tpl(-localVDir.x,localVDir.y));
moveRequest.AddDeltaRotation(deltaAngles*gEnv->pTimer->GetFrameTime());
}
const float fNetAimLerpFactor = g_pGameCVars->pl_netAimLerpFactor;
//Vector slerp produces artifacts here, using a per-component lerp instead
Vec3 vCurrentRight = m_lookDir.cross(Vec3Constants<float>::fVec3_OneZ);
Vec3 vCurrentProjected = -(vCurrentRight.cross(Vec3Constants<float>::fVec3_OneZ));
vCurrentRight.Normalize();
vCurrentProjected.Normalize();
Vec3 vNewRight = m_curInput.lookDirection.cross(Vec3Constants<float>::fVec3_OneZ);
Vec3 vNewProjected = -(vNewRight.cross(Vec3Constants<float>::fVec3_OneZ));
vNewProjected.Normalize();
float fRotZDirDot = vNewProjected.dot(vCurrentRight);
float fRotZDot = vNewProjected.dot(vCurrentProjected);
float fRotZ = acos_tpl(fRotZDot);
fRotZ = AngleWrap_PI(fRotZ);
float fRotZFinal = -fsgnf(fRotZDirDot) * fRotZ * fNetAimLerpFactor;
float fCurrentAngle = acos_tpl(Vec3Constants<float>::fVec3_OneZ.dot(m_lookDir));
float fNewAngle = acos_tpl(Vec3Constants<float>::fVec3_OneZ.dot(m_curInput.lookDirection));
float fRotXFinal = (fNewAngle - fCurrentAngle) * -fNetAimLerpFactor;
//Rotate around X first, as we have already generated the right vector
Vec3 vNewLookDir = m_lookDir.GetRotated(vCurrentRight, fRotXFinal);
m_lookDir = vNewLookDir.GetRotated(Vec3Constants<float>::fVec3_OneZ, fRotZFinal);
Vec3 distantTarget = moveState.eyePosition + 1000.0f * m_lookDir;
Vec3 lookTarget = distantTarget;
if (m_curInput.usinglookik)
moveRequest.SetLookTarget( lookTarget );
else
moveRequest.ClearLookTarget();
if (m_curInput.aiming)
moveRequest.SetAimTarget( lookTarget );
else
moveRequest.ClearAimTarget();
if (m_curInput.deltaMovement.GetLengthSquared() > sqr(0.02f)) // 0.2f is almost stopped
moveRequest.SetBodyTarget( distantTarget );
else
moveRequest.ClearBodyTarget();
moveRequest.SetAllowStrafing(m_curInput.allowStrafing);
moveRequest.SetPseudoSpeed(CalculatePseudoSpeed());
moveRequest.SetStance( (EStance)m_curInput.stance );
m_pPlayer->GetMovementController()->RequestMovement(moveRequest);
if (m_curInput.sprint)
m_pPlayer->m_actions |= ACTION_SPRINT;
else
m_pPlayer->m_actions &= ~ACTION_SPRINT;
#if 0
if (m_pPlayer->m_netSetPosition)
{
SPredictedCharacterStates charStates;
charStates.states[0].position = m_pPlayer->GetEntity()->GetPos();
charStates.states[0].orientation = m_pPlayer->GetEntity()->GetRotation();
charStates.states[0].deltatime = 0.0f;
charStates.states[1].position = m_pPlayer->m_netCurrentLocation;
charStates.states[1].orientation = m_pPlayer->GetEntity()->GetRotation();
charStates.states[1].deltatime = gEnv->pTimer->GetFrameTime();
charStates.states[2].position = m_pPlayer->m_netDesiredLocation;
charStates.states[2].orientation = m_pPlayer->GetEntity()->GetRotation();
charStates.states[2].deltatime = m_pPlayer->m_netLerpTime;
charStates.nStates = 3;
moveRequest.SetPrediction(charStates);
}
#endif //0
#if !defined(_RELEASE)
//.........这里部分代码省略.........