コード例 #1
0
//----------------------- Calculate --------------------------------------
//
//  calculates the accumulated steering force according to the method set
//  in m_SummingMethod
//------------------------------------------------------------------------
ofVec3f SteeringBehaviors::Calculate()
{
	m_SteeringForce = ofVec3f::zero();
	// TagNeighbors if Needed
	if (!isSpacePartioningOn())
	{
		if (On(separation) || On(alignment) || On(cohesion))
		{
			TagNeighbors(m_Vehicle, m_Vehicle->rGroup(), m_viewDistance);
		}
	}
	else
	{
		if (On(separation) || On(alignment) || On(cohesion))
		{
			m_Vehicle->GameWorld()->CellSpace()->CalculateNeighbors(m_Vehicle->Pos(), m_viewDistance);
		}
	}

	// [...switch for summing methods goes here...]
	//CalculateWeightedSum();
	
	CalculatePrioritized();

	return m_SteeringForce;
}
コード例 #2
0
ファイル: TikiSteering.cpp プロジェクト: IreNox/tiki2
		Vector2 TikiSteering::Calculate()
		{
			// reset the steering force
			steeringForce = Vector2::Zero;

			steeringForce = CalculatePrioritized();

			return steeringForce;
		}
コード例 #3
0
//----------------------- Calculate --------------------------------------
//
//  calculates the accumulated steering force according to the method set
//  in m_SummingMethod
//------------------------------------------------------------------------
Vector2D SteeringBehavior::Calculate(float dt)
{ 
	switch (m_SummingMethod) {
		case weighted_average:
			return CalculateWeightedSum(dt); 

		case prioritized:
			return CalculatePrioritized(dt);

		default:
			return Vector2D(0,0);
	}
}
コード例 #4
0
Vector2D SteeringBehavior::Calculate() {
  
  //tag neighbors if any of the following 3 group behaviors are switched on
  if (On(flee) || On(separation) || On(alignment) || On(cohesion)) {
    vehicle_->GetGameWorld()->TagVehiclesWithinViewRange(vehicle_, view_distance_);
  }

  // Reset the steering force
  steering_force_.Zero();

  steering_force_ = CalculatePrioritized();

  return steering_force_;
}
コード例 #5
0
Vector2D	SteeringBehavior::Calculate()
{
	m_vSteeringForce = Vector2D(0.0f, 0.0f);
	////use space partitioning to calculate the neighbours of this vehicle
	////if switched on. If not, use the standard tagging system
	//if (!isSpacePartitioningOn())
	//{
	////tag neighbors if any of the following 3 group behaviors are switched on
	//if (On(separation) || On(allignment) || On(cohesion))
	//{
	//	m_pVehicle->World()->TagVehiclesWithinViewRange(m_pVehicle, m_dViewDistance);
	//}
	//}
	//else
	//{
	//	//calculate neighbours in cell-space if any of the following 3 group
	//	//behaviors are switched on
	//	if (On(separation) || On(allignment) || On(cohesion))
	//	{
	//		m_pVehicle->World()->CellSpace()->CalculateNeighbors(m_pVehicle->Pos(), m_dViewDistance);
	//	}
	//}

	switch (m_SummingMethod)
	{
	case weighted_average:
    
	m_vSteeringForce = CalculateWeightedSum(); break;

	case prioritized:

	m_vSteeringForce = CalculatePrioritized(); break;

	case dithered:
    
	m_vSteeringForce = CalculateDithered();break;

	default:m_vSteeringForce = Vector2D(0,0); 

	}//end switch

	return m_vSteeringForce;
}