// Attenuation = 1 / (qd^2 + ld + c)
IFXRESULT CIFXLightResource::SetAttenuation( F32* pAttenuation )
{
	IFXRESULT result = IFX_OK;

	if ( pAttenuation )
	{
		F32 fConstant  = *pAttenuation++;
		F32 fLinear    = *pAttenuation++;
		F32 fQuadradic = *pAttenuation;

		if ( ( fConstant >= 0 )  &&
			 ( fLinear >= 0 )    &&
			 ( fQuadradic >= 0 ) &&
			 ( (fConstant+fLinear+fQuadradic) > 0 ) )
		{
			m_Light.SetAttenuation(IFXVector3(fConstant, fLinear, fQuadradic));
			CalculateRange();
		}
		else
			result = IFX_E_INVALID_RANGE;
	}
	else
		result = IFX_E_INVALID_POINTER;

	return result;
}
Exemple #2
0
rendering::lighting::PointLight::PointLight(const math::Transform& transform, const Color& color, math::Real intensity, int shaderId,
	int terrainShaderId, int noShadowShaderId, int noShadowTerrainShaderId, const Attenuation& attenuation) :
	BaseLight(transform, color, intensity, shaderId, terrainShaderId, noShadowShaderId, noShadowTerrainShaderId, false),
	m_attenuation(attenuation),
	m_range(CalculateRange())
{
	// Beware of using new operator in the constructor (See e.g. http://herbsutter.com/2008/07/25/constructor-exceptions-in-c-c-and-java/)
}
Exemple #3
0
void mystack::add(openEntry entry, int l) {
    if(level == 0) {
      sArr[l]->add(entry);
      expCount[l]++;
      if(expCount[l] >= lim[l]) {
        suspend[l] = true;
      }
      return;
    }
    int idx = CalculateRange(entry);
    sArr[idx]->add(entry, l);
}
Exemple #4
0
/**
 * Decides where to Categorize a plane.
 */
CDTIPlane_Severity Categorizer::CategorizePlane(CDTIPlane plane) {
    double range = CalculateRange(plane);
    double cpa = CalculateCPA(plane);
    if(range < 2 && abs(plane.position().d()) < 300 && cpa < .5)
        return plane.RESOLUTION;
    else if(range < 5 && abs(plane.position().d()) < 500 && cpa < 1)
        return plane.TRAFFIC;
    else if(range < 10 && abs(plane.position().d()) < 1000)
        return plane.PROXIMATE;
    else
        return plane.PROXIMATE;
}
Exemple #5
0
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
	
    int Max;
    int Min;
    int range;
    int numbers[] = {174, 162, 149, 85, 130, 149, 153, 164, 169, 173};
    int sampleArray[N_AVG_SAMPLES];  //Array that numbers are moved into and out of

    Max = -256;                 // Lowest number possible for 1 byte, easily overwritten
    Min = 255;                  // Highest number possible for 1 byte, easily overwritten

    int i = 0;
    int x = 0;
    int avg;
    int avgs[SIZE+2]; //Sets up array to store moving average
    //I had to do this so that the program would not overwrite SizeOfArray

    //Variable x keeps track of i and stores its value
    for(i = 0; i <= N_AVG_SAMPLES; i++){
    	x = i;
    	sampleArray[i] = 0;
    	i = x;
    }

    //Determine size of array
    // int SizeOfArray = sizeof(numbers)/sizeof(int); //Number of bytes in numbers divided by number of bytes in int
    int SizeOfArray = SIZE; //Can get by with only

    //Finds the average
    for(i = 0; i<= SizeOfArray +1; i++){
    	avg = CalcAverage(sampleArray, N_AVG_SAMPLES);
    	avgs[i] = avg;
    	shiftarray(numbers[i], sampleArray, N_AVG_SAMPLES);
    }

    //Calculate max, min, and range of set
    Max = maximum(numbers, Max, SizeOfArray);
    Min = minimum(numbers, Min, SizeOfArray);
    range = CalculateRange(Max, Min);

	while(1){} //Trap CPU

	return 0;
}
/*
* This function is called when the SetTimer call returns.
*/
void AWormHole::Update()
{
    //see if the user canceled skill during chargeup
    if(!m_InUse)
    {
        m_Player->SetCurrentSkill();
        m_DamageTaken = 0.0f;
        return;
    }

    m_InUse = false;

    // Send a message to all the players in range in the group
    Player * p = NULL;
    int GroupID = m_Player->GroupID();
    if (GroupID != 0)
    {
        for(int MID = 0; MID < 6; MID++)
        {
            int MGameID = g_PlayerMgr->GetMemberID(GroupID, MID);

            // Send to everyone but ourself!
            if (MGameID != m_Player->GameID() && MGameID != -1)
            {
                p = g_ServerMgr->m_PlayerMgr.GetPlayer(MGameID);
                if (p)
                {
                    // Make sure we are in the same sector
                    if (p->PlayerIndex()->GetSectorNum() == m_Player->PlayerIndex()->GetSectorNum())
                    {
                        // See if we are now in range of the player
                        if (m_Player->RangeFrom(p->Position()) < CalculateRange(m_SkillLevel, m_SkillRank))
                        {
                            p->SendConfirmation("All cargo items in your inventory will take 50% durability damage if you take this wormHole.  Do you want to take this WormHole?", m_Player->GameID(), m_AbilityID);
                        }
                    }
                }
            }
        }
    }
    m_Player->SendConfirmation("All cargo items in your inventory will take 50% durability damage if you take this wormHole.  Do you want to take this WormHole?", m_Player->GameID(), m_AbilityID);
}
bool ARechargeShields::CanUse(int TargetID, long AbilityID, long SkillID)
{
	// Get the skill level
	m_SkillLevel = (float) m_Player->PlayerIndex()->RPGInfo.Skills.Skill[SkillID].GetLevel();
	m_SkillRank = DetermineSkillRank(AbilityID);
	m_AbilityID = AbilityID;
	m_SkillID = SkillID;
	ObjectManager *om = m_Player->GetObjectManager();

	//Skill does not exist.
	if(m_SkillRank == -1)
	{
		return false;
	}

	// Make sure we are not dead
	if (m_Player->ShipIndex()->GetIsIncapacitated())
	{
		SendError("Can not use this ability while dead!");
		return false;
	}

	// See if we can use this skill
	if (TargetID > 0 && m_SkillRank >= 3 && om)
	{
		Object * Target = om->GetObjectFromID(TargetID);	// Get Target

		if (Target && Target->ObjectType() != m_TargetType)
		{
			SendError("Incorrect target type!");
			return false;
		}

		// See if we are in range
		if (Target->RangeFrom(m_Player->Position()) > CalculateRange(m_SkillLevel, m_SkillRank))
		{
			SendError("Out of range!");
			return false;
		}

		if(g_PlayerMgr->GetPlayer(TargetID)->ShipIndex()->GetIsIncapacitated())
		{
			SendError("Cannot recharge a dead player!");
			return false;
		}
	}

	//If we are prospecting we cannot use this skill
	if (m_Player->Prospecting())
	{
		SendError("Cannot use while prospecting.");
		return false;
	}

	//if we are warping we cannot use the skill
	if (m_Player->WarpDrive())
	{
		SendError("Cannot use while in warp.");
		return false;
	}

	return true;
}
IFXRESULT CIFXLightResource::SetIntensity( F32 fIntensity )
{
	m_Light.SetIntensity(fIntensity);
	CalculateRange();
	return IFX_OK;
}
void CIFXLightResource::SetColor( IFXVector4 vInColor ) 
{ 
	m_Light.SetDiffuse(vInColor);
	m_Light.SetSpecular(vInColor);
	CalculateRange();
}
Exemple #10
0
  void IApp::InitRenderer(void)
  {
    SLOG(App_InitRenderer, SeverityInfo) << std::endl;

    // Not Console only?
    if(!mProperties.Get<bool>("bWindowConsole"))
    {
      // Are we in Fullscreen mode?
      if(mProperties.Get<bool>("bWindowFullscreen"))
      {
        mWindowStyle = sf::Style::Fullscreen;
      }

#if (SFML_VERSION_MAJOR < 2)
      // What size window does the user want?
      mVideoMode.Width = mProperties.Get<Uint32>("uWindowWidth");
      mVideoMode.Height = mProperties.Get<Uint32>("uWindowHeight");
      mVideoMode.BitsPerPixel = mProperties.Get<Uint32>("uWindowDepth");

      // For Fullscreen, verify valid VideoMode, otherwise revert to defaults for Fullscreen
      if(sf::Style::Fullscreen == mWindowStyle && false == mVideoMode.IsValid())
      {
        mVideoMode.Width = DEFAULT_VIDEO_WIDTH;
        mVideoMode.Height = DEFAULT_VIDEO_HEIGHT;
        mVideoMode.BitsPerPixel = DEFAULT_VIDEO_BPP;
      }

      // Calculate and set GraphicRange value
      SetGraphicRange(CalculateRange(mVideoMode.Height));

      // Create a RenderWindow object using VideoMode object above
      mWindow.Create(mVideoMode, mTitle, mWindowStyle, mWindowSettings);

      // Use Vertical Sync
      mWindow.UseVerticalSync(true);
#else
      // What size window does the user want?
      mVideoMode.width = mProperties.Get<Uint32>("uWindowWidth");
      mVideoMode.height = mProperties.Get<Uint32>("uWindowHeight");
      mVideoMode.bitsPerPixel = mProperties.Get<Uint32>("uWindowDepth");

      // For Fullscreen, verify valid VideoMode, otherwise revert to defaults for Fullscreen
      if(sf::Style::Fullscreen == mWindowStyle && false == mVideoMode.isValid())
      {
        mVideoMode.width = DEFAULT_VIDEO_WIDTH;
        mVideoMode.height = DEFAULT_VIDEO_HEIGHT;
        mVideoMode.bitsPerPixel = DEFAULT_VIDEO_BPP;
      }

      // Calculate and set GraphicRange value
      SetGraphicRange(CalculateRange(mVideoMode.height));

      // Create a RenderWindow object using VideoMode object above
      mWindow.create(mVideoMode, mTitle, mWindowStyle, mContextSettings);

      // Use Vertical Sync
      mWindow.setVerticalSyncEnabled(true);
#endif
    }
    else
    {
      ILOG() << "IApp::InitRenderer() Console only application" << std::endl;
    }
  }
void ImageProcessingTools::findLandmarks(char *ptr)
{
	// Make Histograms for each column
	int i,j, pixelIndex;
	double pixelColorHSV[imageSizeC];
	bool imageThreshold[imageSizeX][imageSizeY];
	int YHistogram[imageSizeX];

	// Loop through each x value adding all pixels that pass threshold
	for ( i = 0; i< imageSizeX; i++) {
		YHistogram[i] = 0;
		for (j = 0; j<imageSizeY-50; j++) {
			pixelIndex = (j *imageSizeX + i) * 3;
			COLORREF pixelColorRGB = RGB(ptr[pixelIndex],ptr[pixelIndex+1],ptr[pixelIndex+2]);
			rgb2hsv(pixelColorRGB, pixelColorHSV);
		
			double colorDiff = fabs(pixelColorHSV[0] - (-8.0f));
			if ((colorDiff <  colorTolerance) && (pixelColorHSV[1] > 0.6f) && (pixelColorHSV[2] > 0.6f)){
				imageThreshold[i][j] = true;
				YHistogram[i]++;
			} else {
				imageThreshold[i][j] = false;
			}
		}
	}



	// Look for blobs using histogram
	int blobWidth[100];
	int blobStart[100];
	double blobCenter[100];
	double blobHeight[100];
	int numRowBlobs = 0;
	bool inBlob = false;
	int blobStartX = -100;
	int blobEndX = 0;

	// Make sure that end is detected
	YHistogram[imageSizeX-1] = 0;

	// For each row, look for on edges and off edges
	for (i = 1; i< imageSizeX; i++) {

		// Check to see if color is yellow
		if (YHistogram[i] > 5){
				
			// Check if start of blob
			if (!inBlob){
					
				// Record edge of blob
				inBlob = true;
				blobStartX = i;
			} 

		// Check to see if end of blob in this column
		} else if (inBlob){

			// Record the end of blob if big enough
			blobEndX = i;
			if (blobEndX - blobStartX > 10) {

				// Update blob arrays
				blobStart[numRowBlobs] = blobStartX;
				blobWidth[numRowBlobs] =  - (blobStartX - blobEndX);
				blobCenter[numRowBlobs] = (blobEndX + blobStartX)/2;
				numRowBlobs++;
			}
			inBlob = false;			
		} 
	}



	// Loop through blobs to get heights
	for (i = 0; i<numRowBlobs; i++){
		blobHeight[i] = 0;
		for (j = max(0,((int)blobCenter[i])-heightCalcWindowSize); j < min(imageSizeX,((int)blobCenter[i])+heightCalcWindowSize); j++){
			blobHeight[i] = blobHeight[i] + YHistogram[j]; 
		}
		blobHeight[i] = blobHeight[i]/(2*heightCalcWindowSize);
	}




	// Create Landmark Measurements
	numMeasuredLandmarks = numRowBlobs;
	for (i = 0; i<numMeasuredLandmarks; i++){
		measuredLandmarks[i].x_pixel = blobCenter[i];
		measuredLandmarks[i].h_pixel = blobHeight[i];
		measuredLandmarks[i].range = CalculateRange(blobHeight[i]);
		measuredLandmarks[i].bearing = CalculateBearing(blobCenter[i]);
		measuredLandmarks[i].x_est = measuredLandmarks[i].bearing;
		measuredLandmarks[i].y_est = measuredLandmarks[i].range;
	}

}