สนับสนุนไฟล์ MTL เมื่อทำการส่งออก OBJ
Contents
[
Hide
]วิธีสนับสนุนไฟล์ MTL เมื่อทำการส่งออก OBJ
ปัญหา: วิธีสนับสนุนไฟล์ MTL เมื่อทำการส่งออก OBJ.
เคล็ดลับ: เพื่อทำเช่นนี้ คุณสามารถใช้ไฟล์วัสดุเมื่อทำการส่งออกไปยังรูปแบบ OBJ ด้านล่างเป็นตัวอย่าง ไฟล์ผลลัพธ์ (ColorImage.obj และ ColorImage.mtl) และไฟล์ต้นฉบับ (ColorImage.dwf) แนบไว้
ตัวอย่าง:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |