在运行时将网格转换为stl/obj/fbx

编程入门 行业动态 更新时间:2024-10-28 00:28:28
本文介绍了在运行时将网格转换为stl/obj/fbx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找一种在运行时将网格导出为stl/obj/fbx格式并将其保存在Android手机的本地文件中的方法.

I am looking for a way to export a mesh into stl/obj/fbx format at runtime and save it on local files of an Android phone.

我该怎么做?我愿意使用免费/付费的插件(如果存在).

How do I do this? I am willing to use a plugin(free/paid) if it exist.

推荐答案

这真的很复杂,因为您必须阅读每种格式(stl/obj/fbx)的规范并理解它们才能自己制作.幸运的是,已经有很多插件可用于将Unity mesh导出到stl,obj和fbx.

This is really complicated since you have to read the specifications for each each format (stl/obj/fbx) and understand them in order to make one yourself. Luckily, there are many plugins out there already that can be used to export Unity mesh to stl, obj and fbx.

FBX :

UnityFBXExporter 用于在运行时将Unity网格导出到fbx

UnityFBXExporter is used to export Unity mesh to fbx during run-time.

public GameObject objMeshToExport; void Start() { string path = Path.Combine(Application.persistentDataPath, "data"); path = Path.Combine(path, "carmodel"+ ".fbx"); //Create Directory if it does not exist if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } FBXExporter.ExportGameObjToFBX(objMeshToExport, path, true, true); }

OBJ :

对于obj,使用 ObjExporter .

For obj, ObjExporter is used.

public GameObject objMeshToExport; void Start() { string path = Path.Combine(Application.persistentDataPath, "data"); path = Path.Combine(path, "carmodel" + ".obj"); //Create Directory if it does not exist if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } MeshFilter meshFilter = objMeshToExport.GetComponent<MeshFilter>(); ObjExporter.MeshToFile(meshFilter, path); }

STL :

您可以将 pb_Stl 插件用于STL格式.

You can use the pb_Stl plugin for STL format.

public GameObject objMeshToExport; void Start() { string path = Path.Combine(Application.persistentDataPath, "data"); path = Path.Combine(path, "carmodel" + ".stl"); Mesh mesh = objMeshToExport.GetComponent<MeshFilter>().mesh; //Create Directory if it does not exist if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } pb_Stl.WriteFile(path, mesh, FileType.Ascii); //OR pb_Stl_Exporter.Export(path, new GameObject[] { objMeshToExport }, FileType.Ascii); }

更多推荐

在运行时将网格转换为stl/obj/fbx

本文发布于:2023-11-12 07:53:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580931.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   转换为   时将   fbx   obj

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!