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

查看:116
本文介绍了如何使用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没有颜色,而源图层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天全站免登陆