示例#1
0
void
main_keyboard(unsigned char key, int x, int y)
{
    switch (key) {
    case 'r':
        light_pos[0].value = -2.0;
        light_pos[1].value = 2.0;
        light_pos[2].value = 2.0;
        light_pos[3].value = 1.0;
        light_Ka[0].value = 0;
        light_Ka[1].value = 0;
        light_Ka[2].value = 0;
        light_Ka[3].value = 1;
        light_Kd[0].value = 1;
        light_Kd[1].value = 1;
        light_Kd[2].value = 1;
        light_Kd[3].value = 1;
        light_Ks[0].value = 1;
        light_Ks[1].value = 1;
        light_Ks[2].value = 1;
        light_Ks[3].value = 1;
        spot_direction[0].value = 1.0;
        spot_direction[1].value = -1.0;
        spot_direction[2].value = -1.0;
        spot_exponent.value = 30.0;
        spot_cutoff.value = 91.0;
        Kc.value = 1.0;
        Kl.value = 0.0;
        Kq.value = 0.0;
        new_material(Pewter);
        lmodel_Ka[0].value = 0.2;
        lmodel_Ka[1].value = 0.2;
        lmodel_Ka[2].value = 0.2;
        lmodel_Ka[3].value = 1.0;
        local_viewer.value = 0;
        two_side.value = 0;
        break;
    case 'm':
        glutSetWindow(command);
        glutMouseFunc(material_mouse);
        glutDisplayFunc(material_display);
        break;
    case 's':
        glutSetWindow(command);
        glutMouseFunc(spotlight_mouse);
        glutDisplayFunc(spotlight_display);
        break;
    case 'l':
        glutSetWindow(command);
        glutMouseFunc(lmodel_mouse);
        glutDisplayFunc(lmodel_display);
        break;
    case 27:
        exit(0);
    }

    redisplay_all();
}
示例#2
0
MaterialID ResourceManagerImpl::new_material_from_file(const unicode& path, bool garbage_collect) {
    //Load the material
    L_INFO(_u("Loading material {0}").format(path));

    auto mat = material(new_material(garbage_collect));
    window->loader_for(path.encode())->into(mat);
    mark_material_as_uncollected(mat->id());
    return mat->id();
}
示例#3
0
MaterialID ResourceManagerImpl::new_material_with_alias(const unicode& alias, bool garbage_collect) {
    MaterialID m = new_material(garbage_collect);

    try {
        MaterialManager::manager_store_alias(alias, m);
    } catch(...) {
        delete_material(m);
        throw;
    }
    return m;
}
示例#4
0
void		new_cone(t_value val, t_object *data)
{
	ft_memcpy(data, &(t_cone){
		CONE,
		new_material(val),
		json_get(val.data.obj, "reflection_index").data.number,
		json_get(val.data.obj, "refraction_index").data.number,
		json_get(val.data.obj, "ambient").data.number,
		json_get(val.data.obj, "diffuse").data.number,
		json_get(val.data.obj, "specular").data.number,
		json_get(val.data.obj, "light").data.boolean,
		new_position(val),
		new_direction(val),
		json_get(val.data.obj, "radius").data.number,
		0
	}, sizeof(t_cone));
}
示例#5
0
void
world_menu(int value)
{
    switch (value) {
    case 1:
        new_material(Brass);
        break;
    case 2:
        new_material(Bronze);
        break;
    case 3:
        new_material(Polished_Bronze);
        break;
    case 4:
        new_material(Chrome);
        break;
    case 5:
        new_material(Copper);
        break;
    case 6:
        new_material(Polished_Copper);
        break;
    case 7:
        new_material(Gold);
        break;
    case 8:
        new_material(Polished_Gold);
        break;
    case 9:
        new_material(Pewter);
        break;
    case 10:
        new_material(Silver);
        break;
    case 11:
        new_material(Polished_Silver);
        break;
    case 12:
        new_material(Emerald);
        break;
    case 13:
        new_material(Jade);
        break;
    case 14:
        new_material(Obsidian);
        break;
    case 15:
        new_material(Pearl);
        break;
    case 16:
        new_material(Ruby);
        break;
    case 17:
        new_material(Turquoise);
        break;
    case 18:
        new_material(Black_Plastic);
        break;
    case 19:
        new_material(Black_Rubber);
        break;
    }

    redisplay_all();
}
示例#6
0
int
main(int argc, char** argv)
{
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    glutInitWindowSize((512+GAP*3)*3/2, 512+GAP*3);
    glutInitWindowPosition(50, 50);
    glutInit(&argc, argv);

    window = glutCreateWindow("Light & Material");
    glutReshapeFunc(main_reshape);
    glutDisplayFunc(main_display);
    glutKeyboardFunc(main_keyboard);

    world = glutCreateSubWindow(window, GAP, GAP, 256, 256);
    glutReshapeFunc(world_reshape);
    glutDisplayFunc(world_display);
    glutKeyboardFunc(main_keyboard);
    glutCreateMenu(world_menu);
    glutAddMenuEntry("Materials", 0);
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("Brass", 1);
    glutAddMenuEntry("Bronze", 2);
    glutAddMenuEntry("Polished_Bronze", 3);
    glutAddMenuEntry("Chrome", 4);
    glutAddMenuEntry("Copper", 5);
    glutAddMenuEntry("Polished_Copper", 6);
    glutAddMenuEntry("Gold", 7);
    glutAddMenuEntry("Polished_Gold", 8);
    glutAddMenuEntry("Pewter", 9);
    glutAddMenuEntry("Silver", 10);
    glutAddMenuEntry("Polished_Silver", 11);
    glutAddMenuEntry("Emerald", 12);
    glutAddMenuEntry("Jade", 13);
    glutAddMenuEntry("Obsidian", 14);
    glutAddMenuEntry("Pearl", 15);
    glutAddMenuEntry("Ruby", 16);
    glutAddMenuEntry("Turquoise", 17);
    glutAddMenuEntry("Black_Plastic", 18);
    glutAddMenuEntry("Black_Rubber", 19);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    screen = glutCreateSubWindow(window, GAP+256+GAP, GAP, 256, 256);
    glutReshapeFunc(screen_reshape);
    glutDisplayFunc(screen_display);
    glutKeyboardFunc(main_keyboard);
    glutMotionFunc(screen_motion);
    glutMouseFunc(screen_mouse);
    glutCreateMenu(screen_menu);
    glutAddMenuEntry("Models", 0);
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("Torus", 'n');
    glutAddMenuEntry("Flat plane", 'l');
    glutAddMenuEntry("Soccerball", 's');
    glutAddMenuEntry("Al Capone", 'a');
    glutAddMenuEntry("F-16 Jet", 'j');
    glutAddMenuEntry("Dolphins", 'd');
    glutAddMenuEntry("Flowers", 'f');
    glutAddMenuEntry("Porsche", 'p');
    glutAddMenuEntry("Rose", 'r');
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    command = glutCreateSubWindow(window, GAP+256+GAP, GAP+256+GAP, 256, 256);
    glutReshapeFunc(command_reshape);
    glutDisplayFunc(material_display);
    glutMotionFunc(command_motion);
    glutMouseFunc(material_mouse);
    glutKeyboardFunc(main_keyboard);
    glutCreateMenu(command_menu);
    glutAddMenuEntry("Light & Material", 0);
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("Material parameters", 'm');
    glutAddMenuEntry("Light model parameters", 'l');
    glutAddMenuEntry("Spotlight & attenuation", 's');
    glutAddMenuEntry("Reset parameters (r)", 'r');
    glutAddMenuEntry("", 0);
    glutAddMenuEntry("Quit", 27);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    new_material(Pewter);
    redisplay_all();

    glutMainLoop();
    return 0;
}
示例#7
0
MaterialID ResourceManagerImpl::new_material_from_file(const unicode& path) {
    //Load the material
    auto mat = material(new_material());
    window().loader_for(path.encode())->into(*mat);
    return mat->id();
}