Exemplo n.º 1
0
int				ft_get_cone(t_rtv1 *rtv1, t_lstline **list, int *line_nb)
{
	int		i;
	char	**tab;
	char	**tri;

	tab = NULL;
	tri = NULL;
	if ((i = -1) && ((rtv1->obj.cone != NULL || (rtv1->nb_cone = ft_atoi(&(*list)->line[9]))) == 0))
		return (1);
	rtv1->obj.cone = (t_cone *)ft_memalloc(sizeof(t_cone) * rtv1->nb_cone);
	while (++i < rtv1->nb_cone)
	{
		*list = (*list)->next;
		if ((*line_nb += 1) && ((tab = ft_strsplitstr((*list)->line, " / "))
					== NULL || ft_memlen((void **)tab) != 5 || (tri = ft_get_3d_val(tab[0])) == NULL
				|| !ft_isdouble(tab[1]) || !ft_isdouble(tab[2]) || !ft_strishexa(tab[3])))
			return (1);
		ft_fill_cone(rtv1, tab, tri, i);
		ft_memdel2((void ***)&tri);
		if ((tri = ft_get_3d_val(tab[4])) == NULL)
			return (1);
		ft_fill_rot_cone(rtv1, tri, i);
		ft_memdel2((void ***)&tab);
		ft_memdel2((void ***)&tri);
	}
	return (0);
}
Exemplo n.º 2
0
static int		ft_fill_objs(char *file, t_obj *tobj)
{
	int				fd;
	char			*line;
	static int		i = -1;

	fd = open(file, O_RDONLY);
	while (get_next_line(fd, &line) > 0)
	{
		if (line[0] == '#')
		{
			if (!(ft_strncmp(line + 1, "box", 3)))
				i = ft_fill_box(fd, tobj);
			else if (!(ft_strncmp(line + 1, "sphere", 6)))
				i = ft_fill_sphere(fd, tobj);
			else if (!(ft_strncmp(line + 1, "plane", 5)))
				i = ft_fill_plane(fd, tobj);
			else if (!(ft_strncmp(line + 1, "disk", 4)))
				i = ft_fill_disk(fd, tobj);
			else if (!(ft_strncmp(line + 1, "cone", 4)))
				i = ft_fill_cone(fd, tobj);
			else if (!(ft_strncmp(line + 1, "cylinder", 8)))
				i = ft_fill_cylinder(fd, tobj);
		}
	}
	close(fd);
	return (i);
}