first commit
This commit is contained in:
commit
6b84f3115d
9 changed files with 14807 additions and 0 deletions
39
cubes.c
Normal file
39
cubes.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "const.h"
|
||||
|
||||
// placeholder function
|
||||
int cubeExists(int x, int y, int z) {
|
||||
return ((x % 3) == (y % 4) && (y % 5) == (z % 6));
|
||||
}
|
||||
|
||||
void gen_face(Vertex *cube, int i, int x, int y, int z, int j) {
|
||||
Vertex a = {{x,y,z}};
|
||||
Vertex b = a;
|
||||
b.pos[(i==0)?1:0]++;
|
||||
Vertex c = a;
|
||||
c.pos[(i==2)?1:2]++;
|
||||
Vertex d = c;
|
||||
d.pos[(i==0)?1:0]++;
|
||||
cube[j] = a;
|
||||
cube[j+1] = b;
|
||||
cube[j+2] = c;
|
||||
cube[j+3] = c;
|
||||
cube[j+4] = b;
|
||||
cube[j+5] = d;
|
||||
}
|
||||
|
||||
void gen_cubes(Vertex *cube, int x, int y, int z) {
|
||||
int i = 0;
|
||||
for (int y2 = y; y2 < y + CHUNK_LENGTH; y2++) {
|
||||
int y3 = y2;
|
||||
for (int x2 = x; x2 < x + CHUNK_LENGTH; x2++) {
|
||||
int x3 = x2;
|
||||
for (int z2 = z; z2 < z + CHUNK_LENGTH; z2++) {
|
||||
int z3 = z2;
|
||||
gen_face(cube, 0, x3, y3, z3, i);
|
||||
gen_face(cube, 1, x3, y3, z3, i + 6);
|
||||
gen_face(cube, 2, x3, y3, z3, i + 12);
|
||||
i += 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue