How to work with MeshLab's mesh
2011-05-13 21:42
483 查看
The next step is to understand how mesh works in MeshLab. MeshLab's defines a CMeshO class.
A CMeshO is a collection of vertices and triangular faces. A Face is (mainly) a three pointers structure to vertices that composed it. Every vertex could be referred by zero, one or more faces.
A Vertex is (mainly) a class composed by a 3d point in space, a vertex- normal, a color and a 2d texture coordinates.
WARNING!!! to use vertex-texture coordinates you MUST first enable it, otherwise your plugin will crash!
You will find all the vertices in an c++ vector called vert, the edgess in a vector called edge and the faces in a vector called
face.
Tipically a MeshLab plugin's function has a
MeshModel parameter. A MeshModel contains a CMeshO you could refer to this instance via the cm MeshModel's member. In other words supposing you have a function with a MeshModel parameter called mymesh you
could access to CMeshO vertices with:
with:
and with:
vcglib also provides a way to simply and safely add and remove faces or vertices from a mesh.
The add functions are defined in the vcglib/vcg/complex/trimesh/allocate.h .
To enable texture coordinates per vertex (or for example quality for vertex) you MUST call the function:
to test if the attribute is already enabled:
Please note that you could use also a combination of attributes:
If you need more detailed info about MeshLab/VCGLib mesh you could take a look to
this link.
A CMeshO is a collection of vertices and triangular faces. A Face is (mainly) a three pointers structure to vertices that composed it. Every vertex could be referred by zero, one or more faces.
A Vertex is (mainly) a class composed by a 3d point in space, a vertex- normal, a color and a 2d texture coordinates.
WARNING!!! to use vertex-texture coordinates you MUST first enable it, otherwise your plugin will crash!
You will find all the vertices in an c++ vector called vert, the edgess in a vector called edge and the faces in a vector called
face.
Tipically a MeshLab plugin's function has a
MeshModel parameter. A MeshModel contains a CMeshO you could refer to this instance via the cm MeshModel's member. In other words supposing you have a function with a MeshModel parameter called mymesh you
could access to CMeshO vertices with:
mymesh.cm.vert[ii]; //ii is an unsigned int index to a particular vertex in the mesh
with:
mymesh.cm.face[ii]; //you can access to the ii face
and with:
mymesh.cm.face[ii].v(jj); //you will get the pointer to the jj vertex ( 0 <= jj < 3) in the ii face
vcglib also provides a way to simply and safely add and remove faces or vertices from a mesh.
vcg::tri::Allocator<CMeshO>::AddVertex(mymesh.cm,new vertex to be added); vcg::tri::Allocator<CMeshO>::AddFace(mymesh.cm,new face to be added);
The add functions are defined in the vcglib/vcg/complex/trimesh/allocate.h .
To enable texture coordinates per vertex (or for example quality for vertex) you MUST call the function:
mymesh.updateDataMask(MeshModel::MM_VERTTEXCOORD);
to test if the attribute is already enabled:
mymesh.hasDataMask(MeshModel::MM_VERTTEXCOORD);
Please note that you could use also a combination of attributes:
mymesh.updateDataMask(MeshModel::MM_VERTTEXCOORD | MeshModel::MM_FACEQUALITY);
If you need more detailed info about MeshLab/VCGLib mesh you could take a look to
this link.
相关文章推荐
- Visual C++ Debugging: How to use 'ASSERT' and deal with assertions failures?
- A Static Mesh Maya Exporter & Irrlicht Mesh Viewer – How to write Maya Plugin with c++
- How to control your dust collection with an Arduino (it's easy)
- how to solve Error cannot add duplicate collection entry of type add with unique key attribute 'valu
- How do I add an integer value with javascript (jquery) to a value that's returning a string?
- This client is too old to work with working copy '...'
- SVN 报错:svn: E155021: This client is too old to work with the working copy at..... (format '31').
- is too old (format 29) to work with client version '1.8.9 (r1591380)' (expects format 31).
- How to deal with ptxas : fatal error : Unresolved extern function 'cudaGetParameterBuffer'
- How to eliminate the compile error "conversion from 'double ' to 'float ', possible loss of data"
- How to resolve '_DllMain@12 already defined in xxx.obj' ?
- ABAP--How to use Number Ranges' Function?
- No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/tx_search_friend
- IOS: How to authenticate the GKLocalPlayer on my 'third party server'.
- How to troubleshoot 'Procedure or function has too many arguments specified' in asp.net 2.0
- How To Find User's SIDs in windows
- RVM is not a function, selecting rubies with 'rvm use ...' will not work.
- [git] HOWTO work with git flow
- The reference to entity "characterEncoding" must end with the ';' delimiter
- Android中String.xml: The reference to entity "timestamp" must end with the ';' delimiter