-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.c
104 lines (91 loc) · 2.27 KB
/
scene.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* scene.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmikaeli <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/16 16:34:51 by tdemay #+# #+# */
/* Updated: 2014/03/17 14:10:21 by bmikaeli ### ########.fr */
/* */
/* ************************************************************************** */
#include "scene.h"
t_scene *new_scene(void)
{
t_scene *new;
new = NEW(t_scene);
new->tab_s = NULL;
new->count_s = 0;
new->tab_p = NULL;
new->count_p = 0;
return (new);
}
# include <stdio.h>
t_scene *add_sphere(t_scene *rob, t_sphere *new)
{
t_sphere **tab;
int i;
i = 0;
rob->count_s += 1;
tab = (t_sphere**)malloc(rob->count_s * sizeof(t_sphere*));
while (i != (rob->count_s - 1))
{
tab[i] = rob->tab_s[i];
i++;
}
tab[i] = new;
free(rob->tab_s);
rob->tab_s = tab;
return (rob);
}
t_scene *add_light(t_scene *rob, t_light *new)
{
t_light **tab;
int i;
i = 0;
rob->count_l += 1;
tab = (t_light**)malloc(rob->count_l * sizeof(t_light*));
while (i != (rob->count_l - 1))
{
tab[i] = rob->tab_l[i];
i++;
}
tab[i] = new;
free(rob->tab_l);
rob->tab_l = tab;
return (rob);
}
t_scene *add_plan(t_scene *rob, t_plan *new)
{
t_plan **tab;
int i;
i = 0;
rob->count_p += 1;
tab = (t_plan**)malloc(rob->count_p * sizeof(t_plan*));
while (i < (rob->count_p - 1))
{
tab[i] = rob->tab_p[i];
i++;
}
tab[i] = new;
free(rob->tab_p);
rob->tab_p = tab;
return (rob);
}
t_scene *add_cyl(t_scene *rob, t_cyl *cyl)
{
t_cyl **tab;
int i;
i = 0;
rob->count_cyl += 1;
tab = (t_cyl**)malloc(rob->count_cyl * sizeof(t_cyl*));
while (i < (rob->count_cyl - 1))
{
tab[i] = rob->tab_cyl[i];
i++;
}
tab[i] = cyl;
free(rob->tab_cyl);
rob->tab_cyl = tab;
return (rob);
}