// キャラクターのアニメーション処理
void Chara_AnimProcess( CHARA *ch )
{
	float AnimTotalTime ;		// 再生しているアニメーションの総時間

	// ブレンド率が1以下の場合は1に近づける
	if( ch->AnimBlendRate < 1.0f )
	{
		ch->AnimBlendRate += CHARA_ANIM_BLEND_SPEED ;
		if( ch->AnimBlendRate > 1.0f )
		{
			ch->AnimBlendRate = 1.0f ;
		}
	}

	// 再生しているアニメーション1の処理
	if( ch->PlayAnim1 != -1 )
	{
		// アニメーションの総時間を取得
		AnimTotalTime = MV1GetAttachAnimTotalTime( ch->ModelHandle, ch->PlayAnim1 ) ;

		// 再生時間を進める
		ch->AnimPlayCount1 += CHARA_PLAY_ANIM_SPEED ;

		// 再生時間が総時間に到達していたら再生時間をループさせる
		if( ch->AnimPlayCount1 >= AnimTotalTime )
		{
			ch->AnimPlayCount1 = fmod( ch->AnimPlayCount1, AnimTotalTime ) ;
		}

		// 変更した再生時間をモデルに反映させる
		MV1SetAttachAnimTime( ch->ModelHandle, ch->PlayAnim1, ch->AnimPlayCount1 ) ;

		// アニメーション1のモデルに対する反映率をセット
		MV1SetAttachAnimBlendRate( ch->ModelHandle, ch->PlayAnim1, ch->AnimBlendRate ) ;
	}

	// 再生しているアニメーション2の処理
	if( ch->PlayAnim2 != -1 )
	{
		// アニメーションの総時間を取得
		AnimTotalTime = MV1GetAttachAnimTotalTime( ch->ModelHandle, ch->PlayAnim2 ) ;

		// 再生時間を進める
		ch->AnimPlayCount2 += CHARA_PLAY_ANIM_SPEED ;

		// 再生時間が総時間に到達していたら再生時間をループさせる
		if( ch->AnimPlayCount2 > AnimTotalTime )
		{
			ch->AnimPlayCount2 = fmod( ch->AnimPlayCount2, AnimTotalTime ) ;
		}

		// 変更した再生時間をモデルに反映させる
		MV1SetAttachAnimTime( ch->ModelHandle, ch->PlayAnim2, ch->AnimPlayCount2 ) ;

		// アニメーション2のモデルに対する反映率をセット
		MV1SetAttachAnimBlendRate( ch->ModelHandle, ch->PlayAnim2, 1.0f - ch->AnimBlendRate ) ;
	}
}
Beispiel #2
0
void MotionPlayer::SetBlendRateToModel()
{
    float prev_blend_rate = static_cast<float>(prev_blend_rate_) / blend_time_;

    if (prev_attach_index_ != -1)
    {
        MV1SetAttachAnimBlendRate(model_handle_, prev_attach_index_, prev_blend_rate);
    }
    if (current_attach_index_ != -1)
    {
        MV1SetAttachAnimBlendRate(model_handle_, current_attach_index_, 1.0f - prev_blend_rate);
    }
}