how to save color using vcglib?

拜拜、爱过 提交于 2019-12-21 21:37:20

问题


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");

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!


回答1:


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);

I hope that helps.



来源:https://stackoverflow.com/questions/26457813/how-to-save-color-using-vcglib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!