如何在 C# 中将 FBX 转换为 OBJ

在这个分步教程中,我们将详细说明如何在 C# 应用程序中将 FBX 转换为 OBJ。使用 Aspose.3D for .NET 在 C# 中将 FBX 转换为 OBJ 非常容易。它也不需要您安装任何第三方 3D 建模软件。

在 C# 中将 FBX 转换为 OBJ 的步骤

  1. 从 NuGet.org 安装 Aspose.3D for .NET
  2. 包含 Aspose.ThreeD 命名空间以使代码正常工作
  3. 设置 Aspose 许可证以避免评估水印
  4. 创建一个新的 Scene 对象
  5. 打开要转换的输入 FBX 文件
  6. 将输出 OBJ 文件保存为 WavefrontOBJ 格式

在 C# 中将 FBX 转换为 OBJ 的代码

using System;
//Add reference to Aspose.3D for .NET API
//Use following namespaces to convert FBX File Format to OBJ Format
using Aspose.ThreeD;
namespace ConvertFBXToOBJFileFormat
{
class Program
{
static void Main(string[] args)
{
//Set Aspose license before converting FBX to OBJ
//using Aspose.3D for .NET
Aspose.ThreeD.License Aspose3DLicense = new Aspose.ThreeD.License();
Aspose3DLicense.SetLicense(@"c:\asposelicense\license.lic");
//Create a object of type 3D Scene to hold and convert FBX file
Scene FBX3DScene = new Scene();
FBX3DScene.Open("InputFBX3DSceneFileFormat.fbx");
//Save the output as Wavefront OBJ 3D file format
FBX3DScene.Save("OutputWaveFrontOBJFileFormat.obj", FileFormat.WavefrontOBJ);
}
}
}

在上面的代码中,Scene 类基本上提供了保存 3D 场景或 3D 文件的功能,然后操作 3D file format 中的对象,如节点、纹理、子场景、动画等。它还保存输出所需的 3D 文件格式的文件。它将方法和属性暴露给 C# 代码中的所有 3D 文件格式对象。

如果您尝试在自己的 C# 或 .NET 应用程序中添加 FBX 到 OBJ 转换器功能,此代码会非常有用。它与控制台、Windows 和 Web 应用程序无缝协作。

 简体中文