本文整理汇总了C++中KDTree::buildTreeStart方法的典型用法代码示例。如果您正苦于以下问题:C++ KDTree::buildTreeStart方法的具体用法?C++ KDTree::buildTreeStart怎么用?C++ KDTree::buildTreeStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDTree
的用法示例。
在下文中一共展示了KDTree::buildTreeStart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildTestScene1
void buildTestScene1()
{
float w,h,f;
w = 9.0f;
h = 6.0f;
f = 6.0f;
cam = PinholeCamera(Vec3(0.0f,0.0f,0.0f), Vec3(0.0f,0.0f,-5.0f), Vec3(0.0f,1.0f,0.0f),f,w,h);
buffer = RayBuffer();
PointLight *l;
l = new PointLight(Vec3(1.0f,0.0f,1.0f),Col(1.0f,1.0f,1.0f), 15, 1, 1, 1);
lights.addLight(*l);
l = new PointLight(Vec3(-3.0f,3.0f,-1.0f),Col(1.0f,1.0f,1.0f), 10, 1, 1, 1);
lights.addLight(*l);
l = new PointLight(Vec3(2.0f,0.0f,0.0f),Col(0.30f,0.30f,0.30f), 4, 1, 1, 1);
lights.addLight(*l);
std::vector<Collidable *> *vec = new std::vector<Collidable *>();
Collidable *c;
c = new Sphere(Vec3(0.0f, .5f, -4.20f), 1.0f, Material(1));
c->precomputeBounds();
vec->push_back(c);
c = new Sphere(Vec3(-0.0f, -1.0f, -3.0f), 0.5f, Material(2));
c->precomputeBounds();
vec->push_back(c);
c = new Sphere(Vec3(-0.0f, 0.00f, -0.50f), 0.1f, Material(3));
c->precomputeBounds();
vec->push_back(c);
c = new Sphere(Vec3(0.7f, 0.30f, -2.5f), 0.5f, Material(4));
c->precomputeBounds();
//vec->push_back(c);
c = new Sphere(Vec3(02.0f, 0.00f, -5.0f), 0.70f, Material(4));
c->precomputeBounds();
vec->push_back(c);
c = new Sphere(Vec3(0.9f, 0.00f, -02.50f), 0.50f, Material(7));
c->precomputeBounds();
vec->push_back(c);
sceneTree.buildTreeStart(*vec);
sceneTree.isLeaf = true;
sceneTree.items = vec;
sceneTree.xMin = -100;
sceneTree.xMax = 100;
sceneTree.yMin = -100;
sceneTree.yMax = 100;
sceneTree.zMin = -100;
sceneTree.zMax = 100;
sceneTree.axis = -1;
sceneTree.depth = 0;
sceneTree.id = 55;
}
示例2: testTree
void testTree()
{
std::vector<Collidable *> *vec = new std::vector<Collidable*>();
Point *p;
printf("\ntesting tree \n");
/*
p = new Point(-4, -1, -3);
p->precomputeBounds();
vec->push_back(p);
p = new Point(-4, -1, 4);
p->precomputeBounds();
vec->push_back(p);
p = new Point(3, 2, -4);
p->precomputeBounds();
vec->push_back(p);
p = new Point(3, 2, 3);
p->precomputeBounds();
vec->push_back(p);
*/
p = new Point(-5, -5, -5);
p->precomputeBounds();
vec->push_back(p);
p = new Point(5, -5, -5);
p->precomputeBounds();
vec->push_back(p);
p = new Point(-5, 5, 5);
p->precomputeBounds();
vec->push_back(p);
p = new Point(5, 5, 5);
p->precomputeBounds();
vec->push_back(p);
p = new Point(-1, -1, -1);
p->precomputeBounds();
vec->push_back(p);
p = new Point(1, -1, -1);
p->precomputeBounds();
vec->push_back(p);
p = new Point(-1, 1, 1);
p->precomputeBounds();
vec->push_back(p);
p = new Point(1, 1, 1);
p->precomputeBounds();
vec->push_back(p);
KDTree *tr = new KDTree();
tr->buildTreeStart(*vec);
//printf("printing \n");
tr->printTreeMod();
printf("tree tested \n");
bMap->clear();
cam.buildCentralRay(*bMap,buffer,lights);
RayLink *t;
t = buffer.start->next;
t->task->execute(*tr);
}
示例3: buildTestScene2
void buildTestScene2()
{
float w,h,f;
w = 9.0f;
h = 6.0f;
f = 3.0f;
float con = 2;
cam = PinholeCamera(Vec3(0.0f,0.0f,0.0f), Vec3(0.0f,0.0f,-5.0f), Vec3(0.0f,1.0f,0.0f),f,w,h);
buffer = RayBuffer();
PointLight *l;
l = new PointLight(Vec3(0.0f, con-0.10f, -con),Col(1.0f,1.0f,1.0f), 15, 1, 1, 1);
lights.addLight(*l);
std::vector<Collidable *> *vec = new std::vector<Collidable *>();
Collidable *c;
c = new Sphere(Vec3(0.0f, 0.0f, -2.0f), 0.50f, Material(3));
c->precomputeBounds();
vec->push_back(c);
c = new Sphere(Vec3(-1.0f, -1.0f, -3.0f), 1.0f, Material(1));
c->precomputeBounds();
vec->push_back(c);
//left
c = new Triangle( Vec3(-con,-con,0), Vec3(-con,-con,-2*con), Vec3(-con,con,0), Material(8));
c->precomputeBounds();
vec->push_back(c);
c = new Triangle( Vec3(-con,-con,-2*con), Vec3(-con,con,-2*con), Vec3(-con,con,0), Material(8));
c->precomputeBounds();
vec->push_back(c);
//right
c = new Triangle( Vec3(con,-con,0), Vec3(con,con,0), Vec3(con,-con,-2*con), Material(9));
c->precomputeBounds();
vec->push_back(c);
c = new Triangle( Vec3(con,-con,-2*con), Vec3(con,con,0), Vec3(con,con,-2*con), Material(9));
c->precomputeBounds();
vec->push_back(c);
//back
c = new Triangle( Vec3(-con,con,-2*con), Vec3(-con,-con,-2*con), Vec3(con,-con,-2*con), Material(10));
c->precomputeBounds();
vec->push_back(c);
c = new Triangle( Vec3(-con,con,-2*con), Vec3(con,-con,-2*con), Vec3(con,con,-2*con), Material(10));
c->precomputeBounds();
vec->push_back(c);
//bottom
c = new Triangle( Vec3(-con,-con,0), Vec3(con,-con,0), Vec3(con,-con,-2*con), Material(10));
c->precomputeBounds();
vec->push_back(c);
c = new Triangle( Vec3(-con,-con,-2*con), Vec3(-con,-con,0), Vec3(con,-con,-2*con), Material(10));
c->precomputeBounds();
vec->push_back(c);
//top
c = new Triangle( Vec3(-con,con,0), Vec3(con,con,-2*con), Vec3(con,con,0), Material(10));
c->precomputeBounds();
vec->push_back(c);
c = new Triangle( Vec3(-con,con,-2*con), Vec3(con,con,-2*con), Vec3(-con,con,0), Material(10));
c->precomputeBounds();
vec->push_back(c);
//front
c = new Triangle( Vec3(-con,con,con), Vec3(con,-con,con), Vec3(-con,-con,con), Material(2));
c->precomputeBounds();
vec->push_back(c);
c = new Triangle( Vec3(-con,con,con), Vec3(con,con,con), Vec3(con,-con,con), Material(2));
c->precomputeBounds();
vec->push_back(c);
sceneTree.buildTreeStart(*vec);
sceneTree.isLeaf = true;
sceneTree.items = vec;
sceneTree.xMin = -100;
sceneTree.xMax = 100;
sceneTree.yMin = -100;
sceneTree.yMax = 100;
sceneTree.zMin = -100;
sceneTree.zMax = 100;
sceneTree.axis = -1;
sceneTree.depth = 0;
sceneTree.id = 55;
}