UE Mesh Generation and Editing at Runtime
虚幻运行时和编辑器下生成和编辑 网格体。
UE Mesh
虚幻中常用的三种网格体
UProceduralMeshComponent
程序化网格体
UStaticMeshComponent
静态网格体
USimpleDynamicMeshComponent
动态网格体
借用他人总结的,UE4和UE5同样适用
USimpleDynamicMeshComponent
支持运行时和编辑器下对网格体的编辑,UE5下新增的模型编辑功能使用的就是这个,支持布尔,支持编辑顶点、边和面,支持挤出等等几何操作。
- 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 (结合第三方库导入其他格式的模型,如obj,ply等等)
UE 插件
已经作为UE官方自带插件
集成第三方库libigl
,可进行复杂的几何计算。
使用libigl对几何进行平滑操作(拉普拉斯平滑)
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
}
编辑器下平滑示例:
其他示例
ToolsFrameworkDemo - Unreal Editor DynamicMeshComponent Demo
ToolsFrameworkDemo - Unreal Editor Demo Bool Operator
GitHub相关仓库
参考
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