//- // ========================================================================== // Copyright (C) 1995 - 2005 Alias Systems Corp. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files are provided by Alias // Systems Corp. ("Alias") and/or its licensors for the exclusive use of the // Customer (as defined in the Alias Software License Agreement that // accompanies this Alias software). Such Customer has the right to use, // modify, and incorporate the Data into other products and to distribute such // products for use by end-users. // // THE DATA IS PROVIDED "AS IS". ALIAS HEREBY DISCLAIMS ALL WARRANTIES // RELATING TO THE DATA, INCLUDING, WITHOUT LIMITATION, ANY AND ALL EXPRESS OR // IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. IN NO EVENT SHALL ALIAS BE LIABLE FOR ANY DAMAGES // WHATSOEVER, WHETHER DIRECT, INDIRECT, SPECIAL, OR PUNITIVE, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, OR IN EQUITY, // ARISING OUT OF ACCESS TO, USE OF, OR RELIANCE UPON THE DATA. // ========================================================================== //+ // // File: flipUVCmd.cpp // // MEL Command: flipUV // #include #include #include #include #include #include #include // Flags for this command static const char * horizFlag = "-h"; static const char * horizFlagLong = "-horizontal"; static const char * globalFlag = "-fg"; static const char * globalFlagLong = "-flipGlobal"; static const char * extendFlag = "-es"; static const char * extendFlagLong = "-extendToShell"; const char * flipUVCmd::cmdName = "flipUV"; // /////////////////////////////////////////////////////////////////////////////// flipUVCmd::flipUVCmd() : horizontal(false), extendToShell(false), flipGlobal(false) {} // /////////////////////////////////////////////////////////////////////////////// flipUVCmd::~flipUVCmd() {} // // Method to create a flipUVCmd object /////////////////////////////////////////////////////////////////////////////// void *flipUVCmd::creator() { return new flipUVCmd; } // // Add additionnal flags for this command. The default setting of the // syntax is done in the base class. /////////////////////////////////////////////////////////////////////////////// MSyntax flipUVCmd::newSyntax () { MStatus status; // Get the base class syntax, and append to it. MSyntax syntax = MPxPolyTweakUVCommand::newSyntax(); status = syntax.addFlag(horizFlag, horizFlagLong, MSyntax::kBoolean); CHECK_MSTATUS_AND_RETURN(status, syntax); status = syntax.addFlag(globalFlag, globalFlagLong, MSyntax::kBoolean); CHECK_MSTATUS_AND_RETURN(status, syntax); status = syntax.addFlag(extendFlag, extendFlagLong, MSyntax::kBoolean); CHECK_MSTATUS_AND_RETURN(status, syntax); return syntax; } // // Read the values of the additionnal flags for this command. /////////////////////////////////////////////////////////////////////////////// MStatus flipUVCmd::parseSyntax (MArgDatabase &argData) { MStatus status; // Get the flag values, otherwise the default values are used. if (argData.isFlagSet(horizFlag)) { status = argData.getFlagArgument(horizFlag, 0, horizontal); CHECK_MSTATUS_AND_RETURN_IT(status); } if (argData.isFlagSet(globalFlag)) { status = argData.getFlagArgument(globalFlag, 0, flipGlobal); CHECK_MSTATUS_AND_RETURN_IT(status); } if (argData.isFlagSet(extendFlag)) { status = argData.getFlagArgument(extendFlag, 0, extendToShell); CHECK_MSTATUS_AND_RETURN_IT(status); } return MS::kSuccess; } // // Change the UVS for the given selection on this mesh object. // /////////////////////////////////////////////////////////////////////////////// MStatus flipUVCmd::getTweakedUVs( const MFnMesh & mesh, // Object MIntArray & uvList, // UVs to move MFloatArray & uPos, // Moved UVs MFloatArray & vPos ) // Moved UVs { MStatus status; unsigned int i; MFloatArray uArray; MFloatArray vArray; // Read all UVs from the poly object status = mesh.getUVs(uArray, vArray); CHECK_MSTATUS_AND_RETURN_IT(status); unsigned int nbUvShells = 1; MIntArray uvShellIds; if ((!flipGlobal) || extendToShell) { // First, extract the UV shells. status = mesh.getUvShellsIds(uvShellIds, nbUvShells); CHECK_MSTATUS_AND_RETURN_IT(status); } if (extendToShell) { // Find all shells that have at least a selected UV. bool *selected = new bool[nbUvShells]; for (i = 0 ; i minMax[4*shellId+2]) minMax[4*shellId+2] = uArray[indx]; if (vArray[indx] > minMax[4*shellId+3]) minMax[4*shellId+3] = vArray[indx]; } // Adjust the size of the output arrays uPos.setLength(uvList.length()); vPos.setLength(uvList.length()); for (i = 0 ; i