Пример #1
0
void	load_new_scene(t_map *map, char *file_name)
{
	printf("le fichier charger : %s\n", file_name);
	free_scene(&map->scene);
	parse(map, file_name);
	map->obj_selected = NULL;//&map->scene.shape[0];
	//raytracer(map);
	scene_update(map);
	draw(map);
}
Пример #2
0
int main(void) {
    // Important: do NOT modify the main function
    struct Scene scene;
    
    scene_init(&scene);
    
    int keep_going = 1;
    while (keep_going == 1) {
        scene_render(&scene);
        cons_update();
        scene_delay(&scene);
        keep_going = scene_update(&scene);
    }
    
    return 0;
}
Пример #3
0
void Scene::update(){
	get_signal();
	scene_update();
}
Пример #4
0
void scene_render(scene_t *scene,float ifps) {
    int i,j,light;
    static int frame;
    glDisable(GL_FOG);
    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);
    scene_update(scene,ifps);   // update scene
    scene_animation(scene); // create mesh and check view animated object
    scene_particle(scene);  // check view and move particle system
    scene_dynamiclight(scene);  // check view and move dynamiclight
    if(frame == FRAME_PER_SHADOW) {
        shadow_enable_shadowmap();  // create shadow maps
        for(i = 0; i < scene->num_animation; i++)
            if(scene->animation[i]->view && scene->animation[i]->shadow > 0)
                shadow_shadowmap(scene->sun->pos,scene->animation[i]->thing,scene->animation[i]->shadow);
        shadow_disable_shadowmap(sys_width(),sys_height());
        frame = 0;
    }
    frame++;
    glColor4f(1.0,1.0,1.0,1.0);
    glEnable(GL_TEXTURE_2D);
    camera_view(scene->camera); // set camera
    sky_render(scene->sky,scene->camera,ifps);  // render sky
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);        // sun light
    glLightfv(GL_LIGHT0,GL_POSITION,scene->sun->pos);
    glLightfv(GL_LIGHT0,GL_DIFFUSE,scene->sun->color);
    glEnable(GL_FOG);
    for(i = 0, j = 1, light = 0; i < scene->num_dynamiclight; i++)
        if(scene->dynamiclight[i]->opengl) {    // add dynamic lights
            switch(j) {
                case 1: light = GL_LIGHT1; break;
                case 2: light = GL_LIGHT2; break;
                case 3: light = GL_LIGHT3; break;
                case 4: light = GL_LIGHT4; break;
                case 5: light = GL_LIGHT5; break;
                case 6: light = GL_LIGHT6; break;
                case 7: light = GL_LIGHT7; break;
            }
            glEnable(light);
            glLightfv(light,GL_POSITION,scene->dynamiclight[i]->light->center);
            glLightfv(light,GL_DIFFUSE,scene->dynamiclight[i]->light->color);
            j++;
            if(j == 8) break;
        }
    glFogfv(GL_FOG_COLOR,scene->camera->fogcolor);
    glFogf(GL_FOG_START,scene->camera->fogstart);
    glFogf(GL_FOG_END,scene->camera->fogend);
    land_render(scene->land,scene->camera); // render landscape
    for(i = 0; i < scene->num_thing; i++)   // render thing
        if(camera_check_sphere(scene->camera,scene->thing[i]->center,scene->thing[i]->radius) &&
           camera_check_box(scene->camera,scene->thing[i]->min,scene->thing[i]->max))
            thing_render(scene->thing[i]);
    for(i = 0; i < scene->num_animation; i++)   // render animated object
        if(scene->animation[i]->view)
            thing_render(scene->animation[i]->thing);
    glDisable(GL_LIGHTING);
    shadow_enable_project();
    for(i = 0; i < scene->num_animation; i++)   // dynamic shadow on land
        if(scene->animation[i]->view && scene->animation[i]->shadow > 0) {
            shadow_project(scene->sun->pos,scene->animation[i]->thing);
            land_dynamicshadow(scene->land,scene->sun->pos,scene->animation[i]->thing);
        }
    shadow_disable_project();
    for(i = 0; i < scene->num_particle; i++)    // particle
        if(scene->particle[i]->view)
            particle_render(scene->particle[i]->particle,scene->camera,ifps);
    for(i = 0; i < scene->num_dynamiclight; i++)// dynamiclight
        if(scene->dynamiclight[i]->view)
            dynamiclight_render(scene->dynamiclight[i]->light,scene->camera,scene->land);
    glDisable(GL_FOG);
    sky_sun_render(scene->sun,scene->camera);   // render sun and flare
    glDisable(GL_TEXTURE_2D);
}