void Orientation::activate()
{	
	if(isActive())
		return;

	m_start = utils::getEntityRotation(m_agent_eID);
	utils::radToDegV(&m_start);
	m_current = m_start;	

	if(!m_targetIsRotation)
	{
		//if the target is a point, then this is a "turn towards" action and we must compute the rotation
		Vec3f direction = m_target - utils::getEntityPosition(m_agent_eID);
		
		//This h3d function assumes that the view direction is (0,0,-1)
		//correct the rotation value based on the agent's forward view direction
		m_target = direction.toRotation();
		utils::radToDegV(&m_target);

		Vec3f fwdView(Config::getParamF(Agent_Param::FwdViewX_F), Config::getParamF(Agent_Param::FwdViewY_F), Config::getParamF(Agent_Param::FwdViewZ_F));
		if(fwdView.z > 0)
			m_target.y += 180.0f; //TODO: do corrections for other axis too	
	}

	//optimize rotations
	m_target.x = optimizeRotation(m_current.x, m_target.x);
	m_target.y = optimizeRotation(m_current.y, m_target.y);
	m_target.z = optimizeRotation(m_current.z, m_target.z);	

	m_distance = (m_target - m_start).length();
	
	if(utils::isEmpty(m_animationName)) chooseAnimation();
	startMovement(Config::getParamF(Agent_Param::OrientationSpeedMult_F));
}
Exemple #2
0
    void Hero::popTemporaryMobilityState() {
        if(temporaryMobilityState) {
            temporaryMobilityState->exit();
            chooseAnimation();
        }

        pushTemporaryMobilityState(std::unique_ptr<MobilityState>(nullptr));
    }
void Idle::activate()
{	
	if(isActive())
		return;
	
	if(utils::isEmpty(m_animationName)) chooseAnimation();
	m_animationPID = GameEngine::Agent_playAnimationN( m_agent_eID, m_animationName, 1, 1, 0, 0, 0 );
	if(m_animationPID >= 0)
		setStatus(MovementStatus::MAIN);
}