예제 #1
0
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));
}
예제 #2
0
파일: IMGDock.C 프로젝트: HeyJJ/ball
	void IMGDock::startDock(bool verbose)
	{
		update();

		// if started from BALLView, show start conformation
		if (display_mode_ != NO_DISPLAY && display_mode_ != NO_INTERMEDIATE_POSES)
		{
			setVisualizationPose(score_);
			Log<<"score of start conformation = "<<score_<<endl;
		}

		max_rotated_pos_ = 0;
		best_conformations_.clear();

		Size no_bonds = current_conformation_.size();
		//Log<<"start conf="; displayConformation(current_conformation_, force_field_->getEnergy());

		/// reset current_conformation_ to zero, since we use the current ligand pose as starting conformation!
		current_conformation_ = vector < int > (current_conformation_.size(), 0);
		vector < int > c0 = current_conformation_; // starting conformation; all angles at 0 degrees

		saveAtomPositions();

		/// put first entries into list 'best_conformations' ...
		optimizeRotation(c0, best_conformations_, 0, false); // start at first inter-fragment bond and thus generate < no_solutions_ > entries for best_conformations
		if (verbose)
		{
			Log<<"i = 0"<<endl;
			for (PoseList::iterator it = best_conformations_.begin(); it != best_conformations_.end(); it++)
			{
				displayConformation(it->second, it->first);
			}
		}


		/// use existing entries of list 'best_conformations' in order to find other conformations and append those to the list (if score high enough or list still small enough) ...
		for (Size i = 1; i < no_bonds && !abort_; i++)
		{
			if (verbose) Log<<"i="<<i<<endl;
			PoseList best_conformations0 = best_conformations_;

			// Optimize the _current_ bond of _each_ of the < no_solutions_ > different ligand conformations
			for (PoseList::iterator it = best_conformations0.begin(); it != best_conformations0.end(); it++)
			{
				vector<int> conf = const_cast<vector<int>& >(it->second);
				if (verbose) displayConformation(conf, it->first);
				optimizeRotation(conf, best_conformations_, i, true);
			}

			// if started from BALLView, show best pose found so far
			if (display_mode_ == BEST_INTERMEDIATE_POSES)
			{
				double score = best_conformations_.begin()->first;
				applyConformation(best_conformations_.begin()->second);
				setVisualizationPose(score);
				Log<<"\rscore = "<<score<<endl;
			}
		}

		/// Apply the best conformation found in this iteration and do a local translation optimization.
		/// In the following iteration (next call of this method), this position of the ligand will be used as the starting conformation.
		applyConformation(best_conformations_.begin()->second);
		score_ = best_conformations_.begin()->first; // use previously calculated score if no transl. opt. is used

		if (post_optimization_steps_ > 0 && post_optimization_step_width_ > 0)
		{
			postDockOptimization(post_optimization_step_width_, post_optimization_steps_);

			// make sure first entry of ConformationSet will contain the correct score
			// (important only if getConformationSet() is used)
			pair < double, vector < int > > best_pose_copy = *best_conformations_.begin();
			best_pose_copy.first = score_;
			best_conformations_.erase(best_conformations_.begin());
			best_conformations_.insert(best_pose_copy);
		}

		// if started from BALLView, show start conformation
		if (display_mode_ != NO_DISPLAY && display_mode_ != NO_INTERMEDIATE_POSES)
		{
			setVisualizationPose(score_);
			Log<<"score after optimized translation = "<<score_<<endl;
		}
	}