more stuff
This commit is contained in:
parent
7bf40240fe
commit
48ecd8d9e8
5 changed files with 96 additions and 48 deletions
60
cubes.c
60
cubes.c
|
@ -1,27 +1,50 @@
|
|||
#include "const.h"
|
||||
//#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// placeholder function
|
||||
int cubeExists(int x, int y, int z) {
|
||||
return ((x % 3) == (y % 4) && (y % 5) == (z % 6));
|
||||
srand(x ^ y ^ z);
|
||||
return ((rand() % 3 == 0) && y == 1);
|
||||
}
|
||||
|
||||
void gen_face(Vertex *cube, int i, int x, int y, int z, int j) {
|
||||
Vertex a = {{x,y,z}};
|
||||
void gen_face(Vertex *cube, int i, int x, int y, int z, int j, int is_text) {
|
||||
Vertex a = {{x, y, z}};
|
||||
|
||||
if (is_text) {
|
||||
a.pos[i]--;
|
||||
int exists =
|
||||
cubeExists(x, y, z) != cubeExists(a.pos[0], a.pos[1], a.pos[2]);
|
||||
a.pos[0] = exists ? TEXT_GAP_H * i : -1.0;
|
||||
a.pos[1] = exists ? TEXT_GAP_V * i : -1.0;
|
||||
a.pos[2] = 0;
|
||||
}
|
||||
|
||||
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]++;
|
||||
Vertex d = a;
|
||||
|
||||
if (is_text) {
|
||||
b.pos[0] += TEXT_GAP_H;
|
||||
c.pos[1] += TEXT_GAP_V;
|
||||
d.pos[0] += TEXT_GAP_H;
|
||||
d.pos[1] += TEXT_GAP_V;
|
||||
} else {
|
||||
b.pos[(i == 0) ? 1 : 0]++;
|
||||
c.pos[(i == 2) ? 1 : 2]++;
|
||||
d.pos[(i == 0) ? 1 : 0]++;
|
||||
d.pos[(i == 2) ? 1 : 2]++;
|
||||
}
|
||||
|
||||
cube[j] = a;
|
||||
cube[j+1] = b;
|
||||
cube[j+2] = c;
|
||||
cube[j+3] = c;
|
||||
cube[j+4] = b;
|
||||
cube[j+5] = d;
|
||||
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) {
|
||||
void gen_cubes(Vertex *cube, int x, int y, int z, int is_text) {
|
||||
int i = 0;
|
||||
for (int y2 = y; y2 < y + CHUNK_LENGTH; y2++) {
|
||||
int y3 = y2;
|
||||
|
@ -29,9 +52,14 @@ void gen_cubes(Vertex *cube, int x, int y, int z) {
|
|||
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);
|
||||
|
||||
if (is_text) {
|
||||
x3 = y3 = z3 = 0;
|
||||
}
|
||||
|
||||
gen_face(cube, 0, x2, y2, z2, i, is_text);
|
||||
gen_face(cube, 1, x2, y2, z2, i + 6, is_text);
|
||||
gen_face(cube, 2, x2, y2, z2, i + 12, is_text);
|
||||
i += 18;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue