void TerrainRenderer::UpdateTrianglePos(const MapCoord x, const MapCoord y,const GameWorldViewer * gwv, const bool update) { unsigned int pos = 2 * width * y + x*2; gl_vertices[pos].pos[0].x = GetTerrainXAround(x,y,4); gl_vertices[pos].pos[0].y = GetTerrainYAround(x,y,4); gl_vertices[pos].pos[1].x = GetTerrainX(x, y); gl_vertices[pos].pos[1].y = GetTerrainY(x, y); gl_vertices[pos].pos[2].x = GetTerrainXAround(x,y,5); gl_vertices[pos].pos[2].y = GetTerrainYAround(x,y,5); ++pos; gl_vertices[pos].pos[0].x = GetTerrainX(x, y); gl_vertices[pos].pos[0].y = GetTerrainY(x, y); gl_vertices[pos].pos[1].x = GetTerrainXAround(x,y,4); gl_vertices[pos].pos[1].y = GetTerrainYAround(x,y,4); gl_vertices[pos].pos[2].x = GetTerrainXAround(x,y,3); gl_vertices[pos].pos[2].y = GetTerrainYAround(x,y,3); if(update && SETTINGS.video.vbo) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_vertices); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB,(pos-1) * 3 * 2 * sizeof(float), 2 * 3 * 2 * sizeof(float), &gl_vertices[pos-1]); } }
/// erzeugt Rand-Vertex void TerrainRenderer::UpdateBorderVertex(const MapPoint pt, const GameWorldViewer* gwv) { /// @todo GetTerrainX und Co durch GetTerrainXA ausdrücken GetVertex(pt).border[0].pos.x = ( GetTerrainXAround(pt.x, pt.y, 5) + GetTerrainX(pt) + GetTerrainXAround(pt.x, pt.y, 4) ) / 3.0f; GetVertex(pt).border[0].pos.y = ( GetTerrainYAround(pt.x, pt.y, 5) + GetTerrainY(pt) + GetTerrainYAround(pt.x, pt.y, 4) ) / 3.0f; GetVertex(pt).border[0].color = ( GetColor(gwv->GetNeighbour(pt, 5)) + GetColor(pt) + GetColor(gwv->GetNeighbour(pt, 4)) ) / 3.0f; GetVertex(pt).border[1].pos.x = ( GetTerrainXAround(pt.x, pt.y, 3) + GetTerrainX(pt) + GetTerrainXAround(pt.x, pt.y, 4) ) / 3.0f; GetVertex(pt).border[1].pos.y = ( GetTerrainYAround(pt.x, pt.y, 3) + GetTerrainY(pt) + GetTerrainYAround(pt.x, pt.y, 4) ) / 3.0f; GetVertex(pt).border[1].color = ( GetColor(gwv->GetNeighbour(pt, 3)) + GetColor(pt) + GetColor(gwv->GetNeighbour(pt, 4)) ) / 3.0f; }
/// erzeugt Rand-Vertex void TerrainRenderer::UpdateBorderVertex(const MapCoord x, const MapCoord y,const GameWorldViewer * gwv) { /// @todo GetTerrainX und Co durch GetTerrainXA ausdrücken GetVertex(x,y).border[0].pos.x = ( GetTerrainXAround(x,y,5) + GetTerrainX(x, y) + GetTerrainXAround(x,y,4) ) / 3.0f; GetVertex(x,y).border[0].pos.y = ( GetTerrainYAround(x,y,5) + GetTerrainY(x, y) + GetTerrainYAround(x,y,4) ) / 3.0f; GetVertex(x,y).border[0].color = ( GetColor(gwv->GetXA(x,y,5), gwv->GetYA(x,y,5)) + GetColor(x, y) + GetColor(gwv->GetXA(x,y,4), gwv->GetYA(x,y,4)) ) / 3.0f; GetVertex(x,y).border[1].pos.x = ( GetTerrainXAround(x,y,3) + GetTerrainX(x, y) + GetTerrainXAround(x,y,4) ) / 3.0f; GetVertex(x,y).border[1].pos.y = ( GetTerrainYAround(x,y,3) + GetTerrainY(x, y) + GetTerrainYAround(x,y,4) ) / 3.0f; GetVertex(x,y).border[1].color = ( GetColor(gwv->GetXA(x,y,3), gwv->GetYA(x,y,3)) + GetColor(x, y) + GetColor(gwv->GetXA(x,y,4), gwv->GetYA(x,y,4)) ) / 3.0f; }
/// Erzeugt die Dreiecke für die Ränder void TerrainRenderer::UpdateBorderTrianglePos(const MapCoord x, const MapCoord y,const GameWorldViewer * gwv, const bool update) { unsigned int pos = y * width + x; // Für VBO-Aktualisierung: // Erzeugte Ränder zählen unsigned count_borders = 0; // Erstes Offset merken unsigned first_offset = 0; // Rand links - rechts for(unsigned char i = 0; i < 2; ++i) { if(borders[pos].left_right[i]) { unsigned int offset = borders[pos].left_right_offset[i]; if(!first_offset) first_offset = offset; gl_vertices[offset].pos[i ? 0 : 2].x = GetTerrainX(x, y); gl_vertices[offset].pos[i ? 0 : 2].y = GetTerrainY(x, y); gl_vertices[offset].pos[1 ].x = GetTerrainXAround(x,y,4); gl_vertices[offset].pos[1 ].y = GetTerrainYAround(x,y,4); gl_vertices[offset].pos[i ? 2 : 0].x = GetBX(x, y, i); gl_vertices[offset].pos[i ? 2 : 0].y = GetBY(x, y, i); ++count_borders; } } // Rand rechts - links for(unsigned char i = 0; i < 2; ++i) { if(borders[pos].right_left[i]) { unsigned int offset = borders[pos].right_left_offset[i]; if(!first_offset) first_offset = offset; gl_vertices[offset].pos[i ? 2 : 0].x = GetTerrainXAround(x,y,4); gl_vertices[offset].pos[i ? 2 : 0].y = GetTerrainYAround(x,y,4); gl_vertices[offset].pos[1 ].x = GetTerrainXAround(x,y,3); gl_vertices[offset].pos[1 ].y = GetTerrainYAround(x,y,3); if(i == 0) { gl_vertices[offset].pos[2].x = GetBX(x, y, 1); gl_vertices[offset].pos[2].y = GetBY(x, y, 1); } else { gl_vertices[offset].pos[0].x = GetBXAround(x, y, 0, 3); gl_vertices[offset].pos[0].y = GetBYAround(x, y, 0, 3); } ++count_borders; } } // Rand oben - unten for(unsigned char i = 0; i < 2; ++i) { if(borders[pos].top_down[i]) { unsigned int offset = borders[pos].top_down_offset[i]; if(!first_offset) first_offset = offset; gl_vertices[offset].pos[i ? 2 : 0].x = GetTerrainXAround(x,y,5); gl_vertices[offset].pos[i ? 2 : 0].y = GetTerrainYAround(x,y,5); gl_vertices[offset].pos[1 ].x = GetTerrainXAround(x,y,4); gl_vertices[offset].pos[1 ].y = GetTerrainYAround(x,y,4); if(i == 0) { gl_vertices[offset].pos[2].x = GetBX(x,y,i); gl_vertices[offset].pos[2].y = GetBY(x,y,i); } else { //x - i + i * rt, y + i, i gl_vertices[offset].pos[0].x = GetBXAround(x, y, i, 5); gl_vertices[offset].pos[0].y = GetBYAround(x, y, i, 5); } ++count_borders; } } /// Bei Vertexbuffern das die Daten aktualisieren if(update && SETTINGS.video.vbo) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_vertices); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB,first_offset * 3 * 2 * sizeof(float), count_borders * 3 * 2 * sizeof(float), &gl_vertices[first_offset]); } }