diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-10 11:30:47 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-04-10 11:30:47 +0200 |
commit | 70d2e2f6af64b43067d4a8421592b14d1258069b (patch) | |
tree | 0e41232ec5db974329a21b8aa911dfc85d325255 /quadtree.cpp | |
parent | 8dbf3e6294a9635cb28ac6d24d2ed71f75499ef7 (diff) |
Added textures and stuff to repo.
Diffstat (limited to 'quadtree.cpp')
-rw-r--r-- | quadtree.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
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]; |