本文整理汇总了C++中ogre::MaterialPtr::setDepthBias方法的典型用法代码示例。如果您正苦于以下问题:C++ MaterialPtr::setDepthBias方法的具体用法?C++ MaterialPtr::setDepthBias怎么用?C++ MaterialPtr::setDepthBias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MaterialPtr
的用法示例。
在下文中一共展示了MaterialPtr::setDepthBias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
void OgreBtDebugDrawer::initialize(Ogre::SceneManager* const sceneManager,
const bool drawTrajectory) {
mDrawTrajectory = drawTrajectory;
mContactPoints = &mContactPoints1;
mLines = new Ogre::ManualObject("BulletPhysicsLines1");
mLines2 = new Ogre::ManualObject("BulletPhysicsLines2");
mTriangles = new Ogre::ManualObject("BulletPhysicsTriangles1");
mTriangles2 = new Ogre::ManualObject("BulletPhysicsTriangles2");
mLines->setDynamic(true);
mLines2->setDynamic(true);
mTriangles->setDynamic(true);
mTriangles2->setDynamic(true);
//mLines->estimateVertexCount( 100000 );
//mLines->estimateIndexCount( 0 );
sceneManager->getRootSceneNode()->attachObject(mLines);
sceneManager->getRootSceneNode()->attachObject(mLines2);
sceneManager->getRootSceneNode()->attachObject(mTriangles);
sceneManager->getRootSceneNode()->attachObject(mTriangles2);
static const char* matName = "OgreBulletCollisionsDebugDefault";
Ogre::MaterialPtr mtl =
Ogre::MaterialManager::getSingleton().getDefaultSettings()->clone(
matName);
mtl->setReceiveShadows(false);
mtl->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
mtl->setDepthBias(0.1, 0);
Ogre::TextureUnitState * tu =
mtl->getTechnique(0)->getPass(0)->createTextureUnitState();
tu->setColourOperationEx(Ogre::LBX_SOURCE1, Ogre::LBS_DIFFUSE);
mtl->getTechnique(0)->setLightingEnabled(false);
//mtl->getTechnique(0)->setSelfIllumination( ColourValue::White );
//for the ogre text
Ogre::Root::getSingleton().addFrameListener(this);
//TODO: Add 3D text writing capability to ogreBtdebugdrawer #133.
// olm = Ogre::OverlayManager::getSingletonPtr();
// panel = static_cast<Ogre::OverlayContainer*>(olm->createOverlayElement(
// "Panel", "OGREBTDEBUGDRAWER_GUI"));
// panel->setMetricsMode(Ogre::GMM_PIXELS);
// panel->setPosition(0, 0);
// panel->setDimensions(1.0f, 1.0f);
// overlay = olm->create("OGREBTDEBUGDRAWER_OVERLAY");
// overlay->add2D(panel);
//
// szElement = "element_";
// overlay = olm->getByName("OGREBTDEBUGDRAWER_OVERLAY");
// panel = static_cast<Ogre::OverlayContainer*>(olm->getOverlayElement(
// "OGREBTDEBUGDRAWER_GUI"));
// textArea =
// static_cast<Ogre::TextAreaOverlayElement*>(olm->createOverlayElement(
// "TextArea", szElement));
// panel->addChild(textArea);
// overlay->show();
}
示例2: setupMaterial
void
setupMaterial() {
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getDefaultSettings()->clone(
MATERIAL_NAME
);
material->setReceiveShadows(false);
material->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
material->setDepthBias(0.1, 0);
Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
textureUnitState->setColourOperationEx(
Ogre::LBX_SOURCE1,
Ogre::LBS_DIFFUSE
);
material->getTechnique(0)->setLightingEnabled(false);
}
示例3: assembleScene
void AerialMapDisplay::assembleScene() {
if (!dirty_) {
return; // nothing to update
}
dirty_ = false;
if (!loader_) {
return; // no tiles loaded, don't do anything
}
// get rid of old geometry, we will re-build this
clearGeometry();
// iterate over all tiles and create an object for each of them
const double resolution = loader_->resolution();
const std::vector<TileLoader::MapTile> &tiles = loader_->tiles();
for (const TileLoader::MapTile &tile : tiles) {
const int w = tile.image().width();
const int h = tile.image().height();
// we here assume that the tiles are uniformly sized...
const double tileW = w * resolution;
const double tileH = h * resolution;
const double origin_x = -loader_->originX() * tileW;
const double origin_y = -(1 - loader_->originY()) * tileH;
// determine location of this tile
const double x = (tile.x() - loader_->tileX()) * tileW + origin_x;
const double y = -(tile.y() - loader_->tileY()) * tileH + origin_y;
// don't re-use any ids
const std::string name_suffix =
std::to_string(tile.x()) + "_" + std::to_string(tile.y()) + "_" +
std::to_string(map_id_) + "_" + std::to_string(scene_id_);
Ogre::TexturePtr tex;
if (tile.hasImage()) {
// one material per texture
std::string matName = "material_" + name_suffix;
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(
matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->setReceiveShadows(false);
material->getTechnique(0)->setLightingEnabled(false);
material->setDepthBias(-16.0f,
0.0f); /// @todo: what the fuck does this do?
material->setCullingMode(Ogre::CULL_NONE);
material->setDepthWriteEnabled(false);
// create textureing unit
Ogre::Pass *pass = material->getTechnique(0)->getPass(0);
Ogre::TextureUnitState *tex_unit = NULL;
if (pass->getNumTextureUnitStates() > 0) {
tex_unit = pass->getTextureUnitState(0);
} else {
tex_unit = pass->createTextureUnitState();
}
// only add if we have a texture for it
tex = textureFromImage(tile.image(), "texture_" + name_suffix);
ROS_INFO("Rendering with texture: %s", tex->getName().c_str());
tex_unit->setTextureName(tex->getName());
tex_unit->setTextureFiltering(Ogre::TFO_BILINEAR);
// create an object
const std::string obj_name = "object_" + name_suffix;
Ogre::ManualObject *obj = scene_manager_->createManualObject(obj_name);
scene_node_->attachObject(obj);
// configure depth & alpha properties
if (alpha_ >= 0.9998) {
material->setDepthWriteEnabled(!draw_under_);
material->setSceneBlending(Ogre::SBT_REPLACE);
} else {
material->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
material->setDepthWriteEnabled(false);
}
if (draw_under_) {
obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_4);
} else {
obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_MAIN);
}
tex_unit->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL,
Ogre::LBS_CURRENT, alpha_);
// create a quad for this tile
obj->begin(material->getName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
// bottom left
obj->position(x, y, 0.0f);
obj->textureCoord(0.0f, 0.0f);
obj->normal(0.0f, 0.0f, 1.0f);
// top right
obj->position(x + tileW, y + tileH, 0.0f);
obj->textureCoord(1.0f, 1.0f);
obj->normal(0.0f, 0.0f, 1.0f);
// top left
obj->position(x, y + tileH, 0.0f);
//.........这里部分代码省略.........