コード例 #1
0
void CAI_Motor::SetIdealYawAndUpdate( float idealYaw, float yawSpeed)
{
	SetIdealYaw( idealYaw );
	if (yawSpeed == AI_CALC_YAW_SPEED)
		RecalculateYawSpeed();
	else if (yawSpeed != AI_KEEP_YAW_SPEED)
		SetYawSpeed( yawSpeed );
	UpdateYaw(-1);
}
コード例 #2
0
ファイル: krlremotecharacter.cpp プロジェクト: 1suming/pap2
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;
}
コード例 #3
0
ファイル: ai_motor.cpp プロジェクト: Au-heppa/swarm-sdk
int CAI_Motor::MoveJumpExecute( )
{
	// needs to detect being hit
	UpdateYaw( );

	if (GetOuter()->GetActivity() == ACT_JUMP && GetOuter()->IsActivityFinished())
	{
		SetActivity( ACT_GLIDE );
	}

	// use all the time
	SetMoveInterval( 0 );

	return AIMR_OK;
}
コード例 #4
0
ファイル: main.c プロジェクト: hoahiep6457/Working
/*=====================================================================================================*/
void IMU_Get_Start(void)
{
  //MPU6050 get roll pitch to start
  Update_MPU6050();
  UpdatePitchRoll();
  gyroX_angle = angleX;
  kalmanX.angle = angleX;
	gyroY_angle = angleY;
  kalmanY.angle = angleY;

  //HMC5883L get yaw to start
  Update_HMC5883L();
  UpdateYaw();
  gyroZ_angle = angleZ;
  kalmanZ.angle = angleZ;
}
コード例 #5
0
void CASW_Simple_Alien::AlienThink()
{
	float delta = gpGlobals->curtime - m_fLastThinkTime;

	StudioFrameAdvance();
	DispatchAnimEvents(this);

	UpdateYaw(delta);

	if (m_bMoving)
	{
		PerformMovement(delta);

		SetNextThink( gpGlobals->curtime + 0.1f );
	}
	else
	{
		WhatToDoNext(delta);	// this will set the next think interval based on what the alien decides to do next
	}

	m_fLastThinkTime = gpGlobals->curtime;
}
コード例 #6
0
ファイル: krlremotecharacter.cpp プロジェクト: 1suming/pap2
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;
}
コード例 #7
0
ファイル: main.c プロジェクト: hoahiep6457/Working
//read MPU once 1 ms
void IMU_Get_Data(void)
{
  //Calculate roll, pitch from MPU6050
  /*--------------------------Hanle MPU6050---------------------------------------*/
  Update_MPU6050();
  UpdatePitchRoll();
  //Caculate Gyrorate 
  gyroX_rate = (gyroX - gyroX_offset)/GYRO_LSB;
  gyroY_rate = (gyroY - gyroY_offset)/GYRO_LSB;
  gyroZ_rate = (gyroZ - gyroZ_offset)/GYRO_LSB;
  //kalman filter
  gyroX_angle += gyroX_rate*DT;
  gyroY_angle += gyroY_rate*DT;
	gyroZ_angle += gyroZ_rate*DT;
	//Calculate Angle from Accel
  /* roll: Rotation around the longitudinal axis (the plane body, 'X axis'). -180<=roll<=180    */
    /* roll is positive and increasing when moving downward                                     */
    /*                                                                                          */
    /*                                 y                                                        */
    /*             roll = atan(-----------------)                                               */
    /*                          sqrt(x^2 + z^2)                                                 */
    /* where:  x, y, z are returned value from accelerometer sensor                             */

    /* pitch: Rotation around the lateral axis (the wing span, 'Y axis'). -90<=pitch<=90)     */
    /* pitch is positive and increasing when moving upwards                                     */
    /*                                                                                          */
    /*                                 x                                                        */
    /*            pitch = atan(-----------------)                                               */
    /*                          sqrt(y^2 + z^2)                                                 */
    /* where:  x, y, z are returned value from accelerometer
  */
  // Source: http://www.freescale.com/files/sensors/doc/app_note/AN3461.pdf eq. 25 and eq. 26
  // atan2 outputs the value of -π to π (radians) - see http://en.wikipedia.org/wiki/Atan2
  // It is then converted from radians to degrees

  #ifdef RESTRICT_PITCH
  // This fixes the transition problem when the accelerometer angle jumps between -180 and 180 degrees
  if ((angleX < -90 && angleX_kalman > 90) || (angleX > 90 && angleX_kalman < -90)) {
    kalmanX.angle = angleX;
    angleX_kalman = angleX;
  } 
  else
    angleX_kalman = kalman_filter_angle(&kalmanX, angleX, gyroX_rate, DT);

  if (abs(angleX_kalman) > 90)
    gyroY_rate = -gyroY_rate; // Invert rate, so it fits the restriced accelerometer reading
    angleY_kalman = kalman_filter_angle(&kalmanY, angleY, gyroY_rate, DT);
  #else
    // This fixes the transition problem when the accelerometer angle jumps between -180 and 180 degrees
    if ((angleY < -90 && angleY_kalman > 90) || (angleY > 90 && angleY_kalman < -90)) {
      kalmanY.angle = angleY;
      angleY_kalman = angleY;
    } 
    else
      angleY_kalman = kalman_filter_angle(&kalmanY, angleY, gyroY_rate, DT);

    if (abs(angleY_kalman) > 90)
      gyroX_rate = -gyroX_rate; // Invert rate, so it fits the restriced accelerometer reading
      angleX_kalman = kalman_filter_angle(&kalmanX, angleX, gyroX_rate, DT);
    #endif
 //Calculate yaw from Magnate
  /*--------------------Handle HMC5883L---------------------*/
     /* Sensor rotates around Z-axis                                                           */
    /* yaw is the angle between the 'X axis' and magnetic north on the horizontal plane (Oxy) */
    /* jump between -180<=yaw<=180  																													*/
    /* Yaw = atan(-Bfy / Bfx)                                                                */
    /* rollAngle = to_radians(angleX);																						*/
    /* pitchAngle = to_radians(angleY);																						*/
    /* Bfy = -(magn->z * sin(rollAngle) - magn->y * cos(rollAngle));							*/
    /* Bfx = magn->x * cos(pitchAngle) +																					*/
    /*             magn->y * sin(pitchAngle) * sin(rollAngle) +										*/
    /*             magn->z * sin(pitchAngle) * cos(rollAngle);										*/
    /* yaw = to_degrees(atan2(Bfy, Bfx));																					*/

  Update_HMC5883L();
  UpdateYaw();
  // This fixes the transition problem when the yaw angle jumps between -180 and 180 degrees
  if ((angleZ < -90 && angleZ_kalman > 90) || (angleZ > 90 && angleZ_kalman < -90)) {
    kalmanZ.angle = angleZ;
    angleZ_kalman = angleZ;
  } 
  else
    angleZ_kalman = kalman_filter_angle(&kalmanZ, angleZ, gyroZ_rate, DT);   
}