本文整理汇总了C++中ogre::Technique::setAmbient方法的典型用法代码示例。如果您正苦于以下问题:C++ Technique::setAmbient方法的具体用法?C++ Technique::setAmbient怎么用?C++ Technique::setAmbient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Technique
的用法示例。
在下文中一共展示了Technique::setAmbient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setColor
void MeshPersonVisual::setColor(const Ogre::ColourValue& c) {
Ogre::SceneBlendType blending;
bool depth_write;
if ( c.a < 0.9998 )
{
blending = Ogre::SBT_TRANSPARENT_ALPHA;
depth_write = false;
}
else
{
blending = Ogre::SBT_REPLACE;
depth_write = true;
}
std::set<Ogre::MaterialPtr>::iterator it;
for( it = materials_.begin(); it != materials_.end(); it++ )
{
Ogre::Technique* technique = (*it)->getTechnique( 0 );
technique->setAmbient( c.r*0.5, c.g*0.5, c.b*0.5 );
technique->setDiffuse( c.r, c.g, c.b, c.a );
technique->setSceneBlending( blending );
technique->setDepthWriteEnabled( depth_write );
technique->setLightingEnabled( true );
}
}
示例2: onNewMessage
void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const MarkerConstPtr& new_message)
{
ROS_ASSERT(new_message->type == visualization_msgs::Marker::MESH_RESOURCE);
bool need_color = false;
scene_node_->setVisible(false);
if( !entity_ ||
old_message->mesh_resource != new_message->mesh_resource ||
old_message->mesh_use_embedded_materials != new_message->mesh_use_embedded_materials )
{
reset();
if (new_message->mesh_resource.empty())
{
return;
}
if (loadMeshFromResource(new_message->mesh_resource).isNull())
{
std::stringstream ss;
ss << "Mesh resource marker [" << getStringID() << "] could not load [" << new_message->mesh_resource << "]";
if ( owner_ )
{
owner_->setMarkerStatus(getID(), StatusProperty::Error, ss.str());
}
ROS_DEBUG("%s", ss.str().c_str());
return;
}
static uint32_t count = 0;
std::stringstream ss;
ss << "mesh_resource_marker_" << count++;
std::string id = ss.str();
entity_ = context_->getSceneManager()->createEntity(id, new_message->mesh_resource);
scene_node_->attachObject(entity_);
need_color = true;
// create a default material for any sub-entities which don't have their own.
ss << "Material";
Ogre::MaterialPtr default_material = Ogre::MaterialManager::getSingleton().create( ss.str(), ROS_PACKAGE_NAME );
default_material->setReceiveShadows(false);
default_material->getTechnique(0)->setLightingEnabled(true);
default_material->getTechnique(0)->setAmbient( 0.5, 0.5, 0.5 );
materials_.insert( default_material );
if ( new_message->mesh_use_embedded_materials )
{
// make clones of all embedded materials so selection works correctly
S_MaterialPtr materials = getMaterials();
S_MaterialPtr::iterator it;
for ( it = materials.begin(); it!=materials.end(); it++ )
{
if( (*it)->getName() != "BaseWhiteNoLighting" )
{
Ogre::MaterialPtr new_material = (*it)->clone( id + (*it)->getName() );
materials_.insert( new_material );
}
}
// make sub-entities use cloned materials
for (uint32_t i = 0; i < entity_->getNumSubEntities(); ++i)
{
std::string mat_name = entity_->getSubEntity(i)->getMaterialName();
if( mat_name != "BaseWhiteNoLighting" )
{
entity_->getSubEntity(i)->setMaterialName( id + mat_name );
}
else
{
// BaseWhiteNoLighting is the default material Ogre uses
// when it sees a mesh with no material. Here we replace
// that with our default_material which gets colored with
// new_message->color.
entity_->getSubEntity(i)->setMaterial( default_material );
}
}
}
else
{
entity_->setMaterial( default_material );
}
context_->getSelectionManager()->removeObject(coll_);
coll_ = context_->getSelectionManager()->createCollisionForEntity(entity_, SelectionHandlerPtr(new MarkerSelectionHandler(this, MarkerID(new_message->ns, new_message->id))), coll_);
}
if( need_color ||
old_message->color.r != new_message->color.r ||
old_message->color.g != new_message->color.g ||
old_message->color.b != new_message->color.b ||
old_message->color.a != new_message->color.a )
{
float r = new_message->color.r;
float g = new_message->color.g;
float b = new_message->color.b;
float a = new_message->color.a;
//.........这里部分代码省略.........
示例3: onNewMessage
void MeshResourceMarker::onNewMessage(const MarkerConstPtr& old_message, const MarkerConstPtr& new_message)
{
ROS_ASSERT(new_message->type == visualization_msgs::Marker::MESH_RESOURCE);
// flag indicating if the mesh material color needs to be updated
bool update_color = false;
scene_node_->setVisible(false);
// Get the color information from the message
float r = new_message->color.r;
float g = new_message->color.g;
float b = new_message->color.b;
float a = new_message->color.a;
Ogre::SceneBlendType blending;
bool depth_write;
if (a < 0.9998)
{
blending = Ogre::SBT_TRANSPARENT_ALPHA;
depth_write = false;
}
else
{
blending = Ogre::SBT_REPLACE;
depth_write = true;
}
if (!entity_ ||
old_message->mesh_resource != new_message->mesh_resource ||
old_message->mesh_use_embedded_materials != new_message->mesh_use_embedded_materials)
{
reset();
if (new_message->mesh_resource.empty())
{
return;
}
if (loadMeshFromResource(new_message->mesh_resource).isNull())
{
std::stringstream ss;
ss << "Mesh resource marker [" << getStringID() << "] could not load [" << new_message->mesh_resource << "]";
if (owner_)
{
owner_->setMarkerStatus(getID(), StatusProperty::Error, ss.str());
}
ROS_DEBUG("%s", ss.str().c_str());
return;
}
static uint32_t count = 0;
std::stringstream ss;
ss << "mesh_resource_marker_" << count++;
std::string id = ss.str();
entity_ = context_->getSceneManager()->createEntity(id, new_message->mesh_resource);
scene_node_->attachObject(entity_);
// create a default material for any sub-entities which don't have their own.
ss << "Material";
Ogre::MaterialPtr default_material = Ogre::MaterialManager::getSingleton().create(ss.str(), ROS_PACKAGE_NAME);
default_material->setReceiveShadows(false);
default_material->getTechnique(0)->setLightingEnabled(true);
default_material->getTechnique(0)->setAmbient(0.5, 0.5, 0.5);
materials_.insert(default_material);
if (new_message->mesh_use_embedded_materials)
{
// make clones of all embedded materials so selection works correctly
S_MaterialPtr materials = getMaterials();
S_MaterialPtr::iterator it;
for (it = materials.begin(); it != materials.end(); it++)
{
if ((*it)->getName() != "BaseWhiteNoLighting")
{
Ogre::MaterialPtr new_material = (*it)->clone(id + (*it)->getName());
materials_.insert(new_material);
}
}
// make sub-entities use cloned materials
for (uint32_t i = 0; i < entity_->getNumSubEntities(); ++i)
{
std::string mat_name = entity_->getSubEntity(i)->getMaterialName();
if (mat_name != "BaseWhiteNoLighting")
{
entity_->getSubEntity(i)->setMaterialName(id + mat_name);
}
else
{
// BaseWhiteNoLighting is the default material Ogre uses
// when it sees a mesh with no material. Here we replace
// that with our default_material which gets colored with
// new_message->color.
entity_->getSubEntity(i)->setMaterial(default_material);
}
//.........这里部分代码省略.........