本文整理汇总了C++中ogre::MaterialPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::get方法的具体用法?C++ MaterialPtr::get怎么用?C++ MaterialPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMaterial
Ogre::MaterialPtr DivBoxLevel::makeMaterial(
Ogre::String name, Ogre::String textureName, float intensity) {
Ogre::MaterialManager::getSingleton().unload(name);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(
name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material.get()->getTechnique(0)-> getPass(0)->createTextureUnitState(
textureName);
material.get()->getTechnique(0)-> getPass(0)->setAmbient(
intensity, intensity, intensity);
return material;
}
示例2: DebugCreateAmbientColorMaterial
void DebugCreateAmbientColorMaterial(const std::string &materialName, float r, float g, float b)
{
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mm.getByName(materialName);
if (material.get()) // The given material already exists, so no need to create it again.
return;
material = mm.getByName("SolidAmbient");
if (!material.get())
return;
Ogre::MaterialPtr newMaterial = material->clone(materialName);
newMaterial->setAmbient(r, g, b);
}
示例3: GetOrCreateLegacyMaterial
Ogre::MaterialPtr GetOrCreateLegacyMaterial(const std::string& texture_name, uint variation)
{
if (variation >= MAX_MATERIAL_VARIATIONS)
{
OgreRenderingModule::LogWarning("Requested suffix for non-existing material variation " + ToString<uint>(variation));
variation = 0;
}
const std::string& suffix = MaterialSuffix[variation];
Ogre::TextureManager &tm = Ogre::TextureManager::getSingleton();
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
std::string material_name = texture_name + suffix;
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
{
material = mm.create(material_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(material.get());
}
else
return material;
Ogre::TexturePtr tex = tm.getByName(texture_name);
bool has_alpha = false;
if (!tex.isNull())
{
// As far as the legacy materials are concerned, DXT1 is not alpha
if (tex->getFormat() == Ogre::PF_DXT1)
has_alpha = false;
else if (Ogre::PixelUtil::hasAlpha(tex->getFormat()))
has_alpha = true;
}
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(BaseMaterials[variation]);
else
base_material = mm.getByName(AlphaBaseMaterials[variation]);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[variation] + " base material for " + texture_name);
return Ogre::MaterialPtr();
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
return material;
}
示例4: CreateGroundMaterialTextured
//-------------------------------------------------------
Ogre::Material* Ground::CreateGroundMaterialTextured(const std::string & name, const Ogre::Image* texture)
{
Ogre::TexturePtr heightMapTexture = Ogre::TextureManager::getSingleton().loadImage("Texture/Terrain",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, *texture);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
{
Ogre::Technique* techniqueGL = material->getTechnique(0);
Ogre::Pass* pass = techniqueGL->getPass(0);
{
auto vprogram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("Shader/" + CLASS_NAME + "/GL/Textured/V",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GPT_VERTEX_PROGRAM);
vprogram->setSource(Shader_GL_Simple_V);
//auto vparams = vprogram->createParameters();
//vparams->setNamedAutoConstant("modelviewproj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
pass->setVertexProgram(vprogram->getName());
}
{
auto fprogram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram("Shader/" + CLASS_NAME + "/GL/Textured/F",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "glsl", Ogre::GPT_FRAGMENT_PROGRAM);
fprogram->setSource(Shader_GL_Simple_F);
auto unit0 = pass->createTextureUnitState(heightMapTexture->getName());
unit0->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
unit0->setTextureFiltering(Ogre::TFO_NONE);
pass->setFragmentProgram(fprogram->getName());
}
}
#if !NDEBUG
material->load();
#endif
return material.get();
}
示例5: 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);
}
}
示例6: 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));
}
}
}
}
}
}
示例7: log
Ogre::Pass *getPass(const string &matName, size_t t, const string &passName, bool clone)
{
if (!Ogre::MaterialManager::getSingleton().resourceExists(matName))
{
log("could not find \"" + matName + "\" material");
return NULL;
}
Ogre::MaterialPtr mat = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().load(
matName, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
assert(mat.get());
static idGen id;
if (clone)
mat = mat->clone(id(matName));
try
{
Ogre::Pass *ret = mat->getTechnique(t)->getPass(passName);
return ret;
}
catch (...)
{
log("Could not find pass \"" + passName + "\" in material \"" + matName + "\"");
}
return NULL;
}
示例8: GetOrCreateLitTexturedMaterial
Ogre::MaterialPtr GetOrCreateLitTexturedMaterial(const std::string& materialName)
{
const char baseMaterialName[] = "LitTextured";
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mm.getByName(materialName);
if (!material.get())
{
Ogre::MaterialPtr baseMaterial = mm.getByName(baseMaterialName);
material = baseMaterial->clone(materialName);
}
assert(material.get());
return material;
}
示例9: 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!");
}
示例10: CreateLegacyMaterials
void CreateLegacyMaterials(const std::string& texture_name, bool update)
{
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;
}
// Early out: if texture does not yet exist and materials have already been created once
if (((tex.isNull()) || (!update)) && (!mm.getByName(texture_name).isNull()))
return;
for (uint i = 0; i < MAX_MATERIAL_VARIATIONS; ++i)
{
const std::string& base_material_name = BaseMaterials[i];
const std::string& alpha_base_material_name = AlphaBaseMaterials[i];
std::string material_name = texture_name + MaterialSuffix[i];
Ogre::MaterialPtr material = mm.getByName(material_name);
if (!material.get())
{
material = mm.create(material_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(material.get());
}
Ogre::MaterialPtr base_material;
if (!has_alpha)
base_material = mm.getByName(base_material_name);
else
base_material = mm.getByName(alpha_base_material_name);
if (!base_material.get())
{
OgreRenderingModule::LogError("Could not find " + MaterialSuffix[i] + " base material for " + texture_name);
return;
}
base_material->copyDetailsTo(material);
SetTextureUnitOnMaterial(material, texture_name, 0);
}
}
示例11: IComponent
/// \todo Use Asset API for fetching sky resources.
EC_SkyBox::EC_SkyBox(IModule *module) :
IComponent(module->GetFramework()),
materialRef(this, "Material", AssetReference("RexSkyBox")), ///< \todo Add "orge://" when AssetAPI can handle it.
textureRefs(this, "Texture"),
orientation(this, "Orientation", Quaternion(f32(M_PI/2.0), Vector3df(1.0,0.0,0.0))),
distance(this, "Distance",50.0),
drawFirst(this, "Draw first", true)
{
connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)), SLOT(OnAttributeUpdated(IAttribute*)));
static AttributeMetadata materialRefMetadata;
AttributeMetadata::ButtonInfoList materialRefButtons;
materialRefButtons.push_back(AttributeMetadata::ButtonInfo(materialRef.GetName(), "V", "View"));
materialRefMetadata.buttons = materialRefButtons;
materialRef.SetMetadata(&materialRefMetadata);
// Find out default textures.
renderer_ = module->GetFramework()->GetServiceManager()->GetService<OgreRenderer::Renderer>();
StringVector names;
Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(materialRef.Get().ref.toStdString().c_str());
if ( materialPtr.get() != 0)
{
OgreRenderer::GetTextureNamesFromMaterial(materialPtr, names);
AssetReferenceList lst;
if (names.size() == cSkyBoxTextureCount)
{
// This code block is not currently working, but if for some reason GetTextureNamesFromMaterialn understands cubic_textures this codeblock is runned
for(int i = 0; i < cSkyBoxTextureCount; ++i)
lst.Append(AssetReference(names[i].c_str()));
}
else
{
// Add default values, hardcoded
/// HACK use hardcoded-values because ogre textureunit state class cannot find out texture names for cubic_texture type.
lst.Append(AssetReference(names[0].c_str()));
lst.Append(AssetReference("rex_sky_back.dds"));
lst.Append(AssetReference("rex_sky_left.dds"));
lst.Append(AssetReference("rex_sky_right.dds"));
lst.Append(AssetReference("rex_sky_top.dds"));
lst.Append(AssetReference("rex_sky_bot.dds"));
}
textureRefs.Set(lst, AttributeChange::LocalOnly);
}
// Disable old sky.
// DisableSky();
CreateSky();
lastMaterial_ = materialRef.Get().ref;
lastOrientation_ = orientation.Get();
lastDistance_ = distance.Get();
lastDrawFirst_ = drawFirst.Get();
lastTextures_ = textureRefs.Get();
}
示例12: CloneMaterial
Ogre::MaterialPtr CloneMaterial(const std::string& sourceMaterialName, const std::string &newName)
{
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mm.getByName(sourceMaterialName);
material = material->clone(newName);
assert(material.get());
return material;
}
示例13: SetOverlayAlpha
void EC_HoveringText::SetOverlayAlpha(float alpha)
{
Ogre::MaterialManager &mgr = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mgr.getByName(materialName_);
if (!material.get() || material->getNumTechniques() < 1 || material->getTechnique(0)->getNumPasses() < 1 || material->getTechnique(0)->getPass(0)->getNumTextureUnitStates() < 1)
return;
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setAlphaOperation(
Ogre::LBX_BLEND_MANUAL, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1.0, 0.0, alpha);
}
示例14: SetAlphaChannelIntensity
void EC_OgreMovableTextOverlay::SetAlphaChannelIntensity(const float &distance)
{
float materialAlpha, textAlpha;
textAlpha = (MAX_VISIBILITY_DISTANCE - distance) / MAX_VISIBILITY_DISTANCE;
materialAlpha = (MAX_VISIBILITY_DISTANCE - distance) / MAX_VISIBILITY_DISTANCE;
if (materialAlpha > materialMaxAlpha_)
materialAlpha = materialMaxAlpha_;
Ogre::MaterialManager &mm = Ogre::MaterialManager::getSingleton();
Ogre::MaterialPtr material = mm.getByName(materialName_);
if (material.get())
material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setAlphaOperation(
Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, materialAlpha, materialAlpha, 0);
text_element_->setColour(Ogre::ColourValue(fontColor_.r, fontColor_.g, fontColor_.b, textAlpha));
}
示例15: Initialize
void ParticleEffect::Initialize(Ogre::SceneManager *sceneManager, Ogre::SceneNode* parentNode, Ogre::String object_name, Ogre::String material_name, PhysicsEngine &physicsEngine, unsigned int parentID)
{
PhysicsEntity::Initialize(sceneManager, parentNode, physicsEngine, parentID);
bodyType = ENTITY_BODY_METAPHYSICAL;
Ogre::Entity* entity = sceneManager->createEntity(object_name);
/* Apply a material to the entity */
materialName = material_name + std::to_string(objectID);
Ogre::MaterialPtr origMat = Ogre::MaterialManager::getSingleton().getByName(material_name);
Ogre::Material* mat = origMat.get();
mat->clone(materialName);
entity->setMaterialName(materialName);
sceneNode->attachObject(entity);
sceneNode->translate(0,0,0);
}