-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_info_sphere.c
55 lines (51 loc) · 1.57 KB
/
get_info_sphere.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
** get_info.c for get_info in /home/nicolas/Modules/gfx_raytracer1
**
** Made by menett_a
** Login <[email protected]>
**
** Started on Sun Feb 28 22:20:00 2016 menett_a
** Last update Sun Mar 13 20:49:20 2016 menett_a
*/
#include <lapin.h>
#include "struct.h"
#include "proto.h"
char *get_ini_fields_sphe(t_bunny_ini *ini, t_info *info, int *nb, int sphe)
{
if (my_getnbr(bunny_ini_get_field(ini, "raytracer1", "sphere", *nb),
&info->sphe[sphe].pos_x) == -1)
return ("Error while getting info of sphere's pos_x\n");
*nb = *nb + 1;
if (my_getnbr(bunny_ini_get_field(ini, "raytracer1", "sphere", *nb),
&info->sphe[sphe].pos_y) == -1)
return ("Error while getting info of sphere's pos_y\n");
*nb = *nb + 1;
if (my_getnbr(bunny_ini_get_field(ini, "raytracer1", "sphere", *nb),
&info->sphe[sphe].pos_z) == -1)
return ("Error while getting info of sphere's pos_z\n");
*nb = *nb + 1;
if (my_getnbr(bunny_ini_get_field(ini, "raytracer1", "sphere", *nb),
&info->sphe[sphe].radius) == -1)
return ("Error while getting info of sphere's radius\n");
*nb = *nb + 1;
if (my_getnbr(bunny_ini_get_field(ini, "raytracer1", "sphere", *nb),
&info->sphe[sphe].color) == -1)
return ("Error while getting info of sphere's color\n");
*nb = *nb + 1;
return (NULL);
}
char *get_info_sphere(t_bunny_ini *ini, t_info *info)
{
char *str;
int sphere;
int nb;
nb = 1;
sphere = 0;
while (sphere < info->nb_sphere)
{
if ((str = get_ini_fields_sphe(ini, info, &nb, sphere)) != NULL)
return (str);
sphere = sphere + 1;
}
return (NULL);
}