本文整理汇总了C++中ogre::Technique::setSceneBlending方法的典型用法代码示例。如果您正苦于以下问题:C++ Technique::setSceneBlending方法的具体用法?C++ Technique::setSceneBlending怎么用?C++ Technique::setSceneBlending使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Technique
的用法示例。
在下文中一共展示了Technique::setSceneBlending方法的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
//.........这里部分代码省略.........
{
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;
// Old way was to ignore the color and alpha when using embedded
// materials, which meant you could leave them unset, which means
// 0. Since we now USE the color and alpha values, leaving them
// all 0 will mean the object will be invisible. Therefore detect
// the situation where RGBA are all 0 and treat that the same as
// all 1 (full white).
if( new_message->mesh_use_embedded_materials && r == 0 && g == 0 && b == 0 && a == 0 )
{
r = 1; g = 1; b = 1; a = 1;
}
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;
}
S_MaterialPtr::iterator it;
for( it = materials_.begin(); it != materials_.end(); it++ )
{
Ogre::Technique* technique = (*it)->getTechnique( 0 );
technique->setAmbient( r*0.5, g*0.5, b*0.5 );
technique->setDiffuse( r, g, b, a );
technique->setSceneBlending( blending );
technique->setDepthWriteEnabled( depth_write );
}
}
Ogre::Vector3 pos, scale;
Ogre::Quaternion orient;
transform(new_message, pos, orient, scale);
scene_node_->setVisible(true);
setPosition(pos);
setOrientation(orient);
// In Ogre, mesh surface normals are not normalized if object is not
// scaled. This forces the surface normals to be renormalized by
// invisibly tweaking the scale.
if( scale.x == 1.0 && scale.y == 1.0 && scale.z == 1.0 )
{
scale.z = 1.0001;
}
scene_node_->setScale(scale);
}
示例3: onNewMessage
//.........这里部分代码省略.........
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);
}
// always update color on resource change
update_color = true;
handler_.reset(new MarkerSelectionHandler(this, MarkerID(new_message->ns, new_message->id), context_));
handler_->addTrackedObject(entity_);
}
else
{
// underlying mesh resource has not changed but if the color has
// then we need to update the materials color
if (!old_message
|| 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)
{
update_color = true;
}
}
// update material color
// if the mesh_use_embedded_materials is true and color is non-zero
// then the color will be used to tint the embedded materials
if (update_color)
{
if( new_message->mesh_use_embedded_materials && r == 0 && g == 0 && b == 0 && a == 0 )
{
blending = Ogre::SBT_REPLACE;
depth_write = true;
r = 1; g = 1; b = 1; a = 1;
}
S_MaterialPtr::iterator material_it;
for (material_it = materials_.begin(); material_it != materials_.end(); material_it++)
{
Ogre::Technique* technique = (*material_it)->getTechnique(0);
technique->setAmbient( r*0.5, g*0.5, b*0.5 );
technique->setDiffuse( r, g, b, a );
technique->setSceneBlending( blending );
technique->setDepthWriteEnabled( depth_write );
technique->setLightingEnabled( true );
}
}
Ogre::Vector3 pos, scale;
Ogre::Quaternion orient;
transform(new_message, pos, orient, scale);
scene_node_->setVisible(true);
setPosition(pos);
setOrientation(orient);
scene_node_->setScale(scale);
}