Ejemplo n.º 1
0
static int		parse_polygon_components(
					const char **tokens,
					t_polygon *new_polygon)
{
	int			i;
	int			nt;
	char		**ctokens;

	i = 0;
	if (!tokens_are_enough(tokens, 3))
		parser_die("A face must declare at least three vertices.");
	while (tokens[i])
	{
		nt = 0;
		if (strstr(tokens[i], "//"))
			nt = 1;
		ctokens = ft_split(tokens[i], "/\n");
		if (!add_vertex((const char **)ctokens, nt, new_polygon->vertices))
		{
			ft_free_tab(ctokens);
			return (0);
		}
		++i;
		ft_free_tab(ctokens);
	}
	return (1);
}
Ejemplo n.º 2
0
int			parse_color(const char **tokens)
{
	t_vec2	*new_color;

	new_color = NULL;
	if (!tokens_are_enough(tokens, 2))
		parser_die("A texture needs two arguments.");
	else if (!(new_color = malloc(sizeof(t_vec2))))
		return (0);
	new_color->x = atof(tokens[0]);
	new_color->y = atof(tokens[1]);
	lst_push_back(g_current_data->uvs, new_color);
	return (1);
}