当前位置: 首页>>代码示例>>C++>>正文


C++ MeshPtr::setLodStrategy方法代码示例

本文整理汇总了C++中ogre::MeshPtr::setLodStrategy方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::setLodStrategy方法的具体用法?C++ MeshPtr::setLodStrategy怎么用?C++ MeshPtr::setLodStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::MeshPtr的用法示例。


在下文中一共展示了MeshPtr::setLodStrategy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadAutomaticLod

void LodManager::loadAutomaticLod(Ogre::MeshPtr mesh)
{
    LodConfig lodConfigs;
    lodConfigs.mesh = mesh;
    mesh->setLodStrategy(&Ogre::PixelCountLodStrategy::getSingleton());
    LodLevel lodLevel;
    lodLevel.reductionMethod = LodLevel::VRM_COLLAPSE_COST;
    Ogre::Real radius = mesh->getBoundingSphereRadius();
    for (int i = 2; i < 6; i++) {
        Ogre::Real i4 = (Ogre::Real) (i * i * i * i);
        Ogre::Real i5 = i4 * (Ogre::Real) i;
        // Distance = pixel count
        // Constant: zoom of the Lod. This could be scaled based on resolution.
        //     Higher constant means first Lod is nearer to camera. Smaller constant means the first Lod is further away from camera.
        // i4: The stretching. Normally you want to have more Lods in the near, then in far away.
        //     i4 means distance is divided by 16=(2*2*2*2), 81, 256, 625=(5*5*5*5).
        //     if 16 would be smaller, the first Lod would be nearer. if 625 would be bigger, the last Lod would be further awaay.
        // if you increase 16 and decrease 625, first and Last Lod distance would be smaller.
        lodLevel.distance = 3388608.f / i4;

        // reductionValue = collapse cost
        // Radius: Edges are multiplied by the length, when calculating collapse cost. So as a base value we use radius, which should help in balancing collapse cost to any mesh size.
        // The constant and i5 are playing together. 1/(1/100k*i5)
        // You need to determine the quality of nearest Lod and the furthest away first.
        // I have choosen 1/(1/100k*(2^5)) = 3125 for nearest Lod and 1/(1/100k*(5^5)) = 32 for nearest Lod.
        // if you divide radius by a bigger number, it means smaller reduction. So radius/3125 is very small reduction for nearest Lod.
        // if you divide radius by a smaller number, it means bigger reduction. So radius/32 means agressive reduction for furthest away lod.
        // current values: 3125, 411, 97, 32
        lodLevel.reductionValue = radius / 100000.f * i5;
        lodConfigs.levels.push_back(lodLevel);
    }

    QueuedProgressiveMeshGenerator pm;
    pm.build(lodConfigs);
}
开发者ID:Arsakes,项目名称:ember,代码行数:35,代码来源:LodManager.cpp

示例2: loadLod

void LodManager::loadLod(Ogre::MeshPtr mesh, const LodDefinition& def)
{
    if (def.getUseAutomaticLod()) {
        loadAutomaticLod(mesh);
    } else if (def.getLodDistanceCount() == 0) {
        mesh->removeLodLevels();
        return;
    } else {
        Ogre::LodStrategy* strategy;
        if (def.getStrategy() == LodDefinition::LS_DISTANCE) {
            strategy = &Ogre::DistanceLodStrategy::getSingleton();
        } else {
            strategy = &Ogre::PixelCountLodStrategy::getSingleton();
        }
        mesh->setLodStrategy(strategy);

        if (def.getType() == LodDefinition::LT_AUTOMATIC_VERTEX_REDUCTION) {
            // Automatic vertex reduction
            LodConfig lodConfig;
            lodConfig.mesh = mesh;
            const LodDefinition::LodDistanceMap& data = def.getManualLodData();
            if (def.getStrategy() == LodDefinition::LS_DISTANCE) {
                // TODO: Use C++11 lambda, instead of template.
                loadAutomaticLodImpl(data.begin(), data.end(), lodConfig);
            } else {
                loadAutomaticLodImpl(data.rbegin(), data.rend(), lodConfig);
            }
            // Uncomment the ProgressiveMesh of your choice.
            // NOTE: OgreProgressiveMeshExt doesn't support collapse cost based reduction.
            // OgreProgressiveMeshExt pm;
            // ProgressiveMeshGenerator pm;
            QueuedProgressiveMeshGenerator pm;
            pm.build(lodConfig);
        } else {
            // User created Lod

            mesh->removeLodLevels();

            const LodDefinition::LodDistanceMap& data = def.getManualLodData();
            if (def.getStrategy() == LodDefinition::LS_DISTANCE) {
                // TODO: Use C++11 lambda, instead of template.
                loadUserLodImpl(data.begin(), data.end(), mesh.get());
            } else {
                loadUserLodImpl(data.rbegin(), data.rend(), mesh.get());
            }
        }
    }
}
开发者ID:Arsakes,项目名称:ember,代码行数:48,代码来源:LodManager.cpp


注:本文中的ogre::MeshPtr::setLodStrategy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。