Support MTL files when exporting OBJ

How to support MTL files when exporting OBJ

Issue: How to support MTL files when exporting OBJ.

Tips: To do this, you can use material file when exporting to OBJ format.Below is an example.Attached are the result files (ColorImage.obj and ColorImage.mtl) and the source file (ColorImage.dwf).

Example:

string fileName = "ColorImage";
string file = string.Format("{0}.dwf", fileName);
string outFile = string.Format("{0}.obj", fileName);
string mtlFileName = string.Format("{0}.mtl", fileName);
using (FileStream inStream = new FileStream(file, FileMode.Open))
using (Image image = Image.Load(inStream))
using (FileStream stream = new FileStream(outFile, FileMode.Create))
using (var mtlStream = new FileStream(mtlFileName, FileMode.Create))
{
ObjOptions options = new ObjOptions();
options.MtlFileName = mtlFileName;
options.MtlFileStream = mtlStream;
options.VectorRasterizationOptions = new CadRasterizationOptions { DrawType = CadDrawTypeMode.UseObjectColor };
image.Save(stream, options);
}