From 70d2e2f6af64b43067d4a8421592b14d1258069b Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 10 Apr 2011 11:30:47 +0200 Subject: Added textures and stuff to repo. --- quadtree.cpp | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'quadtree.cpp') diff --git a/quadtree.cpp b/quadtree.cpp index 8bc366c..c60fd27 100644 --- a/quadtree.cpp +++ b/quadtree.cpp @@ -238,18 +238,34 @@ void Quadtree::QuadChunk::make_vbo() { for(unsigned int index = 0; index < node_count; index++) { Quadtree::QuadNode *node = nodes[index]; - float tex_coords[4][3][2] = { - {{.5, .5}, {0, 0}, {0, 1}}, - {{.5, .5}, {0, 1}, {1, 1}}, - {{.5, .5}, {1, 1}, {1, 0}}, - {{.5, .5}, {1, 0}, {0, 0}} + float tex_coords[4][4][3][2] = { + {{{.25, .25}, {0, 0}, {0, .5}}, + {{.25, .25}, {0, .5}, {.5, .5}}, + {{.25, .25}, {.5, .5}, {.5, 0}}, + {{.25, .25}, {.5, 0}, {0, 0}}}, + + {{{.75, .25}, {.5, 0}, {.5, .5}}, + {{.75, .25}, {.5, .5}, {1, .5}}, + {{.75, .25}, {1, .5}, {1, 0}}, + {{.75, .25}, {1, 0}, {.5, 0}}}, + + {{{.25, .75}, {0, .5}, {0, 1}}, + {{.25, .75}, {0, 1}, {.5, 1}}, + {{.25, .75}, {.5, 1}, {.5, .5}}, + {{.25, .75}, {.5, .5}, {0, .5}}}, + + {{{.75, .75}, {.5, .5}, {.5, 1}}, + {{.75, .75}, {.5, 1}, {1, 1}}, + {{.75, .75}, {1, 1}, {1, .5}}, + {{.75, .75}, {1, .5}, {.5, .5}}} }; for(int i = 0; i < 4; i++) { float *v = buffer + vertex_chunk_size*index + 3*3*i; for(int j = 0; j < 3; j++) { float *tc = buffer + vertices_size + normals_size + tex_coord_chunk_size*index + 6*i + 2*j; - tc[0] = tex_coords[i][j][0]*node->width; - tc[1] = tex_coords[i][j][1]*node->height; + int k = (fmodf(node->x, 2) == 0 ? 1 : 0) + (fmodf(node->y, 2) == 0 ? 2 : 0); + tc[0] = tex_coords[k][i][j][0]*node->width; + tc[1] = tex_coords[k][i][j][1]*node->height; } v[0] = node->vertex_array[0]; -- cgit v1.2.3