//------------------------------------------------------------------------
	MaterialPtr MaterialUtil::generateMaterial(const MtlPtr& _mtl, const MatGenParams& _matGenParams)
	{
		MaterialPtr material;
		Mtl::MaterialHandles::iterator it = _mtl->mMaterialHandles.find(_matGenParams);
		if(it != _mtl->mMaterialHandles.end())
		{
			// Material was generated already, just return it
			// (Materials can be shared.)
			ResourceHandle handle = it->second;
			material = MaterialManager::getSingleton().getByHandle(handle);
		}
		else
		{
			// Generate a new material
			String materialName = s_MaterialNameGenerator.generate();
			material = MaterialManager::getSingleton().create(materialName, StringUtil::BLANK);
			
			// We need a material generator.
			MaterialGenerator* generator = MaterialGeneratorRegistration::getSingleton().getGenerator();

			// Initalise the material with the specified params.
			generator->_updateMaterial(material, _mtl, _matGenParams);

			// Store the smart pointer to the mtl and the material generation params
			// in the material's "user any" member.
			if(!material->getNumTechniques())
			{
				MaterialManager::getSingleton().remove( (ResourcePtr) material);
				return MaterialPtr();
			}
			Technique* technique = material->getTechnique(0);
			UserObjectBindings& uob = technique->getUserObjectBindings();
			uob.setUserAny( USER_MTL, (Any) _mtl );
			uob.setUserAny( USER_MAT_GEN_PARAMS, (Any) _matGenParams );

			// Store the handle to the new material in the mtl.
			ResourceHandle handle = material->getHandle();
			_mtl->mMaterialHandles.insert(std::make_pair(_matGenParams, handle));
		}
		return material;
	}
Exemple #2
0
Button* Button::create(Container* container)
{
	WidgetFactory* wf = UiModule::instance()->getWidgetFactory();
	Button* btn = wf->createButton(sButtonNameGenerator.generate(), container);
	return btn;
}
Exemple #3
0
Container* Container::create(Layout layout, Container* container)
{
    WidgetFactory* wf = UiModule::instance()->getWidgetFactory();
    return wf->createContainer(sContainerNameGenerator.generate(), container, layout);
}
Exemple #4
0
Label* Label::create(Container* container)
{
	WidgetFactory* wf = UiModule::instance()->getWidgetFactory();
	Label* label = wf->createLabel(sLabelNameGenerator.generate(), container);
	return label;
}
Exemple #5
0
Slider* Slider::create(Container* container)
{
	WidgetFactory* wf = UiModule::instance()->getWidgetFactory();
	Slider* slider = wf->createSlider(sSliderNameGenerator.generate(), container);
	return slider;
}