private void RefreshMeshes()
{
int totalChars = this.charInfoList.Count;
if (totalChars == 0)
{
return;
}
////this.normalLines.Clear();
int index = 0;
int remainingVertices = totalChars * CHARVERTICES;
int bufferLength = 0;
Vector3 normal = Vector3.UnitZ;
float tW = this.SpriteFont.FontTexture.Width;
float tH = this.SpriteFont.FontTexture.Height;
for (int charNum = 0; charNum < totalChars; charNum++)
{
var charInfo = this.charInfoList[charNum];
var p = charInfo.Position;
var s = charInfo.SourceRectangle;
// Builds the vertex information.
// Front Vertex
this.vertexBufferData[index].Position = new Vector3(p.Left, p.Top, 0);
this.vertexBufferData[index].Normal = normal;
this.vertexBufferData[index].TexCoord = new Vector2(s.Left / tW, s.Bottom / tH);
this.vertexBufferData[index + 1].Position = new Vector3(p.Right, p.Top, 0);
this.vertexBufferData[index + 1].Normal = normal;
this.vertexBufferData[index + 1].TexCoord = new Vector2(s.Right / tW, s.Bottom / tH);
this.vertexBufferData[index + 2].Position = new Vector3(p.Left, p.Bottom, 0);
this.vertexBufferData[index + 2].Normal = normal;
this.vertexBufferData[index + 2].TexCoord = new Vector2(s.Left / tW, s.Top / tH);
this.vertexBufferData[index + 3].Position = new Vector3(p.Right, p.Bottom, 0);
this.vertexBufferData[index + 3].Normal = normal;
this.vertexBufferData[index + 3].TexCoord = new Vector2(s.Right / tW, s.Top / tH);
index += CHARVERTICES;
remainingVertices -= CHARVERTICES;
bufferLength += CHARVERTICES;
if ((index >= BUFFERLENGTH) || (remainingVertices <= 0))
{
Mesh mesh = this.CreateMesh();
mesh.VertexBuffer.SetData(this.vertexBufferData, BUFFERLENGTH, 0);
mesh.NumVertices = bufferLength;
mesh.NumPrimitives = (bufferLength * CHARTRIANGLES) / CHARVERTICES;
this.RenderManager.GraphicsDevice.BindVertexBuffer(mesh.VertexBuffer);
this.meshes.Add(mesh);
mesh.VertexBuffer.FreePointer();
index = 0;
bufferLength = 0;
}
}
}