本文整理汇总了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;
}
示例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;
}