Exemple #1
0
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);
	}

}
Exemple #4
0
void	init_scene(t_img *img)
{
	init_cam(&img->scene.cam, init_vect(-2, -2, 0));
	img->scene.light = create_light(init_vect(0, 0, -35), 0xffffff);
	img->scene.obj[0] = create_sphere(init_vect(0, 0, -10), 80, 0xffffff);
	img->scene.obj[1] = create_sphere(init_vect(-20, 24, -80), 50, 0x00ff00);
	img->scene.obj[2] = create_sphere(init_vect(10, 10, -100), 50, 0xfff700);
	img->scene.obj[3] = create_sphere(init_vect(200, 200, -150), 50, 0x0000ff);
//	img->scene.obj[4] = create_cone(init_vect(0, 0, -5), 20, 0xff00ff);
	img->scene.obj[4] = create_sphere(init_vect(600, 600, -150), 50, 0xff00ff);
	img->scene.obj[5] = create_cylinder(init_vect(2, 2, -110),
							init_vect(0, 1, 1), 50, 0x777777);
	img->scene.obj[6] = create_plane(init_vect(1, 0, 1),
							init_vect(0, 0, -200), 0xff0000);
	img->scene.obj[7] = create_plane(init_vect(0, 1, 1),
							init_vect(0, 0, -200), 0xffffcc);
}
Exemple #5
0
/** 
 * wrapper func to validate the block of points being processed and to
 * call the appropriate handler.
 */
int
process_group(point_line_t **plta, int count) {
    int valid_count = 0;

    if (!plta) {
	printf("WARNING: Unexpected call to process_multi_group with a NULL point array\n");
	return 0;
    }

    bu_log("processing a group!\n");

    /* resort the list, put nulls at the end */
    valid_count = condense_points(plta, count);

    /* ignore insufficient counts */
    if (valid_count <= 2)
	switch ((*plta)[0].code) {
	    case(PLATE): /* need at least 3 (triangle) */
		/*		printf("IGNORING PLATE POINT DUPLICATE(S)\n"); */
		return 0;
	    case(ARB): /* need 8 */
		/*		printf("IGNORING ARB POINT DUPLICATE(S)\n");*/
		return 0;
	    case(CYLINDER): /* need at least 3 (2 for length + diam) */
		/* printf("IGNORING CYLINDER POINT DUPLICATE(S)\n"); */
		return 0;
	}

    /* FIXME: callbacks should really be registered in the lexer or
       parser when a point-line of that particular type is
       encountered
    */
    switch ((*plta)[0].code) {
	case(PLATE):
	    return create_plate(plta, valid_count);
	case(ARB):
	    return create_arb(plta, valid_count);
	case(CYLINDER):
	    return create_cylinder(plta, valid_count);
	case(CYL):
	    return create_cyl(plta, valid_count);
	case(POINTS):
#if PRINT_ARRAY
	    static int print_counter = 0;
	    if (print_counter == 0) {
		bu_log("--- POINTS ---\n");
		print_array(plta, count);
	    }
#endif
	    return create_points(plta, valid_count);
	case(SYMMETRY):
	    return create_points(plta, valid_count);
	case(PIPE):
	    return create_pipe(plta, valid_count);
	case(SPHERE):
	    return create_sphere(plta, valid_count);
    }

    printf("WARNING, unsupported point code encountered (%d)\n", (*plta)[0].code);
    return 0;
}
Exemple #6
0
/**
 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);
}