Notifications
Clear all

[Closed] Accessing UV Data in MNMesh in C#

Hi,

I am having some difficulty figuring out how to access UV information in an MNMesh. I have the following code:

IMNMapFace fmap = f_map.F(faceIdx);

When I try to get the Vertex array in the fmap I am running into trouble. According to the SDK, the following returns an IntPtr to the array

IPoint3 uvert = f_map.V(the_fmap.Tv[0]);

My problem is the_fmap.Tv portion. I can’t figure out how to get the array of UVs used in the Mapface.

I have tried other routes to access the data including MNMesh.Mv but this can sometimes return the wrong data if the UV is shared among several faces in different locations in the UV map. Basically my C# skills are not good enough to figure out how to access this data.

Does anyone have any tips or a code snippet that shows how to do this?

Thanks

Todd

1 Reply

Here’s how I did it.

IMNMapFace mf = channel.F( f );
int[] ftVerts= new int[ mf.Deg];
Marshal.Copy( mf.Tv, ftVerts, 0, mf.Deg);

I have another question regarding MNMesh.
Can someone show me how to access by pointer MNMesh verts positions?
For IMesh it is as easy as this

public struct Point3
{
        public float X;
        public float Y;
        public float Z;
}
...
Point3* point = (Point3*)mesh.GetTVertPtr( 0 ).Handle; // for TVerts
Point3* p = (Point3*)mesh.Verts[ 0 ].Handle;                     // for Verts positions

this one works good for MNMesh mapverts

Point3* tvert = (Point3*)channel.V_.Handle;

I did try both of these, but it doesn’t seem to return correct values

 Point3* pt  = (Point3*)mnmesh.V_.P.Handle;
 Point3* pt_ = (Point3*)mnmesh.V_.Handle;

OK. Solved.
It turns out that Struct needs two more floats to hold some data.

public struct Point3_
{
        public float X;
        public float Y;
        public float Z;
        public float _flag1;
        public float _flag2;
}