// virtual bool nuiPadGestureRecognizer::MouseMoved(nuiSize X, nuiSize Y) { bool res = nuiGestureRecognizer::MouseMoved(X, Y); if (!mClicked) return false; double diffx = mLastX - X; double diffy = mLastY - Y; double currentTime = nglTime(); nuiVector v(diffx, diffy, 0); double l = v.Length(); if (l > PAD_ATTENUATOR_THRESHOLD) mForce *= 1.0 / l; mForce += v; double length = mForce.Length(); nuiVector n = mForce; //printf("NEW norm: %f - angle: %f\n", GetStrength(), GetDegrees()); mLastX = X; mLastY = Y; UpdateDirection(); return false; }
void nuiPadGestureRecognizer::UpdateForces(const nuiEvent& rEvent) { mForce *= mFriction; //printf("UPD norm: %f - angle: %f\n", GetStrength(), GetDegrees()); UpdateDirection(); }
void CPlayerBase::updateFalling() { UpdateDirection(); UpdateMovDirection(); if (cc->OnGround()) { jspeed = 0.0f; ChangeState("idle"); ChangeCommonState("idle"); } }
void CPlayerBase::Jumping() { PROFILE_FUNCTION("jumping base"); UpdateDirection(); UpdateMovDirection(); if (cc->GetYAxisSpeed() < 0) { ChangeState("falling"); ChangeCommonState("falling"); } }
int KRLRemoteCharacter::UpdateDisplayData(BOOL bForceUpdate) { int nRetCode = false; int nResult = false; HRESULT hr = E_FAIL; KRLCharacterEquipResource EquipResource; KRLCharacterDisplayData RLCharacterDisplayData; nRetCode = m_RLCharacter.PauseAnimationStatus(&RLCharacterDisplayData); KGLOG_CHECK_ERROR(nRetCode); nRetCode = m_FrameData.UpdateCurrentRepresentFrameData(true, m_FrameData.GetCurrentPosition()); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetCharacterModel(&g_pRL->m_ResourceLimit, m_FrameData.m_pCharacter, &EquipResource); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateModel(EquipResource, bForceUpdate); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_FrameData.Interpolate(m_RLCharacter.m_RenderData.IsVisible(), true); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateVehicle(m_FrameData.m_Current.nVehicleTrack, TRUE); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdatePosition(TRUE); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdateYaw(NULL); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdateDirection(bForceUpdate); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateBalloon(); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateTitleMark(); KGLOG_PROCESS_ERROR(nRetCode); UpdateSkillBuff(); UpdateLifeState(TRUE); nRetCode = m_RLCharacter.ResumeAnimationStatus(&RLCharacterDisplayData); KGLOG_CHECK_ERROR(nRetCode); nResult = true; Exit0: return nResult; }
void CPlayerBase::Idle() { PROFILE_FUNCTION("idle base"); ChangeCommonState("idle"); if (!checkDead()) { UpdateDirection(); UpdateJumpState(); if (UpdateMovDirection() && (state == "moving" || state == "idle")) { ChangeCommonState("moving"); ChangeState("moving"); } } }
Camera::Camera(GLfloat aspectRatio, glm::vec3 position, GLfloat moveSpeed, GLfloat fov, glm::vec3 worldUp, GLfloat pitch, GLfloat yaw, GLfloat nearClip, GLfloat farClip) { _aspectRatio = aspectRatio; _position = position; _moveSpeed = moveSpeed; _fov = fov; _pitch = pitch; _yaw = yaw; _worldUpDirection = worldUp; _nearClip = nearClip; _farClip = farClip; UpdateDirection(); }
int KRLLocalCharacter::UpdateDisplayData(BOOL bForceUpdate) { int nRetCode = false; int nResult = false; HRESULT hr = E_FAIL; KRLCharacterEquipResource EquipResource; KRLCharacterDisplayData RLCharacterDisplayData; nRetCode = m_RLCharacter.PauseAnimationStatus(&RLCharacterDisplayData); KGLOG_CHECK_ERROR(nRetCode); nRetCode = m_RLCharacter.m_FrameData.UpdateCurrentRepresentFrameData(true); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.m_FrameData.Interpolate(m_RLCharacter.m_RenderData.IsVisible(), true); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdatePosition(); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdateDirection(); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = GetCharacterModel(m_RLCharacter.m_FrameData.m_pCharacter, &EquipResource); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateModel(EquipResource, bForceUpdate); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateVehicle(m_RLCharacter.m_FrameData.m_Current.nVehicleTrack, TRUE); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.ResumeAnimationStatus(&RLCharacterDisplayData); KGLOG_CHECK_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateBalloon(); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateTitleMark(); KGLOG_PROCESS_ERROR(nRetCode); UpdateSkillBuff(); m_bSheath = m_RLCharacter.m_FrameData.m_Current.bSheathFlag; m_RLCharacter.UpdateWeaponSocketPosition(m_bSheath); nResult = true; Exit0: return nResult; }
CylinderFit3<Real>::CylinderFit3 (int numPoints, const Vector3<Real>* points, Vector3<Real>& center, Vector3<Real>& axis, Real& radius, Real& height, bool inputsAreInitialGuess) { Real invRSqr = (Real)1; if (!inputsAreInitialGuess) { // Find the least-squares line that fits the data and use it as an // initial guess for the cylinder axis. Line3<Real> line = OrthogonalLineFit3(numPoints, points); center = line.Origin; axis = line.Direction; } mError = Math<Real>::MAX_REAL; const int iMax = 8; int i; for (i = 0; i < iMax; ++i) { mError = UpdateInvRSqr(numPoints, points, center, axis, invRSqr); mError = UpdateDirection(numPoints, points, center, axis, invRSqr); mError = UpdateCenter(numPoints, points, center, axis, invRSqr); } // Compute the radius. radius = Math<Real>::InvSqrt(invRSqr); // Project points onto fitted axis to determine extent of cylinder along // the axis. Real tMin = axis.Dot(points[0] - center); Real tMax = tMin; for (i = 1; i < numPoints; ++i) { Real t = axis.Dot(points[i] - center); if (t < tMin) { tMin = t; } else if (t > tMax) { tMax = t; } } // Compute the height. Adjust the center to point that projects to // midpoint of extent. height = tMax - tMin; center += (((Real)0.5)*(tMin + tMax))*axis; }
void CPlayerBase::Moving() { PROFILE_FUNCTION("moving base"); if (checkFalling()) { time_start_falling = 0; ChangeState("start_falling"); ChangeCommonState("start_falling"); } UpdateDirection(); UpdateJumpState(); if (!UpdateMovDirection()) { ChangeState("idle"); ChangeCommonState("idle"); } }
CylinderFit3<Real>::CylinderFit3 (int iQuantity, const Vector3<Real>* akPoint, Vector3<Real>& rkC, Vector3<Real>& rkU, Real& rfR, Real& rfH, bool bInputsAreInitialGuess) { Real fInvRSqr = (Real)1.0; if (!bInputsAreInitialGuess) { // Find the least-squares line that fits the data and use it as an // initial guess for the cylinder axis. Line3<Real> kLine = OrthogonalLineFit3(iQuantity,akPoint); rkC = kLine.Origin; rkU = kLine.Direction; } m_fError = Math<Real>::MAX_REAL; const int iMax = 8; int i; for (i = 0; i < iMax; i++) { m_fError = UpdateInvRSqr(iQuantity,akPoint,rkC,rkU,fInvRSqr); m_fError = UpdateDirection(iQuantity,akPoint,rkC,rkU,fInvRSqr); m_fError = UpdateCenter(iQuantity,akPoint,rkC,rkU,fInvRSqr); } // Compute the radius. rfR = Math<Real>::InvSqrt(fInvRSqr); // Project points onto fitted axis to determine extent of cylinder along // the axis. Real fTMin = rkU.Dot(akPoint[0]-rkC), fTMax = fTMin; for (i = 1; i < iQuantity; i++) { Real fT = rkU.Dot(akPoint[i]-rkC); if (fT < fTMin) { fTMin = fT; } else if (fT > fTMax) { fTMax = fT; } } // Compute the height. Adjust the center to point that projects to // midpoint of extent. rfH = fTMax - fTMin; rkC += ((Real)0.5)*(fTMin+fTMax)*rkU; }
void Camera::Turn(GLfloat xAmount, GLfloat yAmount) { _yaw += xAmount; _pitch += yAmount; if(_pitch > 89) { _pitch = 89; } else if(_pitch < -89) { _pitch = -89; } UpdateDirection(); }
int KRLRemoteCharacter::Update(double fTime, double fTimeLast, DWORD dwGameLoop, BOOL bFrame) { int nRetCode = false; int nResult = false; HRESULT hr = E_FAIL; RL_ANIMATION_DOWN nAnimationDown = RL_ANIMATION_DOWN_NONE; RL_ADVANCE nAdvance = RL_ADVANCE_FORWARD; if (m_RLCharacter.m_RenderData.HasLoadedMDL()) { if (!m_RLCharacter.IsFadeOut() && m_FrameData.m_pCharacter) { if (bFrame) { m_FrameData.UpdateRepresentFrameData( m_RLCharacter.m_RenderData.IsVisible(), m_FrameData.GetCurrentPosition()); } nRetCode = m_FrameData.Interpolate(m_RLCharacter.m_RenderData.IsVisible(), false); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdatePosition(FALSE); KGLOG_PROCESS_ERROR(nRetCode); if (bFrame) { nRetCode = UpdateYaw(&nAdvance); KGLOG_PROCESS_ERROR(nRetCode); } nRetCode = UpdateDirection(TRUE); KGLOG_PROCESS_ERROR(nRetCode); if (bFrame) { nRetCode = UpdateSheath(); KGLOG_PROCESS_ERROR(nRetCode); nAnimationDown = GetRLAnimationDown( m_FrameData.m_Current.nMoveState, m_FrameData.m_Current.nOTAction, m_FrameData.m_Current.nJumpCount, m_nTurning); if (m_RLCharacter.m_bAnimationPaused && nAnimationDown != RL_ANIMATION_DOWN_FREEZE) m_RLCharacter.PauseAnimation(FALSE); nRetCode = UpdateAnimationUp(); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateVehicle( m_FrameData.m_Current.nVehicleTrack, FALSE); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateAnimationDown(nAnimationDown, nAdvance, m_FrameData.m_Current.bSlip, m_FrameData.m_Current.nFightFlag, m_FrameData.m_Current.dwSkillBuffs); KGLOG_PROCESS_ERROR(nRetCode); UpdateLifeState(FALSE); UpdateAnimationSpeed(nAnimationDown, nAdvance); } } if (bFrame) { m_RLCharacter.UpdateFade(); hr = m_RLCharacter.m_RenderData.Update(); KGLOG_COM_PROCESS_ERROR(hr); if (!IS_PLAYER(m_RLCharacter.GetObjectID())) { BOOL bSelectable = m_RLCharacter.m_RenderData.IsMDLSelectable(); if (nAnimationDown == RL_ANIMATION_DOWN_DEATH && bSelectable) { nRetCode = m_RLCharacter.SetSelectable(FALSE); KGLOG_PROCESS_ERROR(nRetCode); } else if (nAnimationDown != RL_ANIMATION_DOWN_DEATH && !bSelectable && m_FrameData.m_pCharacter) { nRetCode = m_RLCharacter.ResetSelectable(); KGLOG_PROCESS_ERROR(nRetCode); } } } } nResult = true; Exit0: return nResult; }
void PlayerController::Update() { UpdateDirection(); UpdateSpeed(); }
int KRLLocalCharacter::Update(double fTime, double fTimeLast, DWORD dwGameLoop, BOOL bFrame) { int nRetCode = false; int nResult = false; HRESULT hr = E_FAIL; RL_ANIMATION_UP nAnimationUp = RL_ANIMATION_UP_NONE; RL_ANIMATION_DOWN nAnimationDown = RL_ANIMATION_DOWN_NONE; RL_ADVANCE nAdvance = RL_ADVANCE_FORWARD; ASSERT(!m_RLCharacter.IsFadeOut()); if (m_RLCharacter.m_RenderData.HasLoadedMDL()) { if (bFrame) { m_RLCharacter.m_FrameData.UpdateRepresentFrameData(TRUE); if (m_bSheath != m_RLCharacter.m_FrameData.m_Current.bSheathFlag) { m_bSheath = m_RLCharacter.m_FrameData.m_Current.bSheathFlag; m_RLCharacter.UpdateSheath(m_bSheath); } } nRetCode = m_RLCharacter.m_FrameData.Interpolate(m_RLCharacter.m_RenderData.IsVisible(), false); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdatePosition(); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = UpdateDirection(); KGLOG_PROCESS_ERROR(nRetCode); nAnimationDown = GetRLAnimationDown( m_RLCharacter.m_FrameData.m_Current.nMoveState, m_RLCharacter.m_FrameData.m_Current.nOTAction, m_RLCharacter.m_FrameData.m_Current.nJumpCount, m_nTurning); nAdvance = GetAdvance(nAnimationDown); nRetCode = UpdateListener(); KGLOG_PROCESS_ERROR(nRetCode); if (bFrame) { if (m_RLCharacter.m_bAnimationPaused && nAnimationDown != RL_ANIMATION_DOWN_FREEZE) m_RLCharacter.PauseAnimation(FALSE); nAnimationUp = GetRLAnimationUp(m_RLCharacter.m_FrameData.m_Current.nOTAction); if (nAnimationUp == RL_ANIMATION_UP_NONE && m_nAnimationUp != RL_ANIMATION_UP_NONE || nAnimationUp != RL_ANIMATION_UP_NONE) { nRetCode = m_RLCharacter.UpdateAnimationUp(nAnimationUp); KGLOG_PROCESS_ERROR(nRetCode); m_nAnimationUp = nAnimationUp; } nRetCode = m_RLCharacter.UpdateVehicle( m_RLCharacter.m_FrameData.m_Current.nVehicleTrack, FALSE); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = m_RLCharacter.UpdateAnimationDown(nAnimationDown, nAdvance, m_RLCharacter.m_FrameData.m_Current.nFightFlag, m_RLCharacter.m_FrameData.m_Current.dwSkillBuffs); KGLOG_PROCESS_ERROR(nRetCode); UpdateLifeState(); UpdateAnimationSpeed(nAnimationDown, nAdvance); if (m_dwLockControlFrame > 0) { --m_dwLockControlFrame; } hr = m_RLCharacter.m_RenderData.Update(); KGLOG_COM_PROCESS_ERROR(hr); } } nResult = true; Exit0: return nResult; }
void BaseGridMovementComponent::OnPositionChanged(const Point3F& oldPos, const Point3F& newPos) { UpdateDirection(oldPos.To2D(), newPos.To2D()); }