示例#1
0
void SponsorsState::enter(const MainMachineInfo &info)
{
	// load the fader state
	ASSERT(!mFader);
	Ogre::OverlayManager &om = Ogre::OverlayManager::getSingleton();
	mFader = om.getByName("FaderOverlay");
	ASSERT(mFader);
	Ogre::PanelOverlayElement *panel = static_cast<Ogre::PanelOverlayElement *>(
					mFader->getChild("FaderOverlay/Background"));
	ASSERT(panel);
	Ogre::MaterialPtr mat = panel->getMaterial();
	ASSERT(!mat.isNull());
	mTexture = mat->getTechnique(0)->getPass(0)->getTextureUnitState(0);
	mTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL,
						Ogre::LBS_TEXTURE, 0);
	ASSERT(mTexture);

	// load the  sponsors Overlay
	ASSERT(!mOverlay);
	mOverlay = om.getByName("SponsorsOverlay");
	ASSERT(mOverlay);
	mOverlay->setZOrder(mFader->getZOrder() - 1);	// put behind it

	mState = STATE_FADE_IN;
}
示例#2
0
/**
 * Create a new PanelOverlayElement
 * @param	matName		The name of the material
 * @param	rSize		The resulting size of the texture (width)
 * @param	name		The name of the panel
 */
Ogre::PanelOverlayElement *GUIHelper::createPanel(const Ogre::String &matName,
		int &rSize, const Ogre::String &name)
{
	static int counter = 0;

	Ogre::PanelOverlayElement *result = 0;
	Ogre::String realName;

	if(name.empty()){
		realName = "pan" + Ogre::StringConverter::toString(counter);
		counter++;
	} else {
		realName = name;
	}

#ifdef DEBUG
	// ensures the material exists
	Ogre::MaterialPtr		material;
	material = Ogre::MaterialManager::getSingleton().getByName(matName);
	if(material.isNull()){
		debug("Material %s not found\n", matName.c_str());
	}
//	ASSERT(!material.isNull());
#endif

	Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
	result = static_cast<Ogre::PanelOverlayElement*>(
		overlayManager.createOverlayElement("Panel", realName));
	result->setMetricsMode(Ogre::GMM_RELATIVE);
	result->setMaterialName(matName); // Optional background material

	// get the texture size
	Ogre::String text = result->getMaterial()->getTechnique(0)->getPass(0)->
			getTextureUnitState(0)->getTextureName();
	Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(text);
	ASSERT(!texture.isNull());
	rSize = texture->getWidth();

	return result;
}