我目前正在使用CGAL从闭合网格计算参数化。这是我正在遵循的示例:https://doc.cgal.org/latest/Surface_mesh_parameterization/Surface_mesh_parameterization_2seam_Polyhedron_3_8cpp-example.html
有没有办法用CGAL输出带有uv坐标/纹理贴图的3D网格?例如,在obj文件或ply上。
这似乎是一件很简单的事情,但我找不到一个函数来处理它。
谢谢!
发布于 2020-09-15 15:15:25
CGAL目前没有处理纹理的功能。但是,处理UV属性是可行的。将属性输出到文件的最简单方法是:
CGAL::Surface_mesh
使用简单的属性(双精度、整数等)来存储网格CGAL::write_ply()
写入您的文件例如,如果我运行这段代码:
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh/IO.h>
using Kernel = CGAL::Simple_cartesian<double>;
using Point_3 = Kernel::Point_3;
using Mesh = CGAL::Surface_mesh<Point_3>;
using Vertex_index = Mesh::Vertex_index;
using Halfedge_index = Mesh::Halfedge_index;
using Edge_index = Mesh::Edge_index;
int main()
{
Mesh mesh;
Mesh::Property_map<Edge_index, double> u_map
= mesh.add_property_map<Edge_index, double>("U").first;
Mesh::Property_map<Edge_index, double> v_map
= mesh.add_property_map<Edge_index, double>("V").first;
Vertex_index v0 = mesh.add_vertex(Point_3(0,0,0));
Vertex_index v1 = mesh.add_vertex(Point_3(0,0,1));
Halfedge_index hi = mesh.add_edge (v0, v1);
Edge_index ei = mesh.edge(hi);
u_map[ei] = 0.2;
v_map[ei] = 0.8;
std::ofstream ofile ("out.ply");
CGAL::write_ply (ofile, mesh);
return EXIT_SUCCESS;
}
我得到了以下输出PLY文件,它确实存储了边缘上的UV属性:
ply
format ascii 1.0
comment Generated by the CGAL library
element vertex 2
property double x
property double y
property double z
element face 0
property list uchar int vertex_indices
element edge 1
property int v0
property int v1
property double U
property double V
end_header
0 0 0
0 0 1
1 0 0.2 0.8
https://stackoverflow.com/questions/63888317
复制相似问题