Beispiel #1
0
WorldState::WorldState()
{
    // make sure that the world can hold at least 5 of each object
    // before it needs to reallocate memory
    shaders.reserve(5);
    lights.reserve(5);
    materials.reserve(5);
    textures.reserve(3);

    // start with one light and material by default
    lights.push_back(LightInfo());
    materials.push_back(MaterialInfo());
}
Beispiel #2
0
void World::loadScene(string filename) {
    // for as4, you can optionally hard-code the scene.  For as5 and as6 it must be loaded from a file.

    if (_FINAL_PROJ) {
        vec4 eye(0.0, 0.0, 0, 1.0);
        vec4 LL(-1.0, -1.0, -3.0, 1.0);
        vec4 UL(-1.0, 1.0, -3.0, 1.0);
        vec4 LR(1.0, -1.0, -3.0, 1.0);
        vec4 UR(1.0, 1.0, -3.0, 1.0);

        _view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT, 1);

        _lights[LIGHT_DIRECTIONAL].push_back(
            Light(0, vec3(0.5,0.5,-0.5),
                  LightInfo(LIGHT_DIRECTIONAL, vec3(.4, .8, 1.2))));
        _lights[LIGHT_POINT].push_back(
            Light(vec3(0.0,0.0,-14.0), vec3(0.5,0.5,-0.5),
                  LightInfo(LIGHT_POINT, vec3(1.39, 0.2, 0.2))));

        _ambientLight = vec3(.5,.2,.2);
        /*
        _spheres.push_back(Sphere(vec4(-2.5,-1.5,-17.0,1.0), 2.0,
        					MaterialInfo(vec3(.4, .5, .9),
        					.1, .5, .5, 150, 1.0)));
        _spheres.push_back(Sphere(vec4(0.0,4.0,-25.0,1.0), 2.5,
        					MaterialInfo(vec3(.9, .4, .5),
        					.4, .2, .5, 20, 0.0)));
        _spheres.push_back(Sphere(vec4(1.5,-1.5,-10.0,1.0), 1.0,
        					MaterialInfo(vec3(.5, .9, .4),
        					.5, .5, .3, 4, .5)));
        */

        _cubes.push_back(Cube(vec4(-3.5,-3.5,-15.0,1.0), 1.5, MaterialInfo(vec3(.4, .5, .9),
                              .1, .5, .5, 150, 1.0)));

        _cubes.push_back(Cube(vec4(2.0, 1.5, -10,1.0), 1.5, MaterialInfo(vec3(.9, .4, .5),
                              .4, .2, .5, 20, 0.0)));

        _cubes.push_back(Cube(vec4(-3.5,4,-120.0,1.0), 3, MaterialInfo(vec3(.5, .9, .4),
                              .5, .5, .3, 4, .5)));

        _cubes.push_back(Cube(vec4(3.5,-4,-250.0,1.0), 3.5, MaterialInfo(vec3(.5, .9, .4),
                              .5, .5, .3, 4, .5)));

        ksmMod = kspMod = 1.0;
    }

    else if (_ASSIGNMENT >= 5) {
        scene = new Scene(filename);

        loadInstance(scene->getRoot());

        if (_ASSIGNMENT >= 6)
            _bb = new BoundingBox(_spheres, 0);
    }

    if (_ASSIGNMENT <= 4) {
        //vec4 eye(0.0, 0.0, 0, 1.0);
        //vec4 LL(-1.0, -1.0, -3.0, 1.0);
        //vec4 UL(-1.0, 1.0, -3.0, 1.0);
        //vec4 LR(1.0, -1.0, -3.0, 1.0);
        //vec4 UR(1.0, 1.0, -3.0, 1.0);

        //_view = Viewport(eye, LL, UL, LR, UR, IMAGE_WIDTH, IMAGE_HEIGHT);

        //_lights[LIGHT_DIRECTIONAL].push_back(
        //						Light(0, vec3(0.5,0.5,-0.5),
        //						LightInfo(LIGHT_DIRECTIONAL, vec3(.4, .8, 1.2))));
        //_lights[LIGHT_POINT].push_back(
        //						Light(vec3(0.0,0.0,-14.0), vec3(0.5,0.5,-0.5),
        //						LightInfo(LIGHT_POINT, vec3(1.39, 0.2, 0.2))));

        //_ambientLight = vec3(.5,.2,.2);

        //_spheres.push_back(Sphere(vec4(-2.5,-1.5,-17.0,1.0), 2.0,
        //					MaterialInfo(vec3(.4, .5, .9),
        //					.1, .5, .5, 150, 1.0)));
        //_spheres.push_back(Sphere(vec4(0.0,4.0,-25.0,1.0), 2.5,
        //					MaterialInfo(vec3(.9, .4, .5),
        //					.4, .2, .5, 20, 0.0)));
        //_spheres.push_back(Sphere(vec4(1.5,-1.5,-10.0,1.0), 1.0,
        //					MaterialInfo(vec3(.5, .9, .4),
        //					.5, .5, .3, 4, .5)));

        //ksmMod = kspMod = 1.0;
    }
}
ProxyLightObject::ProxyLightObject(ProxyManager *man, const SpaceObjectReference&id)
  : LightProvider(LightInfo()),
    ProxyObject(man, id) {
}