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;

}
Esempio n. 2
0
RayTracer::RayTracer(uint width, uint height, Vect viewDir, Vect orthoUp) {
    WIDTH = width;
    HEIGHT = height;
    depth = 1;
    scaleConst = 100;
    buffer = RayBuffer(WIDTH, HEIGHT);
    scene = NULL;

    camera.setPos(Vect(0, 0, 0));
    camera.setVerticalFOV((float)M_PI / 2.0f);
    camera.setViewDir(viewDir);
    camera.setOrthoUp(orthoUp);

    calculateImagePlane();
}
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;

}