In this step-by-step tutorial, we’ll elaborate how to convert FBX to OBJ in C# applications. Converting FBX to OBJ in C# is quite easy using Aspose.3D for .NET. It doesn’t require you to install any third party 3D modeling software either.
Steps to Convert FBX to OBJ in C#
- Install Aspose.3D for .NET package from NuGet.org
- Include Aspose.ThreeD namespace to make the code work
- Set Aspose license to avoid evaluation watermark
- Create a new Scene object
- Open input FBX file which you want to convert
- Save output OBJ file as WavefrontOBJ format
Code to Convert FBX to OBJ in C#
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); | |
} | |
} | |
} |
In the above code, the Scene class basically provides the features to hold a 3D scene or a 3D file and then manipulates the objects in a 3D file format like nodes, textures, sub-scenes, animations etc. It also saves the output file in the required 3D file format. It exposes the methods and properties to excess all the 3D file format objects in your C# code.
This code can be very helpful if you’re trying to add FBX to OBJ converter feature in your own C# or .NET applications. It works seamlessly with console, Windows, and web applications.