static void SuperBake(FileInfo[] files, string pathOut, RichTextBox log)
{
VertexPositionNormalTexture[] verts;
int[] inds;
// Find The Width Of The Bitmap First
int bmpWidth = 0;
using(FileStream fs = File.OpenRead(files[0].FullName)) {
ObjParser.TryParse(fs, out verts, out inds, ParsingFlags.ConversionOpenGL);
bmpWidth = verts.Length;
}
Bitmap bmp = new Bitmap(bmpWidth, files.Length * 3);
log.AppendText("Creating New Image " + bmp.Width + " x " + bmp.Height + "\n");
// Bake
int py = 0;
float percent = 0f, dp = 100f / files.Length;
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++) {
bmp.SetPixel(px, py, Convert(verts[px].Position.X));
bmp.SetPixel(px, py + 1, Convert(verts[px].Position.Y));
bmp.SetPixel(px, py + 2, Convert(verts[px].Position.Z));
}
py += 3;
percent += dp;
log.AppendText("Percent Complete: " + percent + "%\n");
}
// Save The Image
bmp.Save(pathOut, System.Drawing.Imaging.ImageFormat.Png);
log.AppendText("File Saved To - \n" + pathOut);
bmp.Dispose();
}