You can split all meshes of a 3D scene into several sub-meshes. Likewise, you can merge multiple meshes into a single mesh programmatically using C#. This article covers the splitting and merging of 3D meshes in different scenarios:
- 3D Scene Meshes Splitter or Merger – C# API Installation
- Split Meshes of a Scene Per Material Programmatically using C#
- Split a Mesh by a Specific Material Programmatically using C#
- Merge Meshes in a 3D file into a Single Mesh Programmatically in C#
3D Scene Meshes Splitter or Merger – C# API Installation
Aspose.3D for .NET API can be used to split or merge 3D meshes programmatically using C#. You can configure the API by installing it from the Downloads section, or with the below NuGet installation command:
PM> Install-Package Aspose.3D
Split Meshes of a Scene Per Material Programmatically using C#
A 3D file like the FBX format can contain several meshes of a scene. You can split all meshes into several sub meshes per material if the mesh has not been assigned a single material. Please follow the steps below for splitting meshes of a scene per material:
- Load input 3D file.
- Split all meshes with the SplitMesh method.
- Save output file with the splitted meshes.
The following code shows how to split meshes of a scene per material programmatically using C#:
Split a Mesh by a Specific Material Programmatically using C#
You can split a mesh by manually specifying the material. In this way, you can create several objects containing only one material. For demonstration purposes, the below code creates a mesh of a box with 6 planes. Then you will split a primitive mesh by manually specifying the material using the following steps:
- Create a mesh of a box with six planes.
- Secondly, create a material element and specify indexes for each plane.
- Split the Mesh using SplitMeshPolicy enumeration.
The code below explains how to split a mesh by specific material programmatically using C#:
Merge Meshes in a 3D file into a Single Mesh Programmatically in C#
You can merge different meshes into a single valid mesh with the below steps:
- Load input 3D scene file.
- Merge all meshes.
- Finally, encode the merged mesh.
The following code elaborates how to merge meshes into a single mesh programmatically using C#:
Get Free Temporary License
You can get a Free Evaluation License for testing the API without any limitations.
In conclusion, you have learned how to merge or split a mesh of a 3D scene. The API exposes different methods for splitting or merging one or multiple meshes, which you can utilize as per your requirements. Moreover, please feel free to visit the Documentation where several other features are also explained. Please contact us at the Free Support Forum in case of any queries.