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


C++ VRTransformPtr::setWorldPosition方法代码示例

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


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

示例1:

void VRNature::computeLODs2(map<OctreeNode*, VRLodLeafPtr>& leafs) {

    // get all trees and grass patches for each leaf layer
    map<VRLodLeaf*, vector<VRTree*> > trees;
    map<VRLodLeaf*, vector<VRGrassPatch*> > grass;
    for (auto l : leafs) {
        auto& leaf = l.second;
        int lvl = leaf->getLevel();
        if (lvl == 0) continue;

        vector<void*> data = leaf->getOLeaf()->getAllData();
        for (auto v : data) {
            if (((VRObject*)v)->hasTag("tree")) trees[leaf.get()].push_back((VRTree*)v);
            if (((VRObject*)v)->hasTag("grass")) grass[leaf.get()].push_back((VRGrassPatch*)v);
        }
    }

    // create layer node geometries
    for (auto l : leafs) {
        auto& leaf = l.second;
        leaf->reset();
        int lvl = leaf->getLevel();
        if (lvl == 0) continue;
        bool doTrees = (trees.count(leaf.get()) >= 0);
        bool doGrass = (grass.count(leaf.get()) >= 0);

        Boundingbox bb;
        if (doTrees) for (auto t : trees[leaf.get()]) bb.update( t->getWorldPosition() );
        //if (doGrass) for (auto g : grass[leaf.get()]) bb.update( g->getWorldPosition() );
        Vec3d pos = bb.center();

        VRGeoData geo;
        VRMaterialPtr m;

        if (doTrees) for (auto t : trees[leaf.get()]) {
            if (treeRefs.count(t) == 0) continue;
            auto tRef = treeRefs[t];
            if (!tRef || !t) continue;
            Vec3d offset = t->getWorldPosition() - pos;
            VRTransformPtr tlod = tRef->getLOD(0);
            /*tRef->appendLOD(geo, lvl, offset);
            m = tlod->getMaterial();*/
            VRTransformPtr l = dynamic_pointer_cast<VRTransform>( tlod->duplicate() );
            leaf->add( l, 1 );
            l->setWorldPosition(t->getWorldPosition());
        }

        /*if (doGrass) for (auto g : grass[leaf.get()]) {
            if (grassPatchRefs.count(g) == 0) continue;
            auto gRef = grassPatchRefs[g];
            if (!gRef || !g) continue;
            Vec3d offset = g->getWorldPosition() - pos;
            gRef->createLod(geoGrass, lvl, offset, g->getID());
        }*/

        /*VRGeometryPtr woods;
        if (geo.size() > 0) {
            woods = geo.asGeometry("woods");
            if (m) woods->setMaterial(m);
            //cout << "YAY: lod data: " << geo.size() << " " << woods << endl;

            leaf->set( woods, 1 );
            woods->setWorldPosition(pos);
            woods->setDir(Vec3d(0,0,-1));
            woods->setUp(Vec3d(0,1,0));
        }*/
    }
}
开发者ID:Victor-Haefner,项目名称:polyvr,代码行数:68,代码来源:VRNature.cpp


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