首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CGAL输出参数化网格

CGAL输出参数化网格
EN

Stack Overflow用户
提问于 2020-09-15 00:27:47
回答 1查看 122关注 0票数 0

我目前正在使用CGAL从闭合网格计算参数化。这是我正在遵循的示例:https://doc.cgal.org/latest/Surface_mesh_parameterization/Surface_mesh_parameterization_2seam_Polyhedron_3_8cpp-example.html

有没有办法用CGAL输出带有uv坐标/纹理贴图的3D网格?例如,在obj文件或ply上。

这似乎是一件很简单的事情,但我找不到一个函数来处理它。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2020-09-15 15:15:25

CGAL目前没有处理纹理的功能。但是,处理UV属性是可行的。将属性输出到文件的最简单方法是:

例如,如果我运行这段代码:

代码语言:javascript
运行
复制
#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属性:

代码语言:javascript
运行
复制
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 
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63888317

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档