|
|
|
@ -4,29 +4,17 @@ using System.Diagnostics; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Threading; |
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
public class UnityHelper |
|
|
|
|
public class RayHelper |
|
|
|
|
{ |
|
|
|
|
//unity渲染结果(运行前清理) |
|
|
|
|
private static string _image_path = AppDomain.CurrentDomain.BaseDirectory + @"Unity\image\"; |
|
|
|
|
private static string _image_path = AppDomain.CurrentDomain.BaseDirectory + @"Ray\image\"; |
|
|
|
|
//unity渲染模型缓存(运行前清理) |
|
|
|
|
private static string _stl_path = AppDomain.CurrentDomain.BaseDirectory + @"Unity\stl\"; |
|
|
|
|
private static string _stl_path = AppDomain.CurrentDomain.BaseDirectory + @"Ray\"; |
|
|
|
|
//用于存放unity渲染插件(版本发布独立更新) |
|
|
|
|
private static string _unity_path = AppDomain.CurrentDomain.BaseDirectory + @"Unity\core\"; |
|
|
|
|
private static string _unity_path = AppDomain.CurrentDomain.BaseDirectory + @"Ray\core\"; |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* 1、根据模型信息和钻石编码生成签名作为stl文件名(导出:ViewportHelperPro.ExportModelsToStl(null, path+filename)) |
|
|
|
|
* 2、判断同名STL文件是否存在 存在跳到 7 |
|
|
|
|
* 3、 清理Unity下,image、stl两个目录 |
|
|
|
|
* 4、导出模型stl文件,记录完整的路径paramA |
|
|
|
|
* 5、执行导出命令 xx.exe --model=_stl_path+paramA --output=_image_path --type=0/1 0:心图(0.png) 1:箭图(1.png) |
|
|
|
|
* 6、等待命令结束 |
|
|
|
|
* 7、判断图片文件是否存在 --->>不存在:提示生成失败,请重试, --->>不存在并且从2过来的,跳到1 |
|
|
|
|
* 8、展示图片弹窗,并注以说明:心箭图为模拟渲染,实际请以切工镜观测为准。 |
|
|
|
|
* 9、关闭 |
|
|
|
|
* |
|
|
|
|
* 图片展示框左侧展示心图0.png,右侧展示箭图1.png 同时展示在一起 |
|
|
|
|
*/ |
|
|
|
|
public static void GenerateRender(string modelInfo, string diamondCode) |
|
|
|
|
|
|
|
|
|
public static void GenerateRender(string modelInfo, string diamondCode) |
|
|
|
|
{ |
|
|
|
|
string fileName = GenerateSignature(modelInfo, diamondCode); |
|
|
|
|
string fullStlPath = Path.Combine(_stl_path, fileName); |
|
|
|
@ -46,7 +34,6 @@ public class UnityHelper |
|
|
|
|
CleanDirectory(_stl_path); |
|
|
|
|
|
|
|
|
|
// 3. 导出模型为STL |
|
|
|
|
ExportModelsToStl(fullStlPath + ".stl"); |
|
|
|
|
ObjExporter.ExportToObj2(ViewportManager.ViewportTriangle, fullStlPath + ".obj"); |
|
|
|
|
// 4. 执行Unity渲染命令两次 |
|
|
|
|
ExecuteUnityRendering(fileName, 0); // 渲染心图 |
|
|
|
@ -80,9 +67,7 @@ public class UnityHelper |
|
|
|
|
|
|
|
|
|
private static void ExportModelsToStl(string path) |
|
|
|
|
{ |
|
|
|
|
// 模拟模型导出逻辑 |
|
|
|
|
// 调用ViewportHelperPro.ExportModelsToStl(null, path); |
|
|
|
|
// Console.WriteLine("模型已导出为STL: " + path); |
|
|
|
|
|
|
|
|
|
ViewportHelperPro.ExportModelsToStl(null, path); |
|
|
|
|
} |
|
|
|
|
|