Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maya API - Move CV with Kinect?

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
455 Views, 0 Replies

Maya API - Move CV with Kinect?

Hello, my name is Matías, I’m a student of the University Federico Santa María in Chile. I’m trying to create a plug-in for Autodesk Maya 2013 64bits. The aim of this plug-in is to be able to model objects through the Kinect.

 

In context, with the plug-in you can select the CV of a created object.  To specify you want to move the selected points, the position of selected CV is updated constantly.

 

Here is my problem, when I try to update the position of a selected CV of an object, the result is not displayed on the screen.

 

I have tried many ways without getting any result, as an example:

1) when I do the setPosition the point doesn’t update.

for ( ; !iter.isDone(); iter.next() ){
        iter.getDagPath( mdagPath, mComponent );
        MItSurfaceCV sCvFn( mdagPath, mComponent, true, &stat );
        if ( MS::kSuccess == stat ) {
                for ( ; !sCvFn.isDone(); sCvFn.nextRow() ) {
                      for ( ; !sCvFn.isRowDone(); sCvFn.next() ) {
                              MPoint pto(pHand.posX, pHand.posY, pHand.posZ);
                               sCvFn.setPosition(pto, MSpace::kWorld);
                       }
                }
        }
         sCvFn.updateSurface();
 }

 

 

 

2) in this case, if you iterate over the array newCVS before doing the ‘setCVs’’ you can see the updated points.

But then, when doing “setCVs” and looking for the position in the CV array of the object (doing a getCVs) the position of the modified CV  doesn’t change.

for ( ; !iter.isDone(); iter.next() ){
     stat = iter.getDagPath( mdagPath, mComponent );
     if(stat == MS::kSuccess){
           MFnNurbsSurface surf(mdagPath);
           MItSurfaceCV sCvFn( mdagPath, mComponent, true, &stat );
           MPointArray currentCV;
           surf.getCVs(currentCV, MSpace::kWorld); 
           MPointArray newCVS(currentCV.length(), MPoint::origin);
           newCVS.setLength(currentCV.length());
           for(unsigned i = 0; i < currentCV.length(); i++){
                 newCVS[i] = newCVS[i] + currentCV[i];
           }
           int index;
           if ( MS::kSuccess == stat ) {
               for ( ; !sCvFn.isDone(); sCvFn.nextRow() ) {
                    for ( ; !sCvFn.isRowDone(); sCvFn.next() ) {
                         sCvFn.getIndex(indexU, indexV);
                         int posArray = indexU * surf.numCVsInV() + indexV;
                         index = posArray;
                         MVector diff = MPoint(pHand.posX, pHand.posY,pHand.posZ) - currentCV[posArray];
                         newCVS[posArray] = newCVS[posArray] + diff;
                    }
               }
               surf.setCVs(newCVS, MSpace::kWorld);
               surf.updateSurface();
          }
     }
}

 


 

3) When having CV selected in Maya, I tried to move this points with MEL commands. For this, i use the “MGlobal::executeCommand” function, but still nothing happens.

 

Finally, I changed “executeCommand” to “executeCommandOnIdle”. In this case, the object change correctly but the procedure crashes, perhaps, because this procedure is executed many times per second.

 

I would appreciate if anyone can help me with this problem or knows something about this

Tags (3)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report