static void la_norme_a_pas_dit_bonjour(char **line, t_obj *object, int i, int fd) { if ((*line)[i] && strncmp(*line + i, "brightness", 10) == 0) object->brightness = parse_brightness(fd); else if ((*line)[i] && strncmp(*line + i, "sphere", 6) == 0) create_sphere(object, fd); else if ((*line)[i] && strncmp(*line + i, "cylinder", 8) == 0) create_cylinder(object, fd); else if ((*line)[i] && strncmp(*line + i, "cone", 4) == 0) create_cone(object, fd); else if ((*line)[i] && strncmp(*line + i, "para", 4) == 0) create_para(object, fd); else if ((*line)[i] && strncmp(*line + i, "plan", 4) == 0) create_plan(object, fd); else if ((*line)[i] && strncmp(*line + i, "spec", 4) == 0) object->spec = parse_brightness(fd); else if ((*line)[i] && strncmp(*line + i, "transpa", 7) == 0) object->transpa = parse_brightness(fd); else if ((*line)[i] && strncmp(*line + i, "indice", 6) == 0) object->indice = parse_brightness(fd); else if ((*line)[i] && strncmp(*line + i, "texture", 7) == 0) object->texture = parse_texture(fd); else if ((*line)[i] && strncmp(*line + i, "normal", 6) == 0) object->normal_map = parse_normal_map(fd); else if ((*line)[i] && strncmp(*line + i, "rep", 3) == 0) object->rep = parse_object_rep(fd); }
void ShZshapeManager::create_shape(const char* content) { if (content == "cube") { create_cube(); } if (content == "cylinder") { create_cylinder(); } if (content == "pipe") { create_pipe(); } if (content == "cone") { create_cone(); } if (content == "circle") { create_circle(); } if (content == "ring") { create_ring(); } if (content == "pyramid") { create_pyramid(); } if (content == "triangle") { create_triangle(); } if (content == "rectangle") { create_rectangle(); } if (content == "polygon") { create_polygon(); } if (content == "multigonalStar") { create_multigonalStar(); } }
void ShZshapeManager::create_shape(const char* content, GLdouble positionX, GLdouble positionY, GLdouble positionZ, GLdouble r, GLdouble h) { if (content == "cylinder") { create_cylinder(positionX, positionY, positionZ, r, h); } if (content == "cone") { create_cone(positionX, positionY, positionZ, r, h); } }
/** to initialize the scene with the default one. */ void make_test_scene (int xsize, int ysize) { //camera set_camera (0.f, 4.f, -4.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 90.f, xsize, ysize); //objects Material * plastic = create_plastic_mat (0.6f, 0.5f, 0.5f, 0.6f, 0.5f, 0.5f, 100.f); // ground plane Geometry * plane = create_plane (0.f, -1.f, 0.f, 0.f, 1.f, 0.f); add_object (plane, plastic); // Up row // base objects Geometry *boxLeft = create_box (-2.f, 3.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.25f, 1.f, 1.f, 1.f, 1.f); Geometry *sphereLeft = create_sphere (-2.f, 3.f, 0.f, 0.65f); Geometry *boxCenter = create_box (0.f, 3.25f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.25f, 1.f, 1.f, 1.f, 1.f); Geometry *sphereCenter = create_sphere (0.f, 3.25f, 0.f, 0.65f); Geometry *boxRight = create_box (2.f, 3.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.25f, 1.f, 1.f, 1.f, 1.f); Geometry *sphereRight = create_sphere (2.f, 3.f, 0.f, 0.65f); // CSG objects Geometry *unionUp = create_csg_union (boxLeft, sphereLeft); Geometry *intersectionUp = create_csg_intersection(boxCenter, sphereCenter); Geometry *differenceUp = create_csg_difference(boxRight, sphereRight); add_object (unionUp, plastic); add_object (intersectionUp, plastic); add_object (differenceUp, plastic); // Middle row // base objects Geometry *coneLeft = create_cone(-2.25f, 1.f, -1.25f, -2.25f, 3.f, -1.25f, 0.5f); Geometry *cylinderLeft = create_cylinder(-2.25f, 1.75f, -1.25f, 0.5f, 0.f, 1.f, 0.25f, 1.5f); Geometry *coneCenter = create_cone(0.f, 1.5f, -0.75f, 0.f, 3.5f, -0.75f, 0.5f); Geometry *cylinderCenter = create_cylinder(0.f, 2.25f, -0.75f, 0.5f, 0.f, 1.f, 0.25f, 1.5f); Geometry *coneRight = create_cone(2.25f, 1.f, -1.25f, 2.25f, 3.f, -1.25f, 0.5f); Geometry *cylinderRight = create_cylinder(2.25f, 1.75f, -1.25f, 0.5f, 0.f, 1.f, 0.25f, 1.5f); // CSG objects Geometry * unionDown = create_csg_union (coneLeft, cylinderLeft); Geometry * intersectionDown = create_csg_intersection(coneCenter, cylinderCenter); Geometry * differenceDown = create_csg_difference(coneRight, cylinderRight); add_object (unionDown, plastic); add_object (intersectionDown, plastic); add_object (differenceDown, plastic); // front object char complex_tree[] = "(- (* (bo 0. 2.5 -3.25 1. 0. 0. 0. 0. 1. 1.0 1.0 1.0) (sp 0. 2.5 -3.25 0.65) ) (+ (cy 0. 2.5 -3.25 1.0 0.0 0.0 0.3 1.75) (+ (cy 0. 2.5 -3.25 0.0 1.0 0.0 0.3 1.75) (cy 0. 2.5 -3.25 0.0 0.0 1.0 0.3 1.75) ) ) )"; Geometry *tree = csg_parse(complex_tree); if (tree) add_object (tree, plastic); //lights // Front light -- white add_light (0.f, 5.f, -1.5f, 1.5f, 1.5f, 1.5f); // Back light -- blue add_light (4.f, 2.f, 10.f, 0.1f, 0.1f, 0.9f); // Left light -- red add_light (-4.f, 5.f, -2.f, 0.9f, 0.1f, 0.1f); }