43 lines
1.5 KiB
C
43 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* add_sphere.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/02/07 21:41:54 by gbrochar #+# #+# */
|
|
/* Updated: 2019/02/11 11:44:40 by gbrochar ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "rtv1.h"
|
|
|
|
void init_sphere(t_sphere *sphere, t_color *c)
|
|
{
|
|
sphere->o = vec(0, 0, 0);
|
|
sphere->r = 1;
|
|
*c = color(255, 255, 255);
|
|
}
|
|
|
|
int add_sphere(char **data, t_env *e)
|
|
{
|
|
int i;
|
|
t_sphere *sphere;
|
|
t_color c;
|
|
|
|
i = 0;
|
|
ft_putendl("Adding sphere");
|
|
if (!(sphere = (t_sphere *)ft_memalloc(sizeof(t_sphere))))
|
|
return (FAILURE);
|
|
init_sphere(sphere, &c);
|
|
while (data[i] && i < 8)
|
|
++i;
|
|
if (i > 3)
|
|
sphere->o = vec(ft_atof(data[1]), ft_atof(data[2]), ft_atof(data[3]));
|
|
if (i > 4)
|
|
sphere->r = ft_atof(data[4]);
|
|
if (i > 7)
|
|
c = color(ft_atoi(data[5]), ft_atoi(data[6]), ft_atoi(data[7]));
|
|
return (add_obj_node(e, (void *)sphere, SPHERE, c));
|
|
}
|