如何使用vcglib保存颜色? [英] how to save color using vcglib?

查看:34
本文介绍了如何使用vcglib保存颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 vcglib 保存顶点的颜色,但失败了.即使我不做任何操作就读入并保存了文件,原始文件的颜色也会丢失.这是我写的代码:

I'm trying to save color of vertices using vcglib but failed. Even if I read a file in and save it out without doing anything, the color of the original file is lost. Here is the code I wrote:

vcg::tri::io::ImporterPLY<MyMesh>::Open(*srcMesh,"bunny.ply");   
vcg::tri::io::ExporterPLY<MyMesh>::Save(*srcMesh,"out.ply");

这样做后,out.ply 没有颜色,而源 ply bunny.ply 有.有人可以给我一些示例代码来完成这件事吗?谢谢!

After doing this, out.ply has no color while the source ply bunny.ply does. Could anybody give me some sample code to make this thing done? Thank you!

推荐答案

几周前我遇到了完全相同的问题.在调试器上花了一些时间并浏览了大量源代码后,我发现 open 和 save 方法需要共享一个 int 掩码.这允许 Open 方法传达已从原始网格中读取的属性(另外,请确保已将 Colour4b 属性添加到网格定义中.

I had the exact same problem a couple of weeks ago. After spending some time with the debugger and browsing through lots of source code, I discovered that the the open and save methods need to share an int mask. This allows the Open method to convey which attributes have been read from the original mesh (Also, make sure you've added the Colour4b attribute to your mesh definition.

int mask=0;
vcg::tri::io::ImporterPLY<MyMesh>::Open(*srcMesh,"bunny.ply",mask);   
vcg::tri::io::ExporterPLY<MyMesh>::Save(*srcMesh,"out.ply",mask);

希望能帮到你.

这篇关于如何使用vcglib保存颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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