本文整理汇总了C++中ogre::MaterialPtr类的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr类的具体用法?C++ MaterialPtr怎么用?C++ MaterialPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MaterialPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateLegacyMaterials
void UpdateLegacyMaterials(const std::string& texture_name)
{
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
for (uint i = 0; i < MAX_MATERIAL_VARIATIONS; ++i)
{
std::string material_name = texture_name + MaterialSuffix[i];
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
continue;
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(BaseMaterials[i]);
else
base_material = mm.getByName(AlphaBaseMaterials[i]);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[i] + " base material for " + texture_name);
continue;
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
}
}
示例2: notifyMaterialSetup
//---------------------------------------------------------------------------
void GaussianListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
// Prepare the fragment params offsets
switch(pass_id)
{
case 701: // blur horz
{
// horizontal bloom
mat->load();
Ogre::GpuProgramParametersSharedPtr fparams =
mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsHorz[0], 15);
fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
break;
}
case 700: // blur vert
{
// vertical bloom
mat->load();
Ogre::GpuProgramParametersSharedPtr fparams =
mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
fparams->setNamedConstant("sampleOffsets", mBloomTexOffsetsVert[0], 15);
fparams->setNamedConstant("sampleWeights", mBloomTexWeights[0], 15);
break;
}
}
}
示例3: setChangeWorldFactor
void RenderComponentBillboardSet::setChangeWorldFactor(double factor)
{
Ogre::Technique * technique;
Ogre::GpuProgramParametersSharedPtr params;
Ogre::Pass * pass;
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(mChangeWorldMaterial);
if(material.get())
{
technique= material->getTechnique(0);
if(technique)
{
if(technique->getNumPasses()>0)
{
pass=technique->getPass(0);
if(pass->hasFragmentProgram())
{
params=pass->getFragmentProgramParameters();
if(params.get())
{
params->setNamedConstant("mix_factor",Ogre::Real(factor));
}
}
}
}
}
}
示例4: compileMaterial
bool Simple::compileMaterial(Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
if (!mTerrainPageSurfaces.empty()) {
//First add a base pass
auto surfaceLayer = mTerrainPageSurfaces.begin()->second;
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
textureUnitState->setTextureCoordSet(0);
for (auto& layer : mLayers) {
addPassToTechnique(*mGeometry, technique, layer, managedTextures);
}
}
if (mTerrainPageShadow) {
addShadow(technique, mTerrainPageShadow, material, managedTextures);
}
// addLightingPass(technique, managedTextures);
material->load();
if (material->getNumSupportedTechniques() == 0) {
S_LOG_WARNING("The material '" << material->getName() << "' has no supported techniques. The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
return false;
}
return true;
}
示例5: addToGraph
void BoxChunk::addToGraph(Ogre::SceneManager* sceneMgr)
{
// set up Ogre properties
entity = sceneMgr->createEntity(name, "cube.mesh");
// Create BoxChunk materials
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name+"Mat",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
entity->setMaterial(mat);
entity->setMaterial(mat);
entity->setCastShadows(false);
node = sceneMgr->getRootSceneNode()->createChildSceneNode(name);
node->attachObject(entity);
Ogre::Real cur_height = entity->getBoundingBox().getSize().y;
node->scale(height/cur_height, height/cur_height, height/cur_height);
node->rotate(Ogre::Quaternion(((float)(rand() % 10))/10.f, ((float)(rand() % 10))/10.f,
((float)(rand() % 10))/10.f, ((float)(rand() % 10))/10.f));
Ogre::ColourValue c(1, 0, 0, 1);
mat->setAmbient(c);
mat->setDiffuse(c);
mat->setSpecular(c);
}
示例6: _createIndicatorInstance
void DatuPointEditAction::_createIndicatorInstance(void)
{
Ogre::SceneManager* sceneManager = mSceneManipulator->getSceneManager();
mSoundMovingEntity = sceneManager->createEntity("DatuPointMovingEntity", "axes.mesh");
mSoundNode = mSceneManipulator->getIndicatorRootSceneNode()->createChildSceneNode();
mSoundNode->setVisible(false);
mSoundNode->createChildSceneNode()->attachObject(mSoundMovingEntity);
mSoundMovingEntity->getParentSceneNode()->setScale(10,10,10);
Real radius = 1;
int rings = 16;
int segments = 64;
Ogre::MeshPtr sphereMesh = WX::createCommonSphere("DatuPointRadiusEntity", radius, rings, segments);
Ogre::MaterialPtr material = WX::createPureColourMaterial(
Ogre::ColourValue(1, 0, 0, 0.75) );
material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);
mDatuPointRadiusEntity = sceneManager->createEntity("DatuPointRadiusEntity", sphereMesh->getName());
mSoundNode->createChildSceneNode()->attachObject(mDatuPointRadiusEntity);
mDatuPointRadiusEntity->setMaterialName(material->getName());
mDatuPointRadiusEntity->getParentSceneNode()->setVisible(false);
mFirstInit = true;
}
示例7: CreateSky
void EC_Sky::CreateSky()
{
if (!ViewEnabled())
return;
if (world_.expired())
return;
QString currentMaterial = materialRef.Get().ref;
Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(currentMaterial.toStdString().c_str());
//Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(framework->Asset()->LookupAssetRefToStorage(materialRef.Get().ref).toStdString().c_str());
if (materialPtr.isNull())
{
LogError("Could not get SkyBox material : " + currentMaterial.toStdString());
return;
}
materialPtr->setReceiveShadows(false);
try
{
world_.lock()->GetSceneManager()->setSkyBox(true, currentMaterial.toStdString().c_str(), distance.Get(),
drawFirst.Get(), orientation.Get());
}
catch(Ogre::Exception& e)
{
LogError("Could not set SkyBox: " + std::string(e.what()));
}
}
示例8: apply_color
void CubeUpdater::apply_color(Ogre::Entity* entity, float r, float g, float b)
{
Ogre::MaterialPtr manObj = entity->getSubEntity(0)->getMaterial();
float newR(r/255.0f), newG(g/255.0f), newB(b/255.0f);
ColourValue oldColor(manObj->getTechnique(0)->getPass(0)->getDiffuse());
if (oldColor.r == newR && oldColor.g == newG && oldColor.b == newB)
{
return;
}
if (!is_first_update)
{
cout << "New color " << newR << ", " << newG << ", " << newB << " | ";
cout << "Old color " << oldColor.r << ", " << oldColor.g << ", " << oldColor.b << " | ";
cout << "Diff = " << newR-oldColor.r<< endl;
newR = scale_value(oldColor.r, newR, _config->get<double>("application.grid.adaptive_factor"), 0.01);
newG = scale_value(oldColor.g, newG, _config->get<double>("application.grid.adaptive_factor"), 0.01);
newB = scale_value(oldColor.b, newB, _config->get<double>("application.grid.adaptive_factor"), 0.01);
cout << "Actual New color " << newR << ", " << newG << ", " << newB << endl;
}
//
manObj->getTechnique(0)->getPass(0)->setDiffuse(Ogre::ColourValue(newR, newG, newB));
manObj->getTechnique(0)->getPass(0)->setAmbient(Ogre::ColourValue(newR/2.0f, newG/2.0f, newB/2.0f));
//manObj->getTechnique(0)->getPass(0)->setSelfIllumination(Ogre::ColourValue(r, g, b));
}
示例9: notifyMaterialRender
void HDRListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if(pass_id == 600 || pass_id == 800)
{
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("toneMapSettings"))
{
Ogre::Vector4 toneMapSettings(1-mApp->pSet->hdrParam1, mApp->pSet->hdrParam2, mApp->pSet->hdrParam3, 1.0);
params->setNamedConstant("toneMapSettings", toneMapSettings);
}
if (params->_findNamedConstantDefinition("bloomSettings"))
{
Ogre::Vector4 bloomSettings(mApp->pSet->hdrbloomorig*2, mApp->pSet->hdrbloomint, 1.0, 1.0);
params->setNamedConstant("bloomSettings", bloomSettings);
}
if (params->_findNamedConstantDefinition("vignettingSettings"))
{
Ogre::Vector4 vignettingSettings(mApp->pSet->vignettingRadius, mApp->pSet->vignettingDarkness, 1.0, 1.0);
params->setNamedConstant("vignettingSettings", vignettingSettings);
}
}
else if(pass_id == 989)
{
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("AdaptationScale"))
{
params->setNamedConstant("AdaptationScale", mApp->pSet->hdrAdaptationScale);
}
}
}
示例10: SetMaterial
void EC_OgreMovableTextOverlay::SetMaterial(const std::string& new_base_material)
{
///\todo Make this work for other materials!
// Clone own copy of the material for this overlay.
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mm.getByName(new_base_material);
if (material.get())
{
baseMaterialName_ = new_base_material;
Ogre::MaterialPtr baseMaterial = mm.getByName(baseMaterialName_);
materialName_ = renderer_.lock()->GetUniqueObjectName();
material = baseMaterial->clone(materialName_);
//todo Check that the the material alpha channel?
const Ogre::LayerBlendModeEx &blend = baseMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->getAlphaBlendMode();
if (blend.alphaArg1 > 0)
materialHasAlpha_ = true;
else
materialHasAlpha_ = false;
// Set the max alpha for the material.
materialMaxAlpha_ = blend.alphaArg1;
container_->setMaterialName(materialName_);
}
else
OgreRenderingModule::LogError("Invalid material name!");
}
示例11: load
/* Loads the app */
void ImgShowerApp::load(void)
{
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
if(!mContainer){
// Create a panel
mContainer = static_cast<Ogre::OverlayContainer*>(
overlayManager.createOverlayElement("Panel", "ImgShowerAppPanel"));
mContainer->setMetricsMode(Ogre::GMM_RELATIVE);
mContainer->setPosition(0, 0);
mContainer->setDimensions(1, 1);
mContainer->setMaterialName(mOverlayName); // Optional background material
// Ensures that the material exists
#ifdef DEBUG
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(
mOverlayName,Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
ASSERT(!mat.isNull());
#endif
}
if(!mOverlay){
// Create an overlay, and add the panel
mOverlay = overlayManager.create("ImgShowerAppOverlay");
mOverlay->add2D(mContainer);
mOverlay->show();
}
// extracted from http://www.ogre3d.org/tikiwiki/Creating+Overlays+via+Code
}
示例12: ReplaceTextureOnMaterial
void ReplaceTextureOnMaterial(Ogre::MaterialPtr material, const std::string& original_name, const std::string& texture_name)
{
if (material.isNull())
return;
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr tex = tm.getByName(texture_name);
Ogre::Material::TechniqueIterator iter = material->getTechniqueIterator();
while(iter.hasMoreElements())
{
Ogre::Technique *tech = iter.getNext();
assert(tech);
Ogre::Technique::PassIterator passIter = tech->getPassIterator();
while(passIter.hasMoreElements())
{
Ogre::Pass *pass = passIter.getNext();
Ogre::Pass::TextureUnitStateIterator texIter = pass->getTextureUnitStateIterator();
while(texIter.hasMoreElements())
{
Ogre::TextureUnitState *texUnit = texIter.getNext();
if (texUnit->getTextureName() == original_name)
{
if (tex.get())
texUnit->setTextureName(texture_name);
else
texUnit->setTextureName("TextureMissing.png");
}
}
}
}
}
示例13: GetMaterialTextureNames
StringVector EC_OgreSky::GetMaterialTextureNames()
{
StringVector texture_names;
Ogre::MaterialPtr skyMaterial;
switch(type_)
{
case OgreRenderer::SKYTYPE_BOX:
skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyBoxParameters.material);
break;
case OgreRenderer::SKYTYPE_DOME:
skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyDomeParameters.material);
break;
case OgreRenderer::SKYTYPE_PLANE:
skyMaterial = Ogre::MaterialManager::getSingleton().getByName(skyPlaneParameters.material);
break;
}
if (!skyMaterial.isNull())
{
Ogre::TextureUnitState *texture_state = skyMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0);
if (texture_state)
for(uint i = 0; i < texture_state->getNumFrames(); i++)
texture_names.push_back(texture_state->getFrameTextureName(i));
//Ogre::String textures = texture_state->getTextureName();
//texture_names = Ogre::StringConverter::parseStringVector(textures);
}
return texture_names;
}
示例14: setup
//-------------------------------------------------------------------------------------
bool BaseApplication::setup(void)
{
mRoot = new Ogre::Root(mPluginsCfg);
setupResources();
bool carryOn = configure();
if (!carryOn) return false;
chooseSceneManager();
createCamera();
createViewports();
// Set default mipmap level (NB some APIs ignore this)
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
// Create background material
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("Background", "General");
material->getTechnique(0)->getPass(0)->createTextureUnitState("space.jpg");
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
// Create background rectangle covering the whole screen
rect = new Ogre::Rectangle2D(true);
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
rect->setMaterial("Background");
// Render the background before everything else
rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND);
// Use infinite AAB to always stay visible
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
rect->setBoundingBox(aabInf);
// Attach background to the scene
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Background");
node->attachObject(rect);
// Example of background scrolling
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setScrollAnimation(-0.10, 0.0);
// Don't forget to delete the Rectangle2D in the destructor of your application:
// Create any resource listeners (for loading screens)
createResourceListener();
// Load resources
loadResources();
// Create the scene
createScene();
createFrameListener();
return true;
};
示例15: CreateInitialWorld
void PlayState::CreateInitialWorld() {
// Creacion de la entidad y del SceneNode ------------------------
Plane plane1(Vector3(0,1,0), 0); // Normal y distancia
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( "GroundJ", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::TextureUnitState* tuisTexture = mat->getTechnique(0)->getPass(0)->createTextureUnitState("ground2.jpg");
MeshManager::getSingleton().createPlane("p1",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane1,
200, 200, 1, 1, true, 1, 35, 35, Vector3::UNIT_Z);
SceneNode* node = _sceneMgr->createSceneNode("groundJ");
Entity* groundEnt = _sceneMgr->createEntity("planeEnt", "p1");
groundEnt->setMaterialName("GroundJ");
node->attachObject(groundEnt);
_sceneMgr->getRootSceneNode()->addChild(node);
// Creamos forma de colision para el plano -----------------------
OgreBulletCollisions::CollisionShape *Shape;
Shape = new OgreBulletCollisions::StaticPlaneCollisionShape
(Ogre::Vector3(0,1,0), 0); // Vector normal y distancia
OgreBulletDynamics::RigidBody *rigidBodyPlane = new
OgreBulletDynamics::RigidBody("rigidBodyPlane", _world);
// Creamos la forma estatica (forma, Restitucion, Friccion) ------
rigidBodyPlane->setStaticShape(Shape, 0.1, 0.8);
std::cout << "Hola" << std::endl;
ColocarWolfAndRedilAndPig();
CrearBosqueAndColina();
CreationWolf();
std::cout << "BOSQUE AND COLINA COLOCADAS" <<std::endl;
}