Пример #1
0
void Scene::CreateTestScene()
{
    Material* lambert1 = new LambertMaterial(glm::vec3(1, 0, 0));
    Material* lambert2 = new LambertMaterial(glm::vec3(0, 1, 0));

    Cube* c = new Cube();
    c->material = lambert1;
    c->transform = Transform(glm::vec3(1,0,0), glm::vec3(40,20,45), glm::vec3(1,1,1));
    c->create();
    c->setBBox();
    this->objects.append(c);

    Sphere* s = new Sphere();
    s->material = lambert2;
    s->transform = Transform(glm::vec3(-1,0,0), glm::vec3(30,50,30), glm::vec3(1,2,1));
    s->create();
    s->setBBox();
    this->objects.append(s);

    unsigned int w = 400, h = 400;
    camera = Camera(w, h);
    camera.near_clip = 0.1f;
    camera.far_clip = 100.0f;
    camera.create();
    film = Film(w, h);
}
Пример #2
0
void Scene::Clear()
{
    for(Geometry *g : objects)
    {
        QString name = g->getGeometryName();
        if(QString::compare(name,QString("Mesh")) == 0)
            BVHNode::releaseTree(((Mesh*)g)->bvhTree);

        delete g;
    }
    objects.clear();
    lights.clear();
    for(Material *m : materials)
    {
        delete m;
    }
    materials.clear();
    camera = Camera();
    film = Film();
    delete pixel_sampler;

    // settting the sampler properties
    pixel_sampler = new UniformPixelSampler(1);
    //pixel_sampler = new StratifiedPixelSampler(4);
    //pixel_sampler = new RandomPixelSampler(4);

}
Пример #3
0
TEST(CameraTest, GenerateRay){
    Camera c = Camera(vec3(0, 0, 1), vec3(0, 0, 0), vec3(0, 1, 0), 90);
    Film film = Film(2, 2);
    Sample sample = Sample(0, 0);
    
    Ray *ray = new Ray(vec4(0,0,0,1), vec4(0,0,0,0), 0, 0, 100);
    
    c.generateRay(sample, ray, film);
    
    EXPECT_EQ(ray->pos.x, 0);
    EXPECT_EQ(ray->pos.y, 0);
    EXPECT_EQ(ray->pos.z, 1);
    
    // dir
    vec3 dir = glm::normalize(vec3(-1,1,-1));
    EXPECT_EQ(ray->dir.x, dir.x);
    EXPECT_EQ(ray->dir.y, dir.y);
    EXPECT_EQ(ray->dir.z, dir.z);
    
    // another point
    Sample sample2 = Sample(2,0);
    
    c.generateRay(sample2, ray, film);
    
    vec3 dir2 = glm::normalize(vec3(1,1,-1));
    EXPECT_EQ(ray->dir.x, dir2.x);
    EXPECT_EQ(ray->dir.y, dir2.y);
    EXPECT_EQ(ray->dir.z, dir2.z);
    
    
}
Пример #4
0
Film::Film()
{
	Film(800, 600);
}