本文整理汇总了C++中ogre::MaterialPtr::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::getName方法的具体用法?C++ MaterialPtr::getName怎么用?C++ MaterialPtr::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: _createIndicatorInstance
void SoundEditAction::_createIndicatorInstance(void)
{
Ogre::SceneManager* sceneManager = mSceneManipulator->getSceneManager();
mSoundMovingEntity = sceneManager->createEntity("SoundMovingEntity", "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("SoundRadiusEntity", radius, rings, segments);
Ogre::MaterialPtr material = WX::createPureColourMaterial(
Ogre::ColourValue(1, 0, 0, 0.75) );
material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);
mSoundRadiusEntity = sceneManager->createEntity("SoundRadiusEntity", sphereMesh->getName());
mSoundNode->createChildSceneNode()->attachObject(mSoundRadiusEntity);
mSoundRadiusEntity->setMaterialName(material->getName());
mSoundRadiusEntity->getParentSceneNode()->setVisible(false);
mFirstInit = true;
}
示例4: getSceneManipulator
void
JunctionPoints::refresh(void)
{
JunctionSelection* selection = static_cast<JunctionSelection*>(
getSceneManipulator()->_getSelection("JunctionSelection"));
const JunctionSelection::JunctionMap& junctions = selection->getJunctions();
DisplayNodes newDisplayNodes;
// Use existing point if possible
for (JunctionSelection::JunctionMap::const_iterator it = junctions.begin(); it != junctions.end(); ++it)
{
const JunctionSelection::Junction& junction = it->second;
Ogre::Vector3 pos = getTerrainData()->_getPosition(junction.x, junction.z);
DisplayNodes::iterator found = mDisplayNodes.find(Ogre::Vector4(pos.x, pos.y, pos.z, junction.weight));
Ogre::SceneNode* node = NULL;
if (found != mDisplayNodes.end())
{
node = found->second;
mDisplayNodes.erase(found);
}
newDisplayNodes.insert(DisplayNodes::value_type(Ogre::Vector4(pos.x, pos.y, pos.z, junction.weight), node));
}
// Build new point and adjust position
for (DisplayNodes::iterator it = newDisplayNodes.begin(); it != newDisplayNodes.end(); ++it)
{
if (!it->second)
{
if (!mDisplayNodes.empty())
{
DisplayNodes::iterator found = mDisplayNodes.begin();
it->second = found->second;
mDisplayNodes.erase(found);
}
else
{
it->second = allocNode();
}
it->second->setPosition(it->first.x,it->first.y,it->first.z);
// 根据节点的权重来设置节点所挂物体的材质颜色
Ogre::MaterialPtr material = createPureColourMaterial(Ogre::ColourValue(it->first.w,(1.0f-it->first.w),0.0f));
// 设置节点的材质
static_cast<Ogre::Entity *>(it->second->getAttachedObject(0))->setMaterialName(material->getName());
}
}
// Hide extra points
for (DisplayNodes::const_iterator it = mDisplayNodes.begin(); it != mDisplayNodes.end(); ++it)
{
freeNode(it->second);
}
std::swap(newDisplayNodes, mDisplayNodes);
}
示例5: reset
void MeshResourceMarker::reset()
{
//destroy entity
if (entity_)
{
context_->getSceneManager()->destroyEntity( entity_ );
entity_ = 0;
}
// destroy all the materials we've created
S_MaterialPtr::iterator it;
for ( it = materials_.begin(); it!=materials_.end(); it++ )
{
Ogre::MaterialPtr material = *it;
if (!material.isNull())
{
for (size_t i = 0; i < material->getNumTechniques(); ++i)
{
Ogre::Technique* t = material->getTechnique(i);
// hack hack hack, really need to do a shader-based way of picking, rather than
// creating a texture for each object
if (t->getSchemeName() == "Pick")
{
Ogre::TextureManager::getSingleton().remove(t->getPass(0)->getTextureUnitState(0)->getTextureName());
}
}
material->unload();
Ogre::MaterialManager::getSingleton().remove(material->getName());
}
}
materials_.clear();
}
示例6: updateShadowTexture
Ogre::TexturePtr Simple::updateShadowTexture(Ogre::MaterialPtr material, const TerrainPageShadow* terrainPageShadow)
{
//we need an unique name for our alpha texture
std::stringstream shadowTextureNameSS;
shadowTextureNameSS << material->getName() << "_shadow";
const Ogre::String shadowTextureName(shadowTextureNameSS.str());
Ogre::TexturePtr texture = static_cast<Ogre::TexturePtr> (Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(shadowTextureName));
if (texture.isNull()) {
texture = Ogre::Root::getSingletonPtr()->getTextureManager()->createManual(shadowTextureName, "General", Ogre::TEX_TYPE_2D, mPage.getAlphaTextureSize(), mPage.getAlphaTextureSize(), 1, Ogre::PF_L8, Ogre::TU_DYNAMIC_WRITE_ONLY);
}
Ogre::Image ogreImage;
terrainPageShadow->loadIntoImage(ogreImage);
texture->loadImage(ogreImage);
//blit the whole image to the hardware buffer
Ogre::PixelBox sourceBox(ogreImage.getPixelBox());
//blit for each mipmap
for (unsigned int i = 0; i <= texture->getNumMipmaps(); ++i) {
Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(texture->getBuffer(0, i));
hardwareBuffer->blitFromMemory(sourceBox);
}
return texture;
}
示例7: compileMaterial
bool Simple::compileMaterial(Ogre::MaterialPtr material)
{
material->removeAllTechniques();
Ogre::Technique* technique = material->createTechnique();
for (SurfaceLayerStore::const_iterator I = mTerrainPageSurfaces.begin(); I != mTerrainPageSurfaces.end(); ++I) {
const TerrainPageSurfaceLayer* surfaceLayer = I->second;
if (I == mTerrainPageSurfaces.begin()) {
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
//add the first layer of the terrain, no alpha or anything
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureScale(1.0f / surfaceLayer->getScale(), 1.0f / surfaceLayer->getScale());
textureUnitState->setTextureName(surfaceLayer->getDiffuseTextureName());
textureUnitState->setTextureCoordSet(0);
} else {
if (surfaceLayer->intersects(*mGeometry)) {
addPassToTechnique(*mGeometry, technique, surfaceLayer);
}
}
}
if (mTerrainPageShadow) {
addShadow(technique, mTerrainPageShadow, material);
}
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;
}
示例8: reset
void MeshResourceMarker::reset()
{
//destroy entity
if (entity_)
{
context_->getSceneManager()->destroyEntity(entity_);
entity_ = 0;
}
// destroy all the materials we've created
S_MaterialPtr::iterator it;
for (it = materials_.begin(); it != materials_.end(); it++)
{
Ogre::MaterialPtr material = *it;
if (!material.isNull())
{
material->unload();
Ogre::MaterialManager::getSingleton().remove(material->getName());
}
}
materials_.clear();
// the actual passes are deleted by the material
color_tint_passes_.clear();
}
示例9: HitIndicator
IntersectPoint::IntersectPoint(SceneManipulator* sceneManipulator)
: HitIndicator(sceneManipulator)
, mIntersectNode(NULL)
, mIntersectEntity(NULL)
{
// Create intersection node and entity
mIntersectNode = getIndicatorRootSceneNode()->createChildSceneNode();
Real radius = 1;
int rings = 16;
int segments = 16;
Ogre::MeshPtr sphereMesh = createCommonSphere(radius, rings, segments);
Ogre::MaterialPtr material = createColourMaterial(
Ogre::ColourValue(1, 0, 0, 0.75),
Ogre::ColourValue(0, 1, 0),
1);
mIntersectEntity = getSceneManager()->createEntity(mIntersectNode->getName(), sphereMesh->getName());
mIntersectEntity->setQueryFlags(0);
mIntersectEntity->setNormaliseNormals(true);
mIntersectEntity->setMaterialName(material->getName());
mIntersectEntity->setRenderQueueGroup(Ogre::RENDER_QUEUE_7);
mIntersectNode->attachObject(mIntersectEntity);
mIntersectNode->setVisible(false);
reshape();
}
示例10: 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;
}
示例11: CreateResourceFromMaterial
Foundation::ResourcePtr CreateResourceFromMaterial(Ogre::MaterialPtr material)
{
assert(!material.isNull());
OgreMaterialResource* res = new OgreMaterialResource(material->getName());
res->SetMaterial(material);
Foundation::ResourcePtr res_ptr(res);
return res_ptr;
}
示例12: SetMaterial
// 设置碰撞小球原来的材质.
void IntersectPoint::SetMaterial()
{
Ogre::MaterialPtr material = createColourMaterial(
Ogre::ColourValue(1, 0, 0, 0.75),
Ogre::ColourValue(0, 1, 0),
1);
mIntersectEntity->setMaterialName(material->getName());
}
示例13: checkMaterial
bool ShaderManager::checkMaterial(const std::string& materialName, const std::string& schemeName)
{
// OGRE scheme is switched in caller
Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().load(materialName, "General"));
if (material->getNumSupportedTechniques() == 0) {
S_LOG_INFO("The material '" << material->getName() << "' has no supported techniques with scheme " << schemeName << ". The reason for this is: \n" << material->getUnsupportedTechniquesExplanation());
return false;
}
S_LOG_INFO("The material '" << material->getName() << "' has " << material->getNumSupportedTechniques() << " supported techniques out of " << material->getNumTechniques());
// Check that we use desired scheme, but not fallbacked to default
if (material->getBestTechnique()->getSchemeName() != schemeName) {
S_LOG_INFO("The material '" << material->getName() << "' has best supported scheme " << material->getBestTechnique()->getSchemeName() << ". Was looking for " << schemeName);
return false;
}
S_LOG_INFO("The material '" << material->getName() << "' supported with scheme " << schemeName);
return true;
}
示例14: fromOgreMaterialName
//----------------------------------------------------------------------------------------
QImage ImageConverter::fromOgreMaterialName(const Ogre::String& name, const Ogre::String& resourceGroup)
{
mResourceGroup = resourceGroup;
#if (OGRE_VERSION < ((1 << 16) | (9 << 8) | 0))
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->load(name, mResourceGroup);
#else
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->load(name, mResourceGroup).staticCast<Ogre::Material>();
#endif
return _getRenderTarget(material->getName());
}
示例15: 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);
}