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


C++ Octree::insert方法代码示例

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


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

示例1: test2

void test2()
{
    Vec3<double> myorigin = Vec3<double>(0.0, 0.0, 0.0);
    Vec3<double> myradii = Vec3<double>(10.0, 10.0, 10.0);

    Octree* mytree = new Octree(myorigin, myradii);

    assert(mytree->getOrigin().getX() == 0.0);
    assert(mytree->getRadii().getX() == 10.0);

    double i = 5.0;

    OctreePoint *mydata = new OctreePoint(Vec3<double>(43.0, 21.0, 24.0), i, 7);

    mytree->insert(mydata);

    std::vector<OctreePoint*> results;
    mytree->getPointsInBox(Vec3<double>(0.0, 0.0, 0.0), Vec3<double>(45.0, 25.0, 25.0), results);
    std::cout << results[0]->getIndex() << std::endl;
    delete mytree;
}
开发者ID:Nodmgatall,项目名称:ParalleleProgrammierungAbschlussProjekt,代码行数:21,代码来源:test.cpp

示例2: loadMap

bool loadMap(const char* filename, Octree &map) {

    FILE * file = fopen(filename, "r");

    if (NULL == file) {
        fprintf(stderr, "Couldn't open %s for reading the map\n", filename);
        return false;
    }

    int num_objs = 0;

    fscanf(file, "%d ", &num_objs); 

    GameDrawableObject *read_object;

    char name[100];
    int matnum;
    vec3 p, s, r;

    while (num_objs--) {
        fscanf(file, "%s %d\n", name, &matnum);

        read3f(p, file);
        //printf("read p:\n");
        //fprint3f(p, stdout);

        read3f(s, file);
        //printf("read s:\n");
        //fprint3f(s, stdout);

        read3f(r, file);
        //printf("read r:\n");
        //fprint3f(r, stdout);

        // TODO - put this info in a std::map
        if (strcmp(name, "building") == 0) {
           read_object = new GameBuilding();

        } else if (strcmp(name, "ramp") == 0) {
           read_object = new GameRamp();

        } else if (strcmp(name, "wings") == 0) {
           read_object = new GamePartWings("models/wings.obj");

        } else if (strcmp(name, "engine") == 0) {
           read_object = new GamePartEngine("models/engine.obj");

        } else if (strcmp(name, "battery") == 0) {
           read_object = new GamePartBattery();

        } else if (strcmp(name, "stat_speed") == 0) {
           read_object = new GameStatSpeed();

        } else if (strcmp(name, "stat_acceleration") == 0) {
           read_object = new GameStatAcceleration();

        } else if (strcmp(name, "stat_brake") == 0) {
           read_object = new GameStatBrake();

        } else if (strcmp(name, "stat_turn") == 0) {
           read_object = new GameStatTurn();

        } else if (strcmp(name, "speed_boost") == 0) {
           read_object = new GameActiveBoost();

        } else if (strcmp(name, "jetpack") == 0) {
           printf("***read jetpack\n");
           read_object = new GameActiveJetpack();

        } else if (strcmp(name, "turning") == 0) {
           read_object = new GameActiveTurning();

        } else if (strcmp(name, "tree") == 0) {
           read_object = new GameSceneryTree();
           read_object->setName("tree");

        } else {
            // unknown
            read_object = new GameBuilding();
        }

        // read_object->setName(name);
        read_object->setPosition(p);
        read_object->setScale(s);
        read_object->setRotation(r);
        read_object->setMaterialIndex(matnum);
        
        map.insert(read_object);
    }



    fclose(file);
    
    return true;

}
开发者ID:Milez213,项目名称:CityTrial,代码行数:97,代码来源:loadMap.cpp


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