Hi!
I’d like to get all face indexes related to particular vertex.
Is there anything I’m missing? Maybe some unsafe pointer magic?
static public int[] GetPolyVertFacesTab( )
{
var global = GlobalInterface.Instance;
IPolyObject pobj = (IPolyObject)global.COREInterface7.GetSelNode( 0 ).EvalWorldState( 0, false ).Obj;
IMNMesh mesh = pobj.Mesh;
uint MN_MESH_FILLED_IN = 1 << 1;
if ( mesh.GetFlag( MN_MESH_FILLED_IN ) )
{
// mesh is filled in so all vert-faces data should be in place
int[] vert_faces = new int[ mesh.Vfac.Count ];
// according to c++ sdk it should be accessible like this
// mesh.Vfac[ vert_index ][ j ]
// but when accessed like this mesh.Vfac[ vert_index ] returns integer value instead of Tab
// ;(
// thus only the first vert-faces are available which makes Vfac unusable
Marshal.Copy( mesh.Vfac.Addr( (IntPtr)0 ), vert_faces, 0, mesh.Vfac.Count );
return vert_faces;
}
else
{
return new int[] { };
}
}
C++ sdk
for (int j=0; j<mm.vfac[i].Count(); j++) {
int fj = mm.vfac[i][j];
// For each triangle using this vertex:
Tab<int> tri;
Point3 fnorm = mm.GetFaceNormal (fj, true);
mm.f[fj].GetTriangles (tri);
...