Getting Selected Mesh Data

 
 
 
Posted by:Eikester
Data created:10 February 2011

Hello,

i am working the first time with max.net, can someone give me an example how to get the texcoords if the mesh has more than one uv channel.

Thanks :)

 

Edited 10.02.2011, 23:14

Ok, I have the MapChannels and the Mesh Data but now i have an other "problem"

Mesh.Verts[i] or Mesh.GetVert(i) gives me only the Vertices without Transformation.

 I use

IPoint3 P = node.GetNodeTM(0, interval).Trans;

to get the Position of the Selected Object/Node and add it as an Offset to the Vertex but I dont find any

way to add Scaling and Rotation Transformations, is there an other way or how to get the transformed vertices? o.o

You should transform your vertex using the transform matrix instead of merely translating it. In your case:

IMatrix3 transform = node.GetNodeTM(0, interval);

worldCoordinate = objectCoordinate * transform;

Hope this helps

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Thanks for the Answer

in your example worldCoordinate & objectCoordinate are IPoint3?

mesh.Verts[i] returns IPoint3 and i dont know how to Multiply IPoint3 with IMatrix3

Compilererror: Operator '*' cannot be applied to operands of type 'Autodesk.Max.IPoint3' and 'Autodesk.Max.IMatrix3'

 

I am new in Max.Net, Only used Ogre/MOgre and there I use

vt = (orientation * (vertexposition * scale)) + objectposition (all Vector3 values)

to get the Vertex (vt) Position.

 

Thanks for your help :)

 

 

 

hm, i make some tests and now i wrote the IMatrix3 tm = node.GetNodeTM(0, interval) values to output and it is every time 1 0 0|0 1 0|0 0 1, am i doing something wrong? I also tested GetObjectTM(...) and GetObjTMAfterWSM(...) with same result.

 

here is my code:

node = iface.GetSelNode(0);

List vertices = new List();

if (node.ObjectRef.SuperClassID == SClass_ID.Geomobject)
{
        IMesh mesh = GetObjFromNode(node).Mesh;
        IMatrix3 tm = node.GetNodeTM(0, interval);

       for (int i = 0; i < mesh.Verts.Count; i++)
       {
              Vector3 vt = new Vector3();

              Vector3 vertex = ToVector3(mesh.Verts[i]);
             
Log("Vertex: " + vertex.X.ToString() + " - " + vertex.Y.ToString() + " - " + vertex.Z.ToString());
Log("tm Row 0: " + tm.GetRow(0).X.ToString() + " - " + tm.GetRow(0).Y.ToString() + " - " + tm.GetRow(0).Z.ToString());
Log("tm Row 1: " + tm.GetRow(1).X.ToString() + " - " + tm.GetRow(1).Y.ToString() + " - " + tm.GetRow(1).Z.ToString());
Log("tm Row 2: " + tm.GetRow(2).X.ToString() + " - " + tm.GetRow(2).Y.ToString() + " - " + tm.GetRow(2).Z.ToString());

         vt = vertex * tm;

         vertices.Add(vt);

       }

}

 

Solved now, my fault.

I get the Mesh from ITriObject wich is an Editable Mesh, but I used Editable Poly Embarassed

also I wrote an operator to multiply IPoint3 with IMatrix3, used GetObjectTM(...) and finaly add node.GetObjectTM(...).trans;

IMatrix3 tm = node.GetObjectTM(0, interval);
IPoint3 vt = mesh.Verts[i] * tm + node.GetObjectTM(0, interval).Trans;

now it gives me the result that i want. works perfect :)

Thanks

Great to see that you worked it out :)

Marsel Khadiyev (Software Developer, EPHERE Inc.)