예제 #1
0
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Function Name: Init
// Purpose: Initializes the state.
// Original Author: Ethan Pendergraft
// Creation Date: 5/12/2012
// Last Modification By:
// Last Modification Date:
/////////////////////////////////////////////////////////////////////////////////////////////////////
void COptionsState::Init ()
{
	m_pGame = CGame::GetInstance();
	m_pInput = m_pGame->GetInputManager();
	m_pAudio = m_pGame->GetAudioManager();

	TextureManager* pTM = TextureManager::GetInstance();

	m_lpOptionsVideo		= pTM->GetTexture( pTM->LoadTexture("./Resources/Textures/PS_FE_OptionMenu_Video.png" ) );
	m_lpOptionsAudio        = pTM->GetTexture( pTM->LoadTexture("./Resources/Textures/PS_FE_OptionMenu_Audio.png" ) );
	m_lpOptionsExit			= pTM->GetTexture( pTM->LoadTexture("./Resources/Textures/PS_FE_OptionMenu_Exit.png" ) );
	m_nReticle				= pTM->GetTexture( pTM->LoadTexture("./Resources/Textures/T_Reticle_D.png"));

	m_nCurrentlySelected	= OPT_VIDEO;
}						  
예제 #2
0
AnimatedSprite::AnimatedSprite(TextureManager & TM, std::string adr,int nbrFX,int nbrFY,int size,int vit,bool centrer)
{
    std::string imAdr(adr);
    imAdr.append(".png");
    std::string dataAdr(adr);
    dataAdr.append(".data");

    image.setTexture(*(TM.GetTexture(imAdr)));

    frameX = 1;
    frameY = 1;

    cpt = 0;
    vitesse  = vit;
    nbrFrameX = nbrFX;
    nbrFrameY = nbrFY;

    scale = size;
    image.setTextureRect(sf::IntRect(0,0,image.getTexture()->getSize().x/nbrFrameX,image.getTexture()->getSize().y/nbrFrameY));

    image.setScale((((float)size*nbrFrameX)/((float)image.getTexture()->getSize().x)),
                   (((float)size*nbrFrameY)*(((float)image.getTexture()->getSize().y)/((float)image.getTexture()->getSize().x)))
                   /((float)image.getTexture()->getSize().y));
    if(centrer){
     //   if(nbrFrame == 1)
       //     image.SetCenter(0,image.GetImage()->GetHeight()/2);
       // else
        image.setOrigin(image.getTexture()->getSize().x/(2*(nbrFrameX)),image.getTexture()->getSize().y/(2*nbrFrameY));
    }
   // dataAnalyser(width,dataAdr);

}
예제 #3
0
Carte::Carte(TextureManager &TM, std::string adr1, std::string adr2, std::string adr3)
{

    //hb = new Hitbox(IM,adr);


    Iinf.setTexture(*(TM.GetTexture(adr1)));

    Isup.setTexture(*(TM.GetTexture(adr2)));
    hitbox.setTexture(*(TM.GetTexture(adr3)));
    hbpath = adr3;

//    Iinf.Resize(w,h);
//    Isup.Resize(w,h);
//    hitbox.Resize(w,h);


}
예제 #4
0
void Sprite::Render(ID3DXSprite *sprite) {
  TextureManager *TexMan = TextureManager::GetSingleton();

  if (enabled && TexMan->IsTextureValid(tex)) {
    TextureRecord *TexRec = TexMan->GetTexture(tex);

    if (TexRec->IsType(TR_PLANAR)) {
      sprite->SetTransform(&transform);
      sprite->Draw((LPDIRECT3DTEXTURE9)TexRec->GetTexture(), 0, 0, &pos, color);
    }
  }
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Function Name: Render
// Purpose: Render the state.
// Original Author: Rueben Massey
// Creation Date: 5/30/2012
// Last Modification By:
// Last Modification Date:
/////////////////////////////////////////////////////////////////////////////////////////////////////
void CVideoOptionsState::Render()
{
	TextureManager* pTM = TextureManager::GetInstance();
	RenderEngine::RasterTexture( pTM->GetTexture(m_lpCurrentSelection), 0.0f, 0.0f, 1.0f, 1.0f );
	// Render Brightness Slider
	//RenderEngine::RasterTexture( m_lpOptionsSlider, m_fBrightnessSliderPosVec.x, m_fBrightnessSliderPosVec.y, m_fBrightnessSliderPosVec.x + VSLIDER_WIDTH, m_fBrightnessSliderPosVec.y + VSLIDER_HEIGHT );

	// render block out if full screen
	if( m_pGame->GetFullScreen() )
	{
		// Render Gamma Slider
		if(m_pInput->LeftMouseButtonDown() && m_nCurrentlySelected == VIDEO_GAMMA && m_bLocked)
		{
			RenderEngine::RasterTexture( pTM->GetTexture(m_lpOptionsSlider), m_fGammaSliderPosVec.x, m_fGammaSliderPosVec.y, m_fGammaSliderPosVec.x + VSLIDER_DOWN_WIDTH, m_fGammaSliderPosVec.y + VSLIDER_DOWN_HEIGHT );
		}
		else
		{
			RenderEngine::RasterTexture( pTM->GetTexture(m_lpOptionsSlider), m_fGammaSliderPosVec.x, m_fGammaSliderPosVec.y, m_fGammaSliderPosVec.x + VSLIDER_WIDTH, m_fGammaSliderPosVec.y + VSLIDER_HEIGHT );
		}
	}
	else
	{
		RenderEngine::RasterTexture( pTM->GetTexture(m_lpFullScreenBlockOut), m_fGammaSliderPosVec.x, m_fGammaSliderPosVec.y, m_fGammaSliderPosVec.x + VSLIDER_WIDTH, m_fGammaSliderPosVec.y + VSLIDER_HEIGHT );
	}

	// Render The Check Mark
	RenderEngine::RasterTexture( pTM->GetTexture(m_lpOptionsCheck), m_fCheckMarkPos.x, m_fCheckMarkPos.y, m_fCheckMarkPos.x + VCHECKMARK_WIDTH, m_fCheckMarkPos.y + VCHECKMARK_HEIGHT );

	//Render the cursor reticle at the mouse position
	RenderEngine::RasterTexture(pTM->GetTexture(m_nReticle), _mousePos.x - 0.02f, (-_mousePos.y - 0.02f) + 1.0f, _mousePos.x + 0.02f, (-_mousePos.y + 0.02f) + 1.0f );
}	
예제 #6
0
	Texture* TextureUnit::GetTexture(void)
	{
		if (mTexture)
		{
			return mTexture;
		}

		// get from texture manager
		TextureManager* texMgr = TextureManager::getSingleton();
		if(texMgr)
       		{
            		mTexture = texMgr->GetTexture(this->mPicName);
        	}

		return mTexture;
	}
예제 #7
0
/**
 * Constructeur d'image animé
 * @brief AnimatedSprite::AnimatedSprite
 * @param IM
 * @param adr
 * @param nbrF
 * @param width
 * @param height
 * @param centreX
 * @param centreY
 * @param vit
 */
AnimatedSprite::AnimatedSprite(TextureManager & TM, std::string adr,int nbrFX,int size, int centreX, int centreY,int vit)
{
    std::string imAdr(adr);
    imAdr.append(".png");
    std::string dataAdr(adr);
    dataAdr.append(".data");

    image.setTexture(*(TM.GetTexture(imAdr)));

    frameX = 1;
    frameY = 1;
    cpt = 0;
    vitesse  = vit;
    nbrFrameX = nbrFX;
    nbrFrameY = 1;
    scale = size;

    image.setScale(image.getScale().x/size,image.getScale().y/size);
    image.setOrigin(image.getTexture()->getSize().x/(centreX*nbrFrameX),image.getTexture()->getSize().y/(centreY*nbrFrameY));
    image.setTextureRect(sf::IntRect(0,0,image.getTexture()->getSize().x/nbrFrameX,image.getTexture()->getSize().y/nbrFrameY));
   // dataAnalyser(width,dataAdr);

}
예제 #8
0
void TimeClock::FillSunMoonStruct()
{
	//////////////////////////////////////////
	// Where is the sun or moon?
	//////////////////////////////////////////
	float hour = HoursElapsed();
	const float HOUR_TO_RAD = ( 2.0f * PI ) / 24.0f;

	if ( !holdSun )
	{
		// Hour 0 is midnight.
		sunMoon.vector.x = (float) sin( hour * HOUR_TO_RAD );
		sunMoon.vector.y = (float) 0;
		sunMoon.vector.z = (float) -cos( hour * HOUR_TO_RAD );

		if ( sunMoon.vector.z < 0.0f )
		{
			sunMoon.sun = false;
			sunMoon.vector.x = -sunMoon.vector.x;
			sunMoon.vector.y = -sunMoon.vector.y;
			sunMoon.vector.z = -sunMoon.vector.z;
		}
		else
		{
			sunMoon.sun = true;
		}

	}
	else
	{
		switch ( holdSun ) 
		{
			case HOLD_MIDDAY:	
		sunMoon.sun = true;
		sunMoon.vector.x = 0.0f;
		sunMoon.vector.y = 0.0f;
		sunMoon.vector.z = 1.0f;
				break;

			case HOLD_SUNRISE:
			default:
				sunMoon.sun = true;
				sunMoon.vector.x = 0.9f;
				sunMoon.vector.y = 0.0f;
				sunMoon.vector.z = sqrtf( 1.0f - sunMoon.vector.x*sunMoon.vector.x );
				break;
		}
	}
	GLASSERT( Equal( sunMoon.vector.Length(), 1.0f, 0.001f ) );


	//////////////////////////////////////////
	// What color is it?
	//////////////////////////////////////////

//	sunMoon.ambientAmount = 0.40f;
//	sunMoon.diffuseAmount = 0.60f;

	float ambientAmountH = 0.40f;
	float diffuseAmountH = 0.60f;

	float ambientAmountL = 0.55f;
	float diffuseAmountL = 0.45f;

	// Midnight: 0, Sunrise: 6, Midday: 12, Sunset: 18
	const SkyState skyState[] = 
	{
		{	0.0f,	SunMoon::NIGHT },
		{	5.0f,	SunMoon::NIGHT },
		{	7.0f,	SunMoon::SUNRISE },
		{	9.0f,	SunMoon::DAYTIME },
		{	15.0f,	SunMoon::DAYTIME },
		{	17.0f,	SunMoon::SUNSET },
		{	19.0f,	SunMoon::NIGHT },
		{	24.0f,  SunMoon::NIGHT },
	};

	// The diffuse color is projected by the vector...so it must be dark until 6,
	// and light until 18, else the light will shine in the wrong direction...
	const ColorState diffuseColorState[] =
	{
		{	0.0f,	{ MOON_RED, MOON_GREEN, MOON_BLUE } },
		{	5.0f,	{ MOON_RED, MOON_GREEN, MOON_BLUE } },
		{	6.0f,	{ 0.0f, 0.0f, 0.0f } },
		{	6.5f,	{ 1.0f, (float)(30.0/255.0), 0.0f } },
		{	7.0f,	{ 1.0f, (float)(126.0/255.0), 0.0f } },
		{	8.0f,	{ 1.0f, (float)(170.0/255.0), (float)(80.0/255.0) } },
		{   9.0f,	{ 1.0f, 1.0f, 1.0f } },
		{	15.0f,	{ 1.0f, 1.0f, 1.0f } },
		{	16.0f,	{ (float)(250.0/255.0), (float)(156.0/255.0), (float)(253.0/255.0) }},
		{	17.0f,	{ (float)(200.0/255.0), (float)(56.0/255.0), (float)(176.0/255.0) }},
		{	18.0f,	{ 0.0f, 0.0f, 0.0f } },
		{	19.0f,	{ MOON_RED, MOON_GREEN, MOON_BLUE } },
		{	24.0f,	{ MOON_RED, MOON_GREEN, MOON_BLUE } },
	};

	const ColorState ambientColorState[] =
	{
		{	0.0f,	{ MOON_RED, MOON_GREEN, 1.0f } },
		{	5.0f,	{ MOON_RED, MOON_GREEN, 1.0f } },
		{	6.5f,	{ 1.0f, (float)(30.0/255.0), 0.0f } },
		{	7.0f,	{ 1.0f, (float)(126.0/255.0), 0.0f } },
		{	8.0f,	{ 1.0f, (float)(170.0/255.0), (float)(80.0/255.0) } },
		{	9.0f,	{ 1.0f, 1.0f, 1.0f } },
		{	15.0f,	{ 1.0f, 1.0f, 1.0f } },
		{	17.0f,	{ (float)(200.0/255.0), (float)(56.0/255.0), (float)(176.0/255.0) }},
		{	19.0f,	{ MOON_RED, MOON_GREEN, 1.0f } },
		{	24.0f,	{ MOON_RED, MOON_GREEN, 1.0f } },
	};

	U32 day, h, minute, second;
	CalcCalendarTime( &day, &h, &minute, &second );
	float time = (float)(h) + ((float)(minute))/60.0f + ((float)(second))/3600.0f;
	GLASSERT( time >= 0.0f && time < 24.0f );

	if ( holdSun )
	{
		time = 12.0f;
	}

	int i;
	for ( i=0; true; ++i )
	{
		if ( time >= skyState[i].hour && time < skyState[i+1].hour )
		{
			sunMoon.primarySky = skyState[i].state;
			sunMoon.secondarySky = skyState[i+1].state;
			sunMoon.skyBlend = 0.0f;
			if ( sunMoon.primarySky != sunMoon.secondarySky )
				sunMoon.skyBlend = Interpolate( skyState[i].hour, 0.0f, skyState[i+1].hour, 1.0f, time );
			break;
		}
	}

	for ( i=0; true; ++i )
	{
		if ( time >= diffuseColorState[i].hour && time < diffuseColorState[i+1].hour )
		{
			sunMoon.rawDiffuseColor.r = Interpolate(  diffuseColorState[i].hour, diffuseColorState[i].color.r,
														diffuseColorState[i+1].hour, diffuseColorState[i+1].color.r,
														time );
			sunMoon.rawDiffuseColor.g = Interpolate(  diffuseColorState[i].hour, diffuseColorState[i].color.g,
														diffuseColorState[i+1].hour, diffuseColorState[i+1].color.g,
														time );
			sunMoon.rawDiffuseColor.b = Interpolate(  diffuseColorState[i].hour, diffuseColorState[i].color.b,
														diffuseColorState[i+1].hour, diffuseColorState[i+1].color.b,
														time );
			break;
		}
	}


	for ( i=0; true; ++i )
	{
		if ( time >= ambientColorState[i].hour && time < ambientColorState[i+1].hour )
		{
			sunMoon.rawAmbientColor.r = Interpolate(  ambientColorState[i].hour, ambientColorState[i].color.r,
														ambientColorState[i+1].hour, ambientColorState[i+1].color.r,
														time );
			sunMoon.rawAmbientColor.g = Interpolate(  ambientColorState[i].hour, ambientColorState[i].color.g,
														ambientColorState[i+1].hour, ambientColorState[i+1].color.g,
														time );
			sunMoon.rawAmbientColor.b = Interpolate(  ambientColorState[i].hour, ambientColorState[i].color.b,
														ambientColorState[i+1].hour, ambientColorState[i+1].color.b,
														time );
			break;
		}
	}


	sunMoon.ambientColorH = sunMoon.rawAmbientColor * ambientAmountH;
	sunMoon.diffuseColorH = sunMoon.rawDiffuseColor * diffuseAmountH;

	sunMoon.ambientColorL = sunMoon.rawAmbientColor * ambientAmountL;
	sunMoon.diffuseColorL = sunMoon.rawDiffuseColor * diffuseAmountL;

	sunMoon.ambientColorL4.r = sunMoon.ambientColorL.r;
	sunMoon.ambientColorL4.g = sunMoon.ambientColorL.g;
	sunMoon.ambientColorL4.b = sunMoon.ambientColorL.b;
	sunMoon.ambientColorL4.a = 1.0f;

	sunMoon.diffuseColorL4.r = sunMoon.diffuseColorL.r;
	sunMoon.diffuseColorL4.g = sunMoon.diffuseColorL.g;
	sunMoon.diffuseColorL4.b = sunMoon.diffuseColorL.b;
	sunMoon.diffuseColorL4.a = 1.0f;

	sunMoon.ambientColorH4.r = sunMoon.ambientColorH.r;
	sunMoon.ambientColorH4.g = sunMoon.ambientColorH.g;
	sunMoon.ambientColorH4.b = sunMoon.ambientColorH.b;
	sunMoon.ambientColorH4.a = 1.0f;

	sunMoon.diffuseColorH4.r = sunMoon.diffuseColorH.r;
	sunMoon.diffuseColorH4.g = sunMoon.diffuseColorH.g;
	sunMoon.diffuseColorH4.b = sunMoon.diffuseColorH.b;
	sunMoon.diffuseColorH4.a = 1.0f;

	sunMoon.vector4.x = sunMoon.vector.x;
	sunMoon.vector4.y = sunMoon.vector.y;
	sunMoon.vector4.z = sunMoon.vector.z;
	sunMoon.vector4.w = 0.0f;	// Parallel

	//////////////////////////////////////////
	// Set up the skybox
	//////////////////////////////////////////

	TextureManager* texman = TextureManager::Instance();

	sunMoon.primarySkydomeTex = 0;
	sunMoon.secondarySkydomeTex = 0;

	switch( sunMoon.primarySky )
	{
		case SunMoon::SUNRISE:	sunMoon.primarySkydomeTex = texman->GetTexture( "skydomeSunrise", 0 );		break;
		case SunMoon::SUNSET:	sunMoon.primarySkydomeTex = texman->GetTexture( "skydomeSunset", 0 );		break;
		case SunMoon::DAYTIME:	sunMoon.primarySkydomeTex = texman->GetTexture( "skydomeDay", day&1 );		break;
		case SunMoon::NIGHT:	sunMoon.primarySkydomeTex = texman->GetTexture( "skydomeNight", 0 );		break;
		default:	
			GLASSERT( 0 );
	}
	if ( sunMoon.primarySky != sunMoon.secondarySky )
	{
		switch( sunMoon.secondarySky )
		{
		case SunMoon::SUNRISE:	sunMoon.secondarySkydomeTex = texman->GetTexture( "skydomeSunrise", 0 );	break;
		case SunMoon::SUNSET:	sunMoon.secondarySkydomeTex = texman->GetTexture( "skydomeSunset", 0 );		break;
		case SunMoon::DAYTIME:	sunMoon.secondarySkydomeTex = texman->GetTexture( "skydomeDay", day&1 );	break;
		case SunMoon::NIGHT:	sunMoon.secondarySkydomeTex = texman->GetTexture( "skydomeNight", 0 );		break;

			default:
				GLASSERT( 0 );
		}
	}

	if ( !sunMoon.secondarySkydomeTex )
	{
		sunMoon.skyColor = sunMoon.primarySkydomeTex->AverageOpaqueColor();
	}
	else
	{
		Color3F c0 = sunMoon.primarySkydomeTex->AverageOpaqueColor();
		Color3F c1 = sunMoon.secondarySkydomeTex->AverageOpaqueColor();
		sunMoon.skyColor.r = c0.r*(1.0f-sunMoon.skyBlend) + c1.r*sunMoon.skyBlend;
		sunMoon.skyColor.g = c0.g*(1.0f-sunMoon.skyBlend) + c1.g*sunMoon.skyBlend;
		sunMoon.skyColor.b = c0.b*(1.0f-sunMoon.skyBlend) + c1.b*sunMoon.skyBlend;
	}
}