dwww Home | Show directory contents | Find package

/***********************************************************

  This mel script was written based on the
  MEL How-to by Joey Ponthieux (Video
  Applications Group, NASA Langley Research
  Center). 

  @see

     http://www.ewertb.com/maya/mel/mel_a55.html

 ***********************************************************/

global proc string[] edgeVertexOrder( string $inputEdge, string $inputFace )
{
  string $edgeVertexOrder[];

  string $vertexOrder[];

  // Note: polyListComponentConversion will return the components relative
  //       to the TRANSFORM node.  You may want to add an assertion/conversion
  //       for the input arguments so they are relative to a transform.
  //       If the input arguments are shape-relative then this procedure will FAIL.

  // Get vertex order of face
  string $vtxFace[] = `polyListComponentConversion -fromFace -toVertexFace $inputFace`;

  // Use filterExpand to individualize each .vtxFace component in $vtxFace
  $vtxFace = `filterExpand -sm 70 -expand true $vtxFace`;

  for ( $vf in $vtxFace )
  {
    // Get vertex for this vtxFace
    string $vertex[] = `polyListComponentConversion -fromVertexFace -toVertex $vf`;

    // And append to our result
    $vertexOrder[ size($vertexOrder) ] = $vertex[0];
  }

  // Now, check each vertex pair to see if it matches the specified edge
  for ( $v = 0; $v < size($vertexOrder); $v++ )
  {
    int $nextVtx = ( $v < ( size($vertexOrder) - 1 ) ? $v + 1 : 0 );

    // Use two successive vertices to derive internal edge

    string $edge[] = `polyListComponentConversion -fromVertex -toEdge
                    -internal $vertexOrder[$v] $vertexOrder[$nextVtx]`;

    // Does this match?
    if ( $edge[0] == $inputEdge )
    {
      $edgeVertexOrder[0] = $vertexOrder[$v];
      $edgeVertexOrder[1] = $vertexOrder[$nextVtx];

      // As soon as a match is found we can stop looking.
      break;
    }
  }

  // Warn if $inputEdge not found in $inputFace
  if ( size( $edgeVertexOrder ) == 0 )
    warning ( $inputEdge + " is not part of " + $inputFace );

  return $edgeVertexOrder;
}

Generated by dwww version 1.15 on Thu May 23 05:56:03 CEST 2024.