无法使用 vcglib 简化 3D 模型,断言“0"失败 [英] Failed to to simplify 3D models with vcglib, Assertion `0' failed

查看:29
本文介绍了无法使用 vcglib 简化 3D 模型,断言“0"失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 vcglib 来简化 3D 模型文件.我使用了 master_a8e87662 git repo.我运行 sample trimesh_clustering 以简化plf 文件格式的 3D 模型,

I used vcglib to simplify 3D model file. I used the master_a8e87662 git repo. I run the sample trimesh_clustering to simplify a plf file format 3D model with this,

 ./trimesh_clustering ./Zeus.ply out.ply -k 1000

并得到这个错误,

Input mesh  vn:152059 fn:304114
Clustering to 95472 cells
Grid of 51 x 26 x 72 cells
with cells size of 0.48 x 0.49 x 0.48 units
trimesh_clustering: vcglib/vcg/simplex/vertex/component.h:75: vcg::vertex::EmptyCore<TT>::ColorType& vcg::vertex::EmptyCore<TT>::C() [with TT = MyUsedTypes; vcg::vertex::EmptyCore<TT>::ColorType = vcg::Color4<unsigned char>]: Assertion `0' failed.

形成问题,我猜可能是ply文件中的颜色引起的,所以我使用没有颜色的ply文件,

Form the issue, I guess it may caused by the Color in the ply file, So I use ply file without color like this,

ply
format ascii 1.0
comment VCGLIB generated
element vertex 152059
property float x
property float y
property float z
element face 304114
property list uchar int vertex_indices
end_header
-6.17266 0.227923 17.2279
-6.21338 0.633413 26.6069
2.48586 -2.95844 27.9508
1.00704 -3.94445 24.3854

和这样的颜色的ply文件,

and ply file with color like this,

ply
format ascii 1.0
comment VCGLIB generated
element vertex 152059
property float x
property float y
property float z
property int flags
property uchar red
property uchar green
property uchar blue
property uchar alpha
element face 304114
property list uchar int vertex_indices
end_header
-6.17266 0.227923 17.2279 0 192 192 192 255
-6.21338 0.633413 26.6069 0 192 192 192 255
2.48586 -2.95844 27.9508 0 192 192 192 255
1.00704 -3.94445 24.3854 0 192 192 192 255
-0.337305 -4.75996 27.4304 0 192 192 192 255

但都没有成功.

推荐答案

受这个 Stackoverflow 问题的启发 如何使用 vcglib 保存颜色?这个答案,我通过替换为顶点添加 Color4b 属性

Inspired by this Stackoverflow question how to save color using vcglib? and this answer, I add the Color4b attribute for the vertex by replace

class MyVertex  : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags  >{};

class MyVertex  : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags, vcg::vertex::Color4b >{};

trimesh_clustering.cpp 文件中.然后编译运行代码,就可以了.

in the trimesh_clustering.cpp file. Then compile and run the code, it works.

这篇关于无法使用 vcglib 简化 3D 模型,断言“0"失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆