This brief guide describes how to convert OBJ to FBX using Java. It has the details to set the development environment for running the application and improvising it for your needs, and a ready-to-run sample code for changing OBJ to FBX using Java. This sample code does not require any other third-party tool or 3D handling software for this conversion on any of the platforms supporting Java.
Steps to Convert OBJ to FBX using Java
- Set the IDE to add Aspose.3D for Java from the Maven repository for OBJ to FBX transformation
- Load the sample OBJ file in a Scene class object
- Instantiate a FbxSaveOptions class object
- Set the file format in the constructor of the FbxSaveOptions object
- Save the resultant FBX file using the custom settings
These steps summarize the process for converting 3D object to FBX using Java. The process requires loading the source OBJ file into the Scene class as it contains the basic features for the conversion to several formats. The customization of the output FBX file is possible using the FbxSaveOptions class object by setting different properties.
Code to Change OBJ to FBX using Java
import com.aspose.threed.*; | |
public class Main | |
{ | |
public static void main(String[] args) throws Exception // Change OBJ to FBX in Java | |
{ | |
// Set the licenses | |
new License().setLicense("License.lic"); | |
// Load the input OBJ file | |
Scene scene = Scene.fromFile("Aspose3D.obj"); | |
// Initialize the FbxSaveOptions object | |
FbxSaveOptions options = new FbxSaveOptions(FileFormat.FBX7500_BINARY); | |
// Convert OBJ to FBX format | |
scene.save("OBJtoFBX.fbx", options); | |
System.out.println("Done"); | |
} | |
} |
This code segment demonstrates the OBJ to FBX converter using Java. We have used file format FBX7500_BINARY however you may use its ASCII version or other FBX format versions as per your needs. The output FBX file can be customized using different methods in the FbxSaveOptions class, for instance, you may call EmbedTextures(), EnableCompression(), ExportTextures(), FoldRepeatedCurveData(), and GenerateVertexElementMaterial() to enhance the code according to your choice.
This short tutorial has guided us in transforming a file format from OBJ to FBX using Java. If you are interested in learning the reverse conversion i.e. FBX to OBJ, refer to the article on how to convert FBX to OBJ in Java.