-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.c
59 lines (56 loc) · 1.74 KB
/
models.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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "structs.h"
void setFaces(model_t *m, face_t *faces, int facec);
int main(int argc, char *argv[])
{
model_t box;
face_t faces[6] = {
(face_t)
{
(vector){0, 0, 0},
(vector){0, 1, 0},
(vector){1, 1, 0}
},
(face_t)
{
(vector){0, 0, 0},
(vector){1, 0, 0},
(vector){1, 0, 1}
},
(face_t)
{
(vector){0, 0, 1},
(vector){0, 1, 1},
(vector){1, 1, 1}
},
(face_t)
{
(vector){0, 1, 1},
(vector){0, 1, 0},
(vector){1, 1, 0}
},
(face_t)
{
(vector){0, 0, 0},
(vector){0, 1, 0},
(vector){0, 1, 1}
},
(face_t)
{
(vector){1, 0, 0},
(vector){1, 1, 0},
(vector){1, 1, 1}
}
};
setFaces(&box, faces, 6);
printf("done");
return 0;
}
void setFaces(model_t *m, face_t *faces, int facec)
{
m->facec = facec;
m->faces = malloc(m->facec * sizeof(m)); //dynamically assign array size to box.facec
memcpy(m->faces, faces, sizeof(m->faces));
}