UE Mesh Generation and Editing at Runtime
Generate and edit meshes in the Unreal runtime and editor.
UE Mesh
Three types of meshes commonly used in Unreal
UProceduralMeshComponent
Procedural Mesh
UStaticMeshComponent
Static Mesh
USimpleDynamicMeshComponent
Dynamic Mesh
Borrowing what others have summarized, UE4 and UE5 are equally applicable
USimpleDynamicMeshComponent
to support editing of meshes at runtime and in the editor. The new model editing function under UE5 uses this, supports Boolean, supports editing of vertices, edges and faces, and supports extrusion. Output and other geometric operations.
- Hole Filling and Boolean Failure Handling 补洞
- Remeshing
- Mesh Booleans
- Mesh Morphological Operations and Mesh Simplification
- “Solidification” with the Fast Mesh Winding Number
- AABBTree Queries
- Import and Attributes (Combined with third-party libraries to import models in other formats, such as obj, ply, etc.)
UE plug-in
Already used as UE official built-in plug-in
Integrate third-party libraries libigl
to perform complex geometric calculations.
Use libigl to smooth geometry (Laplacian smoothing)
TUniqueFunction<void(FDynamicMesh3&)> UIGLSmoothingTool::MakeMeshProcessingFunction()
{
// make local copies of current settings
int SolveIterations = Properties->Iterations;
float Smoothness = Properties->Smoothness;
// construct compute lambda
auto EditFunction = [Smoothness, SolveIterations](FDynamicMesh3& ResultMesh)
{
Eigen::MatrixXd V; Eigen::MatrixXi F;
iglext::DynamicMeshToIGLMesh(ResultMesh, V, F); // convert FDynamicMesh3 to igl mesh representation
Eigen::SparseMatrix<double> L;
igl::cotmatrix(V, F, L); // Compute Laplace-Beltrami operator L
Eigen::MatrixXd U = V; // smoothed positions will be computed in U
for (int k = 0; k < SolveIterations; ++k)
{
Eigen::SparseMatrix<double> M; // Recompute mass matrix on each step
igl::massmatrix(U, F, igl::MASSMATRIX_TYPE_BARYCENTRIC, M);
const auto& S = (M - Smoothness * L);
Eigen::SimplicialLLT<Eigen::SparseMatrix<double>> solver(S);
U = solver.solve(M * U).eval(); // Solve (M-delta*L) U = M*U
}
iglext::SetVertexPositions(ResultMesh, U); // copy updated positions back to FDynamicMesh3
};
return MoveTemp(EditFunction); // return compute lambda
}
Example of smoothing under the editor:
Other examples
ToolsFrameworkDemo - Unreal Editor DynamicMeshComponent Demo
ToolsFrameworkDemo - Unreal Editor Demo Bool Operator
GitHub related repositories
reference
1、http://www.gradientspace.com/tutorials/2020/10/23/runtime-mesh-generation-in-ue426
2. http://www.gradientspace.com/tutorials/2020/9/21/command-line-geometry-processing-with-unreal-engine
3. https://blog.csdn.net/mrbaolong/article/details/132112714?spm=1001.2014.3001.5501
4. https://blog.csdn.net/mrbaolong/article/details/131543522?spm=1001.2014.3001.5501