當前位置: 首頁>>代碼示例>>C++>>正文


C++ Technique::traverse方法代碼示例

本文整理匯總了C++中Technique::traverse方法的典型用法代碼示例。如果您正苦於以下問題:C++ Technique::traverse方法的具體用法?C++ Technique::traverse怎麽用?C++ Technique::traverse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Technique的用法示例。


在下文中一共展示了Technique::traverse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: traverse

void Effect::traverse(osg::NodeVisitor& nv)
{
    // if this effect is not enabled, then go for default traversal
    if (!_enabled) {
        inherited_traverse(nv);
        return;
    }

    // ensure that at least one technique is defined
    if (!_techs_defined) {

        // clear existing techniques
        _techs.clear();

        // clear technique selection indices
        _sel_tech.clear();

        // clear technique selection flags
        _tech_selected.clear();

        // define new techniques
        _techs_defined = define_techniques();

        // check for errors, return on failure
        if (!_techs_defined) {
            OSG_WARN << "Warning: osgFX::Effect: could not define techniques for effect " << className() << std::endl;
            return;
        }

        // ensure that at least one technique has been defined
        if (_techs.empty()) {
            OSG_WARN << "Warning: osgFX::Effect: no techniques defined for effect " << className() << std::endl;
            return;
        }
    }

    Technique *tech = 0;

    // if the selection mode is set to AUTO_DETECT then we have to
    // choose the active technique!
    if (_global_sel_tech == AUTO_DETECT) {

        // test whether at least one technique has been selected
        bool none_selected = true;
        for (unsigned i=0; i<_tech_selected.size(); ++i) {
            if (_tech_selected[i] != 0) {
                none_selected = false;
                break;
            }
        }

        // no techniques selected, traverse a dummy node that
        // contains the Validator (it will select a technique)
        if (none_selected) {
            _dummy_for_validation->accept(nv);
        }

        // find the highest priority technique that could be validated
        // in all active rendering contexts
        int max_index = -1;
        for (unsigned j=0; j<_sel_tech.size(); ++j) {
            if (_tech_selected[j] != 0) {
                if (_sel_tech[j] > max_index) {
                    max_index = _sel_tech[j];
                }
            }
        }

        // found a valid technique?
        if (max_index >= 0) {
            tech = _techs[max_index].get();
        }

    } else {

        // the active technique was selected manually
        tech = _techs[_global_sel_tech].get();
    }

    // if we could find an active technique, then continue with traversal,
    // else go for default traversal (no effect)
    if (tech) {
        tech->traverse(nv, this);
    } else {
        if (nv.getTraversalMode() == osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {
            inherited_traverse(nv);
        }
    }

    // wow, we're finished! :)
}
開發者ID:151706061,項目名稱:OpenSceneGraph,代碼行數:91,代碼來源:Effect.cpp


注:本文中的Technique::traverse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。