Original Post
What''s wrong with this?
It seems to be rendering som triangles that aren''t supposed to be there...
for (x = xpos; x <= size + xpos; x += trisize) {
for (y = ypos; y <= size + ypos; y += trisize) {
currentcolor = parent->parent->map[parent->mapID]->LightMapData[x * parent->size / trisize + y / trisize].x;
vertex[currentvertex] = Vector3D((float)x, parent->parent->map[parent->mapID]->Height(x, y), (float)y);
color[currentvertex] = Vector3D(currentcolor, currentcolor, currentcolor);
if (vertex[currentvertex].y > topvert.y)
topvert.y = vertex[currentvertex].y;
if (vertex[currentvertex].y < bottomvert.y)
bottomvert.y = vertex[currentvertex].y;
texcoord[currentvertex].u = (float)x / (float)parent->size;
texcoord[currentvertex].v = (float)y / (float)parent->size;
currentvertex++;
}
}
currentvertex = 0;
for (x = 0; x <= size; x += trisize) {
if(switchsides) { // Check if we need to render the opposite way for this column
for (y = size; y >= 0; y -= trisize) {
currentvertex = x / trisize * size / trisize + y / trisize;
vertindex[index++] = currentvertex;
currentvertex = (x + trisize) / trisize * size / trisize + y / trisize;
vertindex[index++] = currentvertex;
}
} else {
for (y = 0; y <= size; y += trisize) {
currentvertex = (x + trisize) / trisize * size / trisize + y / trisize;
vertindex[index++] = currentvertex;
currentvertex = x / trisize * size / trisize + y / trisize;
vertindex[index++] = currentvertex;
}
}
switchsides = !switchsides;
}
