Exemplo n.º 1
0
float TerrainRenderer::GetBXAround(int x, int y, const unsigned char triangle, const unsigned char dir)
{
    GetPointAround(x, y, dir);

    int xo;
    MapPoint t = ConvertCoords(x, y, &xo, NULL);

    return GetBX(t, triangle) + xo;
}
Exemplo n.º 2
0
float TerrainRenderer::GetBXAround(int x, int y, const unsigned char triangle, const unsigned char dir)
{
	unsigned short tx,ty;

	GetPointAround(x,y,dir);

	int xo,yo;
	ConvertCoords(x,y,tx,ty,&xo,&yo);

	return GetBX(tx,ty,triangle)+xo;
}
Exemplo n.º 3
0
/// 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]);
	}
}