View Full Version : Maya API question N2
10-24-2003, 10:03 PM
Hello. This is my second question about maya's api.
First of all - sorry for my English. But i'll try to explain my problem.
I'll ask it in abstract terms, because it's general problem.
In my case i want to get some points from original mesh (poly) and create new object from these points using MEL via Global::executeCommand. My problem is that this new object created always in the center (0,0,0), and, as i can understand, without any transformations, that was aplied to original object (so points are in "wrong" positions).
I don't understand the main thing: when i get points from original object (i do it in k::World space), I though, that i have its "final" positions, but as i can see - it is not, i have "not real" positions of the points. Positions without any transformations, that was applied to original mesh.
Question is: how can i get "real" (or "final" or "after all transformations") positions of the points of the mesh?
(i thought that when i use k::World, i get it, but it isn't true :cry: ).
I hope that my text doesn't look like crazy with this "real" positions and e.t.c. :)
Hi tosich, good to see you're still at it.
Use "MitMeshVertex:: position(...)" to get your points locations after transforms. See the api docs for how to use it, and cvPosCmd.cpp in the devkit/plugins for the example.
10-26-2003, 09:10 AM
I have a small problem with your solution.
I have a MIntArray, that contains vertex indexes, which i need. As I can understand MitMeshVertex iterates over all vertexes in a mesh, so if i want to use this way I have to interate over all vertexes and check them if they are containing in my array, and only then use position() method.
Before, I used MFnMesh::getPoint(), that can works with indexes (that is good in my case), and i used kWorld space there, but as I wrote - points stay in wrong position. :(
pointFn.getPoint(points[i], point1, MSpace::kWorld);
What do you think?
Thank you very much, that you are replying!!! you are only one who do it. please don't leave me. :)
10-26-2003, 10:35 AM
Please look at here:
i use (for example) such strings to get positions of some points of simple cube
(i've created poly-cube, and then just moved it to new position):
for (int m=0; m<points.length(); m++)
pointFn.getPoint(points[m], point1, MSpace::kWorld);
MGlobal::displayInfo (MString ("point ")+m+": "+ "x " +point1.x + ", y " +point1.y + ", z " +point1.z);
(i used your MItMeshVertex :: position() too, but results were the same.)
// point 0: x -0.5, y -0.5, z 0.5
// point 1: x 0.5, y -0.5, z 0.5
// point 2: x 0.5, y -0.5, z -0.5
// point 3: x 0.5, y 0.5, z -0.5
// point 4: x 0.5, y 0.5, z 0.5
// point 5: x -0.5, y 0.5, z 0.5
// point 6: x -0.5, y -0.5, z 0.5
but if you look at picture, you'll see that it's not true.
How can i get real (final) positions of the points of this cube?
I see the problem now. You need to get your object relative to the dag path. A shape by itself doesn't have the transform. (See the MDagPath docs.) Here's an example.
for (int i=0; i<pa.length(); i++)
MGlobal::displayInfo (MString ("point ") + i + ": "+ "x " + pa[i].x + ", y " + pa[i].y + ", z " + pa[i].z);
10-26-2003, 10:20 PM
Thank you so much!
I undertsand the problem!
Please look at my third question if you have time.
01-16-2006, 12:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.