void TerrainRenderer::VisibilityChanged(const MapCoord x, const MapCoord y, const GameWorldViewer * gwv)
{
	/// Noch kein Terrain gebaut? abbrechen
	if(!vertices)
		return;

	UpdateVertexColor(x,y,gwv);
	for(unsigned i = 0;i<6;++i)
		UpdateVertexColor(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv);
	
	// und für die Ränder
	UpdateBorderVertex(x,y,gwv);
	for(unsigned i = 0;i<6;++i)
		UpdateBorderVertex(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv);

	// den selbst sowieso die Punkte darum updaten, da sich bei letzteren die Schattierung geändert haben könnte
	UpdateTriangleColor(x,y,gwv,true);
	for(unsigned i = 0;i<6;++i)
		UpdateTriangleColor(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv,true);

	// und für die Ränder
	UpdateBorderTriangleColor(x,y,gwv,true);
	for(unsigned i = 0;i<6;++i)
		UpdateBorderTriangleColor(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv,true);
}
示例#2
0
void TerrainRenderer::VisibilityChanged(const MapPoint pt, const GameWorldViewer& gwv)
{
    /// Noch kein Terrain gebaut? abbrechen
    if(vertices.empty())
        return;

    UpdateVertexColor(pt, gwv);
    for(unsigned i = 0; i < 6; ++i)
        UpdateVertexColor(gwv.GetNeighbour(pt, i), gwv);

    // und für die Ränder
    UpdateBorderVertex(pt, gwv);
    for(unsigned i = 0; i < 6; ++i)
        UpdateBorderVertex(gwv.GetNeighbour(pt, i), gwv);

    // den selbst sowieso die Punkte darum updaten, da sich bei letzteren die Schattierung geändert haben könnte
    UpdateTriangleColor(pt, gwv, true);
    for(unsigned i = 0; i < 6; ++i)
        UpdateTriangleColor(gwv.GetNeighbour(pt, i), gwv, true);

    // und für die Ränder
    UpdateBorderTriangleColor(pt, gwv, true);
    for(unsigned i = 0; i < 6; ++i)
        UpdateBorderTriangleColor(gwv.GetNeighbour(pt, i), gwv, true);
}
/**
 *  erzeugt die Terrain-Vertices.
 *
 *  @author OLiver
 */
void TerrainRenderer::GenerateVertices(const GameWorldViewer * gwv)
{
	delete[] vertices;
	vertices = new Vertex[width * height];
	memset(vertices, 0, sizeof(Vertex) * width * height);

	// Terrain generieren
	for(unsigned short y = 0; y < height; ++y)
	{
		for(unsigned short x = 0; x < width; ++x)
		{
			UpdateVertexPos(x,y,gwv);
			UpdateVertexColor(x,y,gwv);
			UpdateVertexTerrain(x,y,gwv);
		}
	}

	// Ränder generieren
	for(unsigned short y = 0; y < height; ++y)
	{
		for(unsigned short x = 0; x < width; ++x)
		{
			UpdateBorderVertex(x,y,gwv);
		}
	}
}
示例#4
0
void TerrainRenderer::UpdateAllColors(const GameWorldViewer& gwv)
{
    for(MapCoord y = 0; y < height; ++y)
        for(MapCoord x = 0; x < width; ++x)
            UpdateVertexColor(MapPoint(x, y), gwv);

    for(MapCoord y = 0; y < height; ++y)
        for(MapCoord x = 0; x < width; ++x)
            UpdateBorderVertex(MapPoint(x, y), gwv);

    for(MapCoord y = 0; y < height; ++y)
        for(MapCoord x = 0; x < width; ++x)
            UpdateTriangleColor(MapPoint(x, y), gwv, false);

    for(MapCoord y = 0; y < height; ++y)
        for(MapCoord x = 0; x < width; ++x)
            UpdateBorderTriangleColor(MapPoint(x, y), gwv, false);

    if(vboBuffersUsed)
    {
        // Generiere und Binde den Color Buffer
        glGenBuffersARB(1, (GLuint*)&vbo_colors);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_colors);
        glBufferDataARB(GL_ARRAY_BUFFER_ARB, gl_colors.size() * sizeof(ColorTriangle), &gl_colors.front(), GL_STATIC_DRAW_ARB );
        glColorPointer(3, GL_FLOAT, 0, NULL);
    }
    else
        glColorPointer(3, GL_FLOAT, 0, &gl_colors.front());
}
示例#5
0
/**
 *  erzeugt die Terrain-Vertices.
 *
 *  @author OLiver
 */
void TerrainRenderer::GenerateVertices(const GameWorldViewer& gwv)
{
    vertices.clear();
    vertices.resize(width * height);

    // Terrain generieren
    for(MapCoord y = 0; y < height; ++y)
    {
        for(MapCoord x = 0; x < width; ++x)
        {
            MapPoint pt(x, y);
            UpdateVertexPos(pt, gwv);
            UpdateVertexColor(pt, gwv);
            UpdateVertexTerrain(pt, gwv);
        }
    }

    // Ränder generieren
    for(MapCoord y = 0; y < height; ++y)
    {
        for(MapCoord x = 0; x < width; ++x)
        {
            MapPoint pt(x, y);
            UpdateBorderVertex(pt, gwv);
        }
    }
}
示例#6
0
/**
 *  erzeugt die Terrain-Vertices.
 *
 *  @author OLiver
 */
void TerrainRenderer::GenerateVertices(const GameWorldViewer* gwv)
{
    delete[] vertices;
    vertices = new Vertex[width * height];
    memset(vertices, 0, sizeof(Vertex) * width * height);

    // Terrain generieren
    for(MapCoord y = 0; y < height; ++y)
    {
        for(MapCoord x = 0; x < width; ++x)
        {
            MapPoint pt(x, y);
            UpdateVertexPos(pt, gwv);
            UpdateVertexColor(pt, gwv);
            UpdateVertexTerrain(pt, gwv);
        }
    }

    // Ränder generieren
    for(MapCoord y = 0; y < height; ++y)
    {
        for(MapCoord x = 0; x < width; ++x)
        {
            MapPoint pt(x, y);
            UpdateBorderVertex(pt, gwv);
        }
    }
}
void TerrainRenderer::AltitudeChanged(const MapCoord x, const MapCoord y, const GameWorldViewer * gwv)
{
	// den selbst sowieso die Punkte darum updaten, da sich bei letzteren die Schattierung geändert haben könnte
	UpdateVertexPos(x,y,gwv);
	UpdateVertexColor(x,y,gwv);
	
	for(unsigned i = 0;i<6;++i)
		UpdateVertexColor(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv);
	

	// und für die Ränder
	UpdateBorderVertex(x,y,gwv);

	for(unsigned i = 0;i<6;++i)
		UpdateBorderVertex(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv);

	// den selbst sowieso die Punkte darum updaten, da sich bei letzteren die Schattierung geändert haben könnte
	UpdateTrianglePos(x,y,gwv,true);
	UpdateTriangleColor(x,y,gwv,true);
	
	for(unsigned i = 0;i<6;++i)
	{
		UpdateTrianglePos(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv,true);
		UpdateTriangleColor(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv,true);
	}


	// Auch im zweiten Kreis drumherum die Dreiecke neu berechnen, da die durch die Schattenänderung der umliegenden
	// Punkte auch geändert werden könnten
	for(unsigned i = 0;i<12;++i)
		UpdateTriangleColor(gwv->GetXA2(x,y,i),gwv->GetYA2(x,y,i),gwv,true);
	

	// und für die Ränder
	UpdateBorderTrianglePos(x,y,gwv,true);
	UpdateBorderTriangleColor(x,y,gwv,true);

	for(unsigned i = 0;i<6;++i)
	{
		UpdateBorderTrianglePos(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv,true);
		UpdateBorderTriangleColor(gwv->GetXA(x,y,i),gwv->GetYA(x,y,i),gwv,true);
	}

	for(unsigned i = 0;i<12;++i)
		UpdateBorderTriangleColor(gwv->GetXA2(x,y,i),gwv->GetYA2(x,y,i),gwv,true);
}
void TerrainRenderer::UpdateAllColors(const GameWorldViewer * gwv)
{
	for(MapCoord y = 0;y<height;++y)
	{
		for(MapCoord x = 0;x<width;++x)
		{
			UpdateVertexColor(x,y,gwv);
		}
	}

	for(MapCoord y = 0;y<height;++y)
	{
		for(MapCoord x = 0;x<width;++x)
		{
			UpdateBorderVertex(x,y,gwv);
		}
	}

	for(MapCoord y = 0;y<height;++y)
	{
		for(MapCoord x = 0;x<width;++x)
		{
			UpdateTriangleColor(x,y,gwv,false);
		}
	}

	for(MapCoord y = 0;y<height;++y)
	{
		for(MapCoord x = 0;x<width;++x)
		{
			UpdateBorderTriangleColor(x,y,gwv,false);
		}
	}

	
	if(SETTINGS.video.vbo)
	{
		// Generiere und Binde den Color Buffer
		glGenBuffersARB(1, (GLuint*)&vbo_colors);
		glBindBufferARB(GL_ARRAY_BUFFER_ARB,vbo_colors);
		glBufferDataARB(GL_ARRAY_BUFFER_ARB, (width * height * 2 + border_count) * 3 * 3 * sizeof(float), gl_colors, GL_STATIC_DRAW_ARB );
		glColorPointer(3, GL_FLOAT, 0, NULL);
	}
	else
		glColorPointer(3, GL_FLOAT, 0, gl_colors);
}