点云技术相关产学研社区

 找回密码
 立即注册加入PCL中国点云技术相关产学研社区

扫一扫,访问微社区

查看: 11123|回复: 3

PCL纹理映射实现方法

[复制链接]
发表于 2013-12-23 13:44:13 | 显示全部楼层 |阅读模式
准备一个obj文件,内容如下:
####
# OBJ dataFile simple version. File name: triangles.obj
# Vertices: 4
# Faces: 2
####
# List of Vertices, with (x,y,z) coordinates, w is optional.
v 0.0 0.0 0.0
v 10.0 0.0 0.0
v 10.0 10.0 0.0
v 0.0 10.0 0.0
# 4 vertices
# Face Definitions
f 1 2 3
f 1 3 4
# End of File

加载obj文件代码
#include <pcl/io/vtk_lib_io.h>
pcl::PolygonMesh triangles;
pcl::io::loadPolygonFileOBJ("triangles_test.obj", *triangles);

使用pcl::visualization::PCLVisualizer* viewer显示PolygonMesh代码
viewer->addPolygonMesh(*triangles);


生成TextureMesh模型
pcl::TextureMeshPtr nvmMesh_(new pcl::TextureMesh());//带纹理的三维模型
nvmMesh_->cloud = triangles_->cloud;
nvmMesh_->header = triangles_->header;
nvmMesh_->tex_polygons.push_back(triangles_->polygons);
std::vector< Eigen::Vector2f > texcoord;
texcoord.push_back(Eigen::Vector2f(0.0,0.0));
texcoord.push_back(Eigen::Vector2f(1.0,0.0));
texcoord.push_back(Eigen::Vector2f(1.0,1.0));
texcoord.push_back(Eigen::Vector2f(0.0,1.0));
nvmMesh_->tex_coordinates.push_back(texcoord);
pcl::TexMaterial tex_material;
tex_material.tex_file = std::string("F:\\Develop\\examples\\111.jpg");
tex_material.tex_name = std::string("111.jpg");
nvmMesh_->tex_materials.push_back(tex_material);

使用pcl::visualization::PCLVisualizer* viewer显示TextureMesh代码
viewer->addTextureMesh(*nvmMesh_);

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册加入PCL中国点云技术相关产学研社区

x
回复

使用道具 举报

发表于 2015-12-7 17:00:30 | 显示全部楼层
addTextureMesh函数可以使用???PCL里没定义呵

点评

LWQ
你好,在吗?请问一下纹理映射弄出来了吗?  发表于 2016-4-15 16:25
回复 支持 反对

使用道具 举报

发表于 2016-4-29 18:39:10 | 显示全部楼层
为什么我使用addtexturemesh之后,还是贴不上图片呢?
回复 支持 反对

使用道具 举报

发表于 2018-1-10 11:32:10 | 显示全部楼层
LWQ 发表于 2016-4-29 18:39
为什么我使用addtexturemesh之后,还是贴不上图片呢?

问题解决没,我也想知道怎么弄
回复 支持 反对

使用道具 举报

本版积分规则

QQ|小黑屋|点云技术相关产学研社区 ( 陕ICP备13001629号 )

GMT+8, 2024-4-20 21:39 , Processed in 1.874466 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表