コード例 #1
0
int GameObjectFlashLight::calculateCurrentColour(double elapsedSeconds)
{
	int nextColour;

	ColourValue ogreTargetColour;
	ColourValue ogreCurrentColour;
	ColourValue ogreNextColour;
	double incr;

	ogreTargetColour.setAsRGBA(mTargetColour);
	ogreCurrentColour.setAsRGBA(mCurrentColour);
	incr=mGameWorldManager->CHANGE_FLASHLIGHT_COLOUR_SPEED*elapsedSeconds;

	ogreNextColour.r=ogreCurrentColour.r+(ogreTargetColour.r-ogreCurrentColour.r)*incr;
	ogreNextColour.g=ogreCurrentColour.g+(ogreTargetColour.g-ogreCurrentColour.g)*incr;
	ogreNextColour.b=ogreCurrentColour.b+(ogreTargetColour.b-ogreCurrentColour.b)*incr;
	ogreNextColour.a=1;

	if(Ogre::Math::Abs(ogreTargetColour.r-ogreCurrentColour.r)<incr &&
		Ogre::Math::Abs(ogreTargetColour.g-ogreCurrentColour.g)<incr &&
		Ogre::Math::Abs(ogreTargetColour.b-ogreCurrentColour.b)<incr)
	{
		nextColour=mTargetColour;
	}
	else
	{
		nextColour=ogreNextColour.getAsRGBA();
	}

	return nextColour;
}	
コード例 #2
0
void GameObjectFlashLight::setColour(int colour)
{
		ColourValue ogreColour;
		ogreColour.setAsRGBA(colour);
		mRenderComponentLight->setDiffuseColor(ogreColour);
		mRenderComponentLight->setSpecularColor(ogreColour);
		//TODO: radius, etc, should also be modified here
		if (mFlashlightDecalComponent.get())
		{
			mFlashlightDecalComponent->changeColour(colour);
			if (mFlashlightDecalComponent->isVisible())
			{	
				mFlashlightDecalComponent->hide();
				mFlashlightDecalComponent->show();
			}
		}
		if (mConeEntity)
		{
			applyTintColour(colour);
		}
}