本文整理汇总了C++中ogre::MaterialPtr::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::clone方法的具体用法?C++ MaterialPtr::clone怎么用?C++ MaterialPtr::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::clone方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTemplateMaterial
const Ogre::MaterialPtr& MaterialGenerator::GetMaterial(Perm permutation)
{
// Check if material/shader permutation already was generated
MaterialMap::iterator i = mMaterials.find(permutation);
if (i != mMaterials.end())
{
return i->second;
}
else
{
// Create it
Ogre::MaterialPtr templ = GetTemplateMaterial(permutation & mMatMask);
Ogre::GpuProgramPtr vs = GetVertexShader(permutation & mVsMask);
Ogre::GpuProgramPtr fs = GetFragmentShader(permutation & mFsMask);
// Create material name
string name = mMaterialBaseName + Ogre::StringConverter::toString(permutation);
// Create material from template, and set shaders
Ogre::MaterialPtr mat = templ->clone(name);
Ogre::Technique* tech = mat->getTechnique(0);
Ogre::Pass* pass = tech->getPass(0);
pass->setFragmentProgram(fs->getName());
pass->setVertexProgram(vs->getName());
// And store it
mMaterials[permutation] = mat;
return mMaterials[permutation];
}
}
示例2: GetMaterialCopy
Ogre::MaterialPtr Renderer::GetMaterialCopy(const String& originalName, const String& newName)
{
Ogre::MaterialPtr material = GetMaterial(originalName);
if (material.isNull())
return material;
return material->clone(newName);
}
示例3: 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;
}
示例4: init
void DynamicLines::init(Ogre::String const &resourceGroup,
Ogre::RenderOperation::OperationType opType /*= Ogre::RenderOperation::OT_LINE_STRIP*/,
bool use2d /*= false*/)
{
mPoints.clear();
mColors.clear();
//dynamic renderable
initialize(opType, false);
{
Ogre::MaterialPtr const whiteNoLignthing = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting");
Ogre::String const resName = "DynamicLines_" + Ogre::StringConverter::toString(mId) + "_BaseWhiteNoLighting_" + resourceGroup;
mMaterial = Ogre::MaterialManager::getSingleton().getByName(resName);
if(mMaterial.isNull())
{
mMaterial = whiteNoLignthing->clone(resName, true, resourceGroup);
mMaterial->load();
}
mMaterial->setDepthCheckEnabled(!use2d);
}
setMaterial(mMaterial->getName());
setUse2D(use2d);
mDirty = false;
}
示例5: CreateParticleEntity
Ogre::SceneNode* ParticleFactory::CreateParticleEntity(Ogre::String object_name, Ogre::String material_name,Ogre::SceneNode* parent, Ogre::Vector3 size){
/* Create one instance of the torus (one entity) */
/* The same object can have multiple instances or entities */
/* Create entity */
Ogre::String name = parent->getName() + object_name;
//Ogre::Entity* entity = scene_manager->createEntity(object_name);
Ogre::Entity* entity = scene_manager->createEntity(object_name);
Ogre::MaterialPtr mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(material_name));
//mat = mat->clone(object_name.append("_" +material_name.append("_" + Ogre::StringConverter::toString(materialCounter))));
mat = mat->clone(name.append("_" +material_name.append("_" + Ogre::StringConverter::toString(materialCounter))));
//std::cout << "NAME: " << name << std::endl;
//mat = mat->clone(object_name.append(material_name));
/* Apply a material to the entity */
entity->setMaterialName(mat->getName());
//materialArray[numMaterials] = mat->getName();
materialArray.push_back(mat->getName());
/* Create a scene node for the entity */
/* The scene node keeps track of the entity's position */
Ogre::SceneNode* scene_node = parent->createChildSceneNode(mat->getName());
scene_node->attachObject(entity);
//scene_node->translate(0.5,0.5,-1);
incrementCounter();
/* Scale the entity */
scene_node->scale(size);
return scene_node;
}
示例6: 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!");
}
示例7: createPureColourMaterial
AxisRenderable::AxisRenderable(int lineCount,Ogre::Camera* camera,Ogre::Viewport* viewport)
{
// Disable cast shadows by default
mCastShadows = false;
mPrevAxisGizmoSelAxis = -1;
mCamera = camera;
mViewport = viewport;
m_max_line_count = m_line_count = lineCount;
m_line_count = 0;
mLength = 200;
mProjectDistance = mCamera->getFarClipDistance();
m_local = false;
m_locked_data = 0;
//m_locked_buffer = 0;
mRenderOp.vertexData = new Ogre::VertexData();
m_radius = 0;
mRenderOp.indexData = 0;
mRenderOp.vertexData->vertexCount = m_line_count*2;
mRenderOp.vertexData->vertexStart = 0;
mRenderOp.operationType = Ogre::RenderOperation::OT_LINE_LIST;
mRenderOp.useIndexes = false;
Ogre::VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
Ogre::VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
decl->addElement(0, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
decl->addElement(0, 3*sizeof(Ogre::Real), Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
Ogre::HardwareVertexBufferSharedPtr vbuf =
Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
decl->getVertexSize(0),
2*m_max_line_count,
Ogre::HardwareBuffer::HBU_WRITE_ONLY);
bind->setBinding(0, vbuf);
// Obtain the pure colour material
Ogre::MaterialPtr pureColourMaterial = createPureColourMaterial(Ogre::ColourValue(1,1,0));
Ogre::String realName = pureColourMaterial->getName() + "_NoDepthBuffer";
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(realName);
if (material.isNull())
{
// Clone to avoid confuse somewhere else that using the same material
material = pureColourMaterial->clone(realName);
material->setDepthCheckEnabled(false);
material->setDepthWriteEnabled(false);
}
setMaterial(material->getName());
mBox.setExtents(-10,-10,-10,10,10,10);
setQueryFlags(0);
}
示例8:
void Worms::setColor(Ogre::ColourValue &color)
{
Ogre::MaterialPtr new_mat;
Ogre::MaterialPtr mat = _ent->getSubEntity(2)->getMaterial();
new_mat = mat->clone(_name);
//new_mat->getTechnique(0)->getPass("Skin")->setSpecular(color);
new_mat->getTechnique(0)->getPass("Skin")->setDiffuse(color);
this->_ent->getSubEntity(2)->setMaterialName(_name);
}
示例9: 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;
}
示例10: getOrCreateMaterialClone
Ogre::MaterialPtr EmberTerrainProfile::getOrCreateMaterialClone(Ogre::MaterialPtr templateMaterial, const std::string& suffix)
{
std::string name = templateMaterial->getName() + suffix;
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(name);
if (!mat.isNull()) {
return mat;
}
return templateMaterial->clone(name);
}
示例11:
//---------------------------------------------------------------------
std::list<Ogre::MaterialPtr> MapBlock::cloneMaterials(void) {
std::list<Ogre::MaterialPtr> clones;
for(unsigned int i=0; i < mEntity->getNumSubEntities(); i++) {
Ogre::MaterialPtr realMaterial = mEntity->getSubEntity(i)->getMaterial();
std::stringstream nameStream;
nameStream << realMaterial->getName() << " " << mStaticPosition[0] << ":" << mStaticPosition[1];
Ogre::MaterialPtr newMaterial = realMaterial->clone(nameStream.str());
newMaterial->load();
mEntity->getSubEntity(i)->setMaterial(newMaterial);
clones.push_back(newMaterial);
}
return clones;
}
示例12:
static void
SubEntity_tintColour(
SubEntity* self,
const String& groupName,
const String& materialName,
const Ogre::ColourValue& colour
) {
Ogre::MaterialPtr baseMaterial = Ogre::MaterialManager::getSingleton().getByName(materialName);
Ogre::MaterialPtr materialPtr = baseMaterial->clone(groupName);
materialPtr->compile();
Ogre::TextureUnitState* ptus = materialPtr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
ptus->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_TEXTURE, colour);
self->setMaterial(materialPtr);
}
示例13: buildDepthShadowMaterial
//-------------------------------------------------------------------------------
Ogre::MaterialPtr CSceneManagerEditor::buildDepthShadowMaterial(Ogre::MaterialPtr cpyMat)
{
if(mShadowsTechnique->get() >= (int)Ogre::SHADOWTYPE_TEXTURE_ADDITIVE && mShadowsTechnique->get() <= (int)Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED)
{
Ogre::String matName = "DepthShadows/" + cpyMat->getName();
Ogre::MaterialPtr ret = Ogre::MaterialManager::getSingleton().getByName(matName);
if (ret.isNull())
{
ret = cpyMat->clone(matName);
Ogre::Technique *t = ret->getTechnique(0);
t->setShadowCasterMaterial("Ogre/shadow/depth/caster");
Ogre::Pass *p = t->getPass(0);
p->setVertexProgram("Ogre/shadow/receiver/depth/pssm3/vp");
p->setFragmentProgram("Ogre/shadow/receiver/depth/pssm3/fp");
Ogre::TextureUnitState *tu = p->createTextureUnitState();
tu->setName("shadow0");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
tu = p->createTextureUnitState();
tu->setName("shadow1");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
tu = p->createTextureUnitState();
tu->setName("shadow2");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
Ogre::Vector4 splitPoints;
const Ogre::PSSMShadowCameraSetup::SplitPointList& splitPointList =
static_cast<Ogre::PSSMShadowCameraSetup*>(mPSSMSetup.get())->getSplitPoints();
for (int i = 0; i < 3; ++i)
{
splitPoints[i] = splitPointList[i];
}
p->getFragmentProgramParameters()->setNamedConstant("pssmSplitPoints", splitPoints);
}
return ret;
}
else
return cpyMat;
}
示例14: 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);
}
示例15: 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;
}