Develop a cloud-based lightweight FBX to GLB converter in Python.
Overview
GLB format is among the popular 3D file formats for 3D scenes and models. It is the binary version of the GLTF 2.0 file format. It usually includes textures instead of referencing them as external images, and was introduced as an extension to GLTF. Whereas, an FBX file is used to exchange 3D geometry and animation data. It is widely used in film, game, and augmented reality, and virtual reality (AR/VR) development. Also, the FBX file format utilizes a binary format and is highly efficient. Therefore, owing to this fact, we may have a requirement to convert GLB format to FBX format, so in this article, we are going to discuss the steps and related details on how to programmatically convert GLB to FBX in Python.
3D Files Processing API
Aspose.3D Cloud is our REST-based solution for programmatically processing 3D file formats. It enables you to create, modify & convert 3D objects, models & entities (Box, Cylinder, Sphere, Torus, Plane) in desktop, web & cloud-based applications. The API enables you to work with triangulate meshes and allows you to triangulate the whole file or triangulate only part of the 3D scene (specified by OAP) and save it to other supported file formats.
To further facilitate our customers, we have created Aspose.3D Cloud SDK for Python which is a wrapper on top of Aspose.3D Cloud. So the first step is to install the GLB to FBX Python library, which is available for download at PIP and GitHub. Now execute the following command on the command line terminal to install the SDK:
pip install aspose3dcloud
However, in order to directly install Aspose.3D Cloud in Microsoft Visual Studio, enter aspose3dcloud under Packages field in Python Environments window. Then click the Install aspose3dcloud link. See the image below.
Aspose.Cloud Dashboard
In order to get started with Cloud APIs, we need to create an account on Aspose.Cloud dashboard. If you have a GitHub or Google account, simply Sign Up or, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.
GLB to FBX using Python
In this section, we are going to discuss the conversion of GLB files already available in Cloud storage to FBX format using Python code snippet. Please follow the steps given below to accomplish this requirement.
- Firstly, we need to create an instance of ThreeDCloudApi while passing Client ID and Client secret details as arguments.
- Secondly, define input GLB name, output format as FBX and the name of resultant file.
- Lastly, call the post_convert_by_format(…) method of ThreeDCloudApi class to perform the conversion operation.
Convert GLB to FBX using cURL Command
The cURL commands are one of the convenient ways of accessing REST APIs through command prompt. So we can also access Aspose.3D Cloud via cURL command. But first, we need to generate a JWT access token based on client credentials to use this GLB to FBX Python library. Please execute the following command to generate one:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=6185429e-17ce-468d-bb81-a51ac9d96c16&client_secret=73a07e2fb010f559e482d854fe5a8f49" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Please use the following command to convert the GLB file to FBX format and save the output in the Cloud storage.
curl -v -X POST "https://api.aspose.cloud/v3.0/3d/saveas/newformat?name=Wolf-Blender-2.82a.glb&newformat=fbx7200binary&newfilename=Wolf-Blender-Converted.fbx&IsOverwrite=false" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
The sample files used in the above example can be downloaded from Wolf-Blender-2.82a.glb and Wolf-Blender-Converted.fbx.
Conclusion
In this article, we have discussed the details of how we can convert GLB to FBX format using GLB to FBX Python library and through the cURL command. Please note that our SDKs are developed as per an MIT license, so their complete source code is available for download over GitHub. This blog post will surely help you if you are looking to opt for an FBX to GLB converter in your Python project. In addition, there are further relevant articles enlisted in the ‘Explore’ section below that you may check out.
In order to stay informed about recent updates regarding our APIs, you may consider following us on our social media accounts over Facebook, LinkedIn, and Twitter.
Ask a question
Feel free to visit our forum which is very active to respond to questions and queries/discussions.
Explore
We also recommend visiting the following link to learn more about
- Word to JPEG – Convert Word to JPEG in Python
- PDF To DOC Converter – Aspose.PDF Cloud SDKs For Node.js
- How To Convert PDF To PPT in Cloud Using Node.js
- PDF To Excel Using Aspose.PDF Cloud SDKs For Node.js
- HTML To PDF Converter | Aspose.PDF | File Format Converter
- How To Convert PDF File To HTML Using Aspose.PDF Cloud SDKs For Node.js
- Email Sending using Aspose.Email Cloud in Heroku Ruby on Rails