static void TestBake(FileInfo[] files, string pathBMP, RichTextBox log)
{
Bitmap bmp = Bitmap.FromFile(pathBMP) as Bitmap;
VertexPositionNormalTexture[] verts;
int[] inds;
int py = 0;
float percent = 0f, dp = 100f / files.Length;
float totalDistSq = 0f, maxDistSq = 0f;
log.AppendText("Percent Complete: " + percent + "%\n");
foreach(var fi in files) {
using(FileStream fs = File.OpenRead(fi.FullName)) {
ObjParser.TryParse(fs, out verts, out inds, ParsingFlags.ConversionOpenGL);
}
for(int px = 0; px < bmp.Width || px < verts.Length; px++) {
Vector3 point = new Vector3(
Convert(bmp.GetPixel(px, py)),
Convert(bmp.GetPixel(px, py + 1)),
Convert(bmp.GetPixel(px, py + 2))
);
float d = (point - verts[px].Position).LengthSquared();
totalDistSq += d;
if(d > maxDistSq) maxDistSq = d;
}
py += 3;
percent += dp;
log.AppendText("Percent Complete: " + percent + "%\n");
}
log.AppendText("Total Error (Sum Squares): " + totalDistSq + "\nMax Error: " + maxDistSq + "\n");
bmp.Dispose();
}