Example #1
0
void akAnimationStrip::evaluate(akScalar time, akScalar weight, void* object)
{
	if (object)
	{
		akScalar bi, bo;
		akScalar actualWeight;
		akScalar scaledTime = time * m_anim->getLength() / getLength();
		
		bi = m_blendin;
		bo = m_blendout;
		
		m_curBlend = 1.0f;
		
		if (!akFuzzy(bi) && time < bi)
		{
			m_curBlend *= time / bi;
		}
		
		if (!akFuzzy(bo) && (time + bo) > getLength())
		{
			m_curBlend *= (getLength() - time) / bo;
		}
		
		actualWeight = akClampf(weight * m_weight * m_curBlend, 0.f, 1.f);
		
		m_anim->evaluate(scaledTime, actualWeight, object);
	}
}
bool akAnimationBlend::evaluate(akScalar delta)
{
	if (!m_enabled || !m_base)
		return true;

	if (m_mode == AK_ACT_LOOP)
	{
		if (m_time >= getLength())
			m_time = 0.f;
		m_time += delta;
	}
	else
	{
		m_time += delta;
		if (m_time >= getLength())
			m_time = getLength();
	}
	
	
	if (m_way != AB_NONE)
	{
		m_blend = akClampf(m_blend + m_frames, 0.f, 1.f);
		m_base->setWeight(m_way == akAnimationBlend::AB_IN ? m_blend : 1.f - m_blend);
	}
	else
		m_base->setWeight(1.f);
	
	// Apply objects
	//m_base->setTimePosition(m_time);
	//m_base->evaluate(0.f);
	m_base->evaluate(delta);
	
	
	return m_way == akAnimationBlend::AB_OUT ? (1.f - m_blend) <= 0.f : false;
}