// // PoseMan v 1.3.3 // Modify this at your own risk // // Updated at: 03/11/2009 // // Description: // This script create a tool to manage character poses // Install: // Copy poseMan.mel into /user/documents/maya/version/scripts, /user/documents/maya/scripts or whatever path that include MAYA_SCRIPT_PATH environment // Use: // type poseMan in maya command line and press enter. // // Tested just on windows xp // // // Contact // hisconer@gmail.com // // Blog // http://inartx.com/poseman/ // // Scripting tips // // Load character by mel (req: poseman opened) // openCharacter_pm "characterPath" // Create new character by mel: // newCharacter_pm "characterPath" "characterName" "section1 section2 section3" // ----------------- // Init PoseMan proc // ----------------- global proc poseMan () { global string $POSEMAN_LOGO; // *********************************** // POSEMAN LOGO // *********************************** $POSEMAN_LOGO = "C:/Documents and Settings/francis.vega/Mis documentos/maya/2009/prefs/icons/poseMan.bmp"; global int $gCharacterImage; global string $gCurrentChar; $gCurrentChar = ""; // Borramos todas las posibles ventanas if (`window -exists newCharacterWindow`) deleteUI newCharacterWindow; if (`window -exists newSectinWindow`) deleteUI newSectinWindow; if (`window -exists selectCharacterWindow`) deleteUI selectCharacterWindow; if (`window -exists characterWindow`) deleteUI characterWindow; if (`window -exists poseListWindow`) deleteUI poseListWindow; if (`window -exists sectionWindow`) deleteUI sectionWindow; if (`window -exists capturePoseWindow`) deleteUI capturePoseWindow; if (`window -exists aboutPoseManWindow`) deleteUI aboutPoseManWindow; if (`window -exists renameCharacterWindow`) deleteUI renameCharacterWindow; if (`window -exists renamePoseWindow`) deleteUI renamePoseWindow; if (`window -exists renameSectionWindow`) deleteUI renameSectionWindow; if (`window -exists cleanModeWindow`) deleteUI cleanModeWindow; if (`window -exists newSectionWindow`) deleteUI newSectionWindow; if (`window -exists reorderWindow`) deleteUI reorderWindow; if (`window -exists movePoseWindow`) deleteUI movePoseWindow; if (`window -exists sliderMixPoseWindow`) deleteUI -window sliderMixPoseWindow; // Iniciamos poseman sin personajes $gCharacterImage = 1; poseManProc; } // --------------------- // PoseMAN Main proccess // --------------------- global proc poseManProc () { global string $poseMAN_version; global string $poseMAN_UI_title; $poseMAN_UI_title = "PoseMAN 1.3.3"; // PoseMAN main window if (`window -exists poseManWindow`) { deleteUI -window poseManWindow; } // PoseMAN Window window -menuBar 1 poseManWindow; global string $POSEMAN_LOGO; global int $gCurrentTabId; global int $gCharCount; global int $gCharacterImage; global int $gSizeableFlag; global string $poseMAN_version; global string $poseMAN_UI_title; global string $gIconsPath; global string $gPoseFile; global string $gLogoFile; global string $gCharFile; global string $gCurrentChar; global string $gCurrentCharPath; global string $gMainLayout; global string $gProjectURL; global string $gTabs; global string $gCurrentCharNamespace; global string $imgExtension; global string $PoseMANActive; global string $gSetKeyOnPose; global string $keyOnPoseLayout; global string $showHideCharacterImageMenuItem; global string $imgExtension; global string $gMainFrameLayout; if (`about -windows`) { // windows os $gLogoFile = "poseManLogo.bmp"; $imgExtension = ".bmp"; $gSizeableFlag = 1; } else if (`about -linux` || `about -mac`) { // linux os $gLogoFile = "poseManLogo.xpm"; $imgExtension = ".xpm"; $gSizeableFlag = 1; } if ($gCurrentTabId<1) { $gCurrentTabId = 1; } $gIconsPath = `internalVar -ubd`; // Windows size int $mainWindowWith = 300; // Main layout $gMainFrameLayout = `frameLayout -bs "in" -lv 0 -bv 0 poseManFrameLayout`; $gMainLayout = `formLayout`; // Character avatar / logo string $characterThumbLayout = `columnLayout -adj 1 characterAvatarLayout`; string $characterIconTextButn = `iconTextButton -mw 0 -mh -0 -dcc "poseMan_captureNewPoseUI($gTabs)" -i1 $POSEMAN_LOGO -w 355 -h 80`; popupMenu; if ($gCurrentChar != "") { menuItem -l "Create new Sections..." -c "poseMan_addNewSectionUI"; menuItem -l "Create new Pose..." -c "poseMan_captureNewPoseUI($gTabs)"; menuItem -divider true; menuItem -en 1 -l "Delete Sections..." -c "poseMan_deleteSectionUI"; menuItem -l "Delete Poses..." -c "poseMan_deletePoseUI($gTabs)"; menuItem -divider true; } menuItem -l "Learn Namespace from object" -c "poseMan_learnNS"; menuItem -l "Reset/Empty Namespace" -c "$gCurrentCharNamespace=\"\""; menuItem -l "Hide Character image" -c "poseMan_HideCharAvatar"; setParent ..; // Character info string $characterInfoLayout = `formLayout characterInfo`; // Character name string $characterName = `text -l "Character Name: " characterNameTextLayout`; // Button string $getNamespaceInfoButton = `iconTextButton -w 20 -h 20 -i "EYEDROPPER.xpm" -l "Get NS" -c "poseMan_learnNS"`; string $trashIconButton = `iconTextButton -dropCallback howToDropTRASH -w 30 -h 30 -i "SMALLTRASH.xpm"`; // Info string $namespaceInfoText = `text -l ("Namespace: " + $gCurrentCharNamespace) namespaceInfoText`; formLayout -e -attachForm $characterName "left" 0 -af $trashIconButton "top" 0 -af $trashIconButton "right" 0 -af $namespaceInfoText "top" 5 -ac $namespaceInfoText "right" 5 $trashIconButton -af $getNamespaceInfoButton "top" 1 -ac $getNamespaceInfoButton "right" 10 $namespaceInfoText $characterInfoLayout; setParent..; // Global tabs layout $gTabs = `tabLayout poseManTabLayout`; int $showHideValue; if ($gCharacterImage == 0) { $showHideValue = -80; } else { $showHideValue = 0; } // Layout formLayout -e -attachForm $characterThumbLayout "top" $showHideValue -attachForm $characterThumbLayout "left" 0 -attachForm $characterThumbLayout "right" 0 -attachControl $gTabs "top" 0 $characterThumbLayout -attachForm $gTabs "left" 0 -attachForm $gTabs "right" 0 -attachForm $gTabs "bottom" 30 -attachControl $characterInfoLayout "top" 5 $gTabs -attachForm $characterInfoLayout "left" 8 -attachForm $characterInfoLayout "right" 2 $gMainLayout; // PoseMAN - MAIN MENU // @@@@@@@@@@@@@@@@@ // POSEMAN ITEM MENU // @@@@@@@@@@@@@@@@@ // Character menu with character loaded menu -label "Settings" -tearOff 0 -en 1 poseManMDropMenu; menuItem -en 1 -label "Cells x4..." -c ("window -e -w ((4*82)+45) poseManWindow") cx4_layout; menuItem -en 1 -label "Cells x6..." -c ("window -e -w ((6*82)+45) poseManWindow") cx6_layout; menuItem -en 1 -label "Cells x8..." -c ("window -e -w ((8*82)+45) poseManWindow") cx8_layout; menuItem -en 1 -label "Cells x10..." -c ("window -e -w ((10*82)+45) poseManWindow") cx10_layout; menuItem -divider true; $showHideCharacterImageMenuItem = `menuItem -en 1 -cb $gCharacterImage -label "Show / Hide Character image" -c "poseMan_ShowHideCharAvatar"`; menuItem -divider true; $keyOnPoseLayout = `menuItem -en 1 -cb 0 -label "Create Key on Pose" -c "poseMan_manageCheckBoxKeyOnPose"`; menuItem -divider true; menuItem -en 1 -label "Learn character Namespace" -c "poseMan_learnNS"; menuItem -en 1 -label "Reset/Empty Namespace" -c "$gCurrentCharNamespace=\"\""; // @@@@@@@@@@@@@@@@@@@ // CHARACTER ITEM MENU // @@@@@@@@@@@@@@@@@@@ // Character menu with character loaded menu -label "Character" -tearOff 0 -en 1 characterMenu; menuItem -en 1 -label "New..." -c "poseMan_addNewCharacterUI"; menuItem -en 1 -label "Load..." -c "loadCharacterFileBrowser"; // @@@@@@@@@@@@@@@@@@ // SECTIONS ITEM MENU // @@@@@@@@@@@@@@@@@@ menu -label "sections" -tearOff 0 -en 0 sectionMenu; menuItem -en 1 -label "Create new section..." -c "poseMan_addNewSectionUI"; menuItem -en 1 -label "Rename section..." -c "poseMan_renameSectionUI($gTabs)"; menuItem -en 1 -label "Reorder section..." -c "poseMan_reorderSections"; menuItem -en 1 -label "Delete sections..." -c "poseMan_deleteSectionUI"; // @@@@@@@@@@@@@@@ // POSES ITEM MENU // @@@@@@@@@@@@@@@ // Poses menu with character loaded menu -label "poses" -tearOff 0 -en 0 poseMenu; menuItem -en 1 -label "Create new pose..." -c "poseMan_captureNewPoseUI($gTabs)"; menuItem -en 1 -label "Delete poses..." -c "poseMan_deletePoseUI($gTabs)"; if ($gCurrentChar == "") { print ("// Welcome to PoseMan\n"); } else { print ("// Character " + $gCurrentChar + " open\n"); } window -e -title $poseMAN_UI_title poseManWindow; showWindow poseManWindow; } // ************************************************************************************************************* // PROCS character-relative // ************************************************************************************************************* // ------------------------ // Add new character Window // ------------------------ global proc poseMan_addNewCharacterUI () { global int $gSizeableFlag; if (`window -ex newCharacterWindow`) { deleteUI -window newCharacterWindow; } string $newCharacterWindow = `window newCharacterWindow`; string $mainLayout = `frameLayout -lv 0 -bv 0 -bs "etchedIn" newCharacterLayout`; columnLayout -adj 1 -rs 1; text -l "Character name" -align "left"; string $characterName = `textField -tx "" characterNameTextField`; text -l "Section Name" -align "left"; string $firstSectionName = `textField -tx "Default" sectionsNamesTextField`; button -l "Create new character" -c "getCharacterPathToWrite"; textField -e -ec ("getCharacterPathToWrite;deleteUI "+$newCharacterWindow+"") $characterName; window -e -sizeable $gSizeableFlag -w 300 -h 130 -title "Add new Character" newCharacterWindow; showWindow $newCharacterWindow; } global proc getCharacterPathToWrite () { fileBrowser "saveChar" "Save" "poseman" 4; } global proc saveChar (string $path, string $type) { global string $gCurrentCharPath; $gCurrentCharPath = $path; string $characterName = `textField -q -tx characterNameTextField`; string $sectionName = `textField -q -tx sectionsNamesTextField`; string $characterDirectory = ($path + "/" + $characterName); if (`filetest -d $characterDirectory` == 0) { poseMan_addNewCharacter $path $characterName $sectionName; } else { error "This character already exists in this directory"; } } // --------------------------------------- // Add new character Window to the project // --------------------------------------- global proc poseMan_addNewCharacter (string $characterPath, string $characterName, string $firstSectionName) { // string $projectURL = `workspace -q -fullName`; global int $gCurrentTabId; global string $gCurrentCharPath; $gCurrentCharPath = ($characterPath + "/" + $characterName + "/"); global string $gTabs; string $buffer[]; $characterName = poseMan_spacesToDown ($characterName); if ($characterName != "") { if (poseMan_checkCharacterName($characterName) == 0) { sysFile -makeDir ($characterPath + "/" + $characterName); print ("// Character " + $characterName + " has been created\n"); poseMan_addDefaultSection $firstSectionName; // Borramos la ventana de "nuevo personaje" deleteUI newCharacterWindow; poseMan_refreshMainWindowWhenNewCharacter; // Activamos los menus menu -e -en 1 -l "Sections" sectionMenu; menu -e -en 1 -l "Poses" poseMenu; } else { print "// This Character name already exists\n"; } } else { print ("// Type any character name\n"); } } global proc readCamPreset (int $id) { global string $poseManCameraName; global string $gCurrentCharPath; string $fileData; global float $poseManCameraPreset[]; string $cameraShapes[] = `listRelatives $poseManCameraName`; string $cameraShape = $cameraShapes[0]; float $v; if (`filetest -r ($gCurrentCharPath + "/" + "camera.p"+$id)`) { evaluateMelFile ($gCurrentCharPath + "/" + "camera.p"+$id); setAttr ($cameraShape + "." + "horizontalFilmAperture") $poseManCameraPreset[0]; setAttr ($cameraShape + "." + "verticalFilmAperture") $poseManCameraPreset[1]; setAttr ($cameraShape + "." + "focalLength") $poseManCameraPreset[2]; setAttr ($cameraShape + "." + "lensSqueezeRatio") $poseManCameraPreset[3]; setAttr ($cameraShape + "." + "fStop") $poseManCameraPreset[4]; setAttr ($cameraShape + "." + "focusDistance") $poseManCameraPreset[5]; setAttr ($cameraShape + "." + "shutterAngle") $poseManCameraPreset[6]; setAttr ($cameraShape + "." + "centerOfInterest") $poseManCameraPreset[7]; setAttr ($poseManCameraName + "." + "tx") $poseManCameraPreset[8]; setAttr ($poseManCameraName + "." + "ty") $poseManCameraPreset[9]; setAttr ($poseManCameraName + "." + "tz") $poseManCameraPreset[10]; setAttr ($poseManCameraName + "." + "rx") $poseManCameraPreset[11]; setAttr ($poseManCameraName + "." + "ry") $poseManCameraPreset[12]; setAttr ($poseManCameraName + "." + "rz") $poseManCameraPreset[13]; setAttr ($poseManCameraName + "." + "sx") $poseManCameraPreset[14]; setAttr ($poseManCameraName + "." + "sy") $poseManCameraPreset[15]; setAttr ($poseManCameraName + "." + "sz") $poseManCameraPreset[16]; setAttr ($poseManCameraName + "." + "v") $poseManCameraPreset[17]; print ("// Camera preset " + $id + " has been setted\n"); } else { print ("// There is no exists camera preset " + $id + "\n"); } } global proc writeCamPreset (int $id) { global string $poseManCameraName; global string $gCurrentCharPath; string $fileData; string $cameraShapes[] = `listRelatives $poseManCameraName`; string $cameraShape = $cameraShapes[0]; float $v; $fileData += "float $poseManCameraPreset[] = {(float)"; $v = `getAttr ($cameraShape + "." + "horizontalFilmAperture")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "verticalFilmAperture")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "focalLength")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "lensSqueezeRatio")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "fStop")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "focusDistance")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "shutterAngle")`; $fileData += ($v + ", "); $v = `getAttr ($cameraShape + "." + "centerOfInterest")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "tx")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "ty")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "tz")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "rx")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "ry")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "rz")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "sx")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "sy")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "sz")`; $fileData += ($v + ", "); $v = `getAttr ($poseManCameraName + "." + "v")`; $fileData += ($v + ", "); $fileData = `substring $fileData 1 (size($fileData)-2)`; $fileData += "};"; int $fileID = `fopen ($gCurrentCharPath + "/" + "camera.p"+$id) "w"`; fprint $fileID $fileData; fclose $fileID; print ("// Camera preset " + $id + " has been writed\n"); } // ------------------------- // Check if character exists // ------------------------- global proc int poseMan_checkCharacterName (string $characterName) { global string $gCurrentCharPath; // string $projectURL = `workspace -q -fullName`; int $outPut; if (`filetest -d ($gCurrentCharPath + "/" + $characterName)`) { $outPut = 1; } else { $outPut = 0; } return $outPut; } // -------------------- // About PoseMan Window // -------------------- global proc poseMan_aboutPoseMan() { global string $gIconsPath; global string $gLogoFile; global string $poseMAN_UI_title; global int $gSizeableFlag; if (`window -exists aboutPoseManWindow`) { deleteUI -window aboutPoseManWindow; } string $aboutPoseManWindow = `window aboutPoseManWindow`; string $aboutLayout = `frameLayout -cll 0 -lv 0 -bv 0 -bs "etchedIn" -h 100`; columnLayout -adj 0; // image -i ($gIconsPath + $gLogoFile) -w 280 -h 100; text -l ("\n"+$poseMAN_UI_title); text -l "Mêlèe Island Project Tools\n"; text -l "Francis Vega (c) 2009\n"; button -w 100 -l "Close" -h 20 -c ("deleteUI -window "+$aboutPoseManWindow); window -e -sizeable $gSizeableFlag -w 280 -h 230 -title "About PoseMAN" $aboutPoseManWindow; showWindow $aboutPoseManWindow; } // ------------------------------ // "learn" who namespaced is used // ------------------------------ global proc poseMan_learnNS () { string $theNS; string $buffer[], $bufferObject[]; string $currentNSCharacter = `namespaceInfo -cur`; global string $gCurrentCharNamespace; string $lista[] = `ls -sl`; if (size($lista)>0) { // Primero separamos solo un objeto tokenize $lista[0] "|" $bufferObject; int $nTokens = `tokenize $bufferObject[0] $currentNSCharacter $buffer`; if ($nTokens==2) { // Tiene un namespace $gCurrentCharNamespace = ($buffer[0] + $currentNSCharacter); print ("// Namespace: " + $gCurrentCharNamespace+"\n"); } else if ($nTokens>2) { $gCurrentCharNamespace = ""; for ($i=0;$i<($nTokens-1);$i++) { $gCurrentCharNamespace += ($buffer[$i] + $currentNSCharacter); } print ("// Namespace : " + $gCurrentCharNamespace+"\n"); } else { // es un objeto sin namespace $gCurrentCharNamespace = ""; print ("// No Namespace found. The namespace environment has been reset" + $gCurrentCharNamespace + "\n"); } } else { error "// Select object with Namespace info or has double namespace (reference inside referenfe)!"; } // Update namespace info at main UI text -e -l ("Namespace: " + $gCurrentCharNamespace) namespaceInfoText; } // ------------------------------- // Get array of characters From HD // ------------------------------- global proc string[] poseMan_getCharacterFromHD () { global string $gCurrentCharPath; // string $projectURL = `workspace -q -fullName`; string $poseMAN_URL = ($gCurrentCharPath); string $chars[]; string $charsAll[]; string $buffer[]; if (`about -windows`) { $chars = `getFileList -folder $poseMAN_URL -filespec "*."`; } else { $charsAll = `getFileList -folder $poseMAN_URL`; for ($i=0;$i el nombre del personaje es mooly string $charName; string $bits[]; int $tokens; $path = `pathonize $path`; $tokens = `tokenize $path "/" $bits`; $charName = $bits[$tokens-1]; return $charName; } // ************************************************************************************************************* // PROCS sections-relative // ************************************************************************************************************* // ---------------------- // Add new section window // ---------------------- global proc poseMan_addNewSectionUI () { global int $gSizeableFlag; if (`window -exists newSectionWindow`) { deleteUI -window newSectionWindow; } string $newSectionWindow = `window newSectionWindow`; string $mainLayout = `frameLayout -lv 0 -bv 0 -bs "etchedIn" newSectionLayout`; columnLayout -adj 1 -rs 1; text -l "Type section name/s (spaces = multi)" -align "left"; string $nombreSeccion = `textField`; button -l "CREATE" -c ("poseMan_addNewSection(`textField -q -tx "+$nombreSeccion+"`);deleteUI "+$newSectionWindow+""); window -e -sizeable $gSizeableFlag -w 250 -h 92 -title "Add new Section" $newSectionWindow; showWindow $newSectionWindow; } // -------------------------------- // Add new show-type section window // -------------------------------- global proc poseMan_addNewShowSectionUI () { global int $gSizeableFlag; if (`window -exists newSectionWindow`) { deleteUI -window newSectionWindow; } string $newSectionWindow = `window newSectionWindow`; string $mainLayout = `frameLayout -lv 0 -bv 0 -bs "etchedIn" newSectionLayout`; columnLayout -adj 1 -rs 1; text -l "Type Show Section name" -align "left"; string $nombreSeccion = `textField`; button -l "Create" -c ("poseMan_addNewShowSection(`textField -q -tx "+$nombreSeccion+"`);deleteUI "+$newSectionWindow+""); window -e -sizeable $gSizeableFlag -w 250 -h 92 -title "Add new Section" $newSectionWindow; showWindow $newSectionWindow; } // ------------------------------------------------ // Add defaults secionts at character creation time // ------------------------------------------------ global proc poseMan_addDefaultSection (string $sectionName) { string $buffer[]; global string $gCurrentSection; global string $gCurrentCharPath; global int $gCurrentTabId; global string $gTabs; string $fileData; tokenize $sectionName " " $buffer; for ($i=0;$i0) { // obtenemos los atributos son keyables $atributosKeyable_tmp2 = `cleanArray $channelBoxAttrs $atributosKeyable`; $atributosKeyable = $channelBoxAttrs; } for ($atributo in $atributosKeyable) { if (`getAttr -se ($listaObjs[$i]+"."+$atributo)`){ $atributosKeyable_tmp[size($atributosKeyable_tmp)] = $atributo; } } $atributosKeyable = $atributosKeyable_tmp; // Procesamos el nombre del objeto para quiarle el/los namespace/s // Primero separamos los diferentes objetos de la "ruta" del nombre compuesto tipo: nombre|nombre|nombre|etc.. $nTokens = `tokenize $listaObjs[$i] "|" $buffer`; for ($k=0;$k<$nTokens;$k++) { // Ahora por cada uno, le quitamos el namespace $nTokens2 = `tokenize $buffer[$k] ":" $buffer2`; $nombreSinNS += ($buffer2[size($buffer2)-1] + "|"); $buffer2 = {""}; } $nombreSinNS = `substring $nombreSinNS 1 (size($nombreSinNS)-1)`; $poseData += ("ctrl:" + $nombreSinNS + "\n"); // Ahora pasamos atributo por atributo recogiendo el valor for ($j=0;$j>" + " * " + $valor + " * " + "1" + "\n"); } else { float $valor = (`getAttr ($listaObjs[$i]+"."+$atributosKeyable[$j])`); $poseData += ($nombreSinNS + " * " + $atributosKeyable[$j] + " * " + $valor + " * " + "1" + "\n"); } } // $poseData += ("// set keyframe at all keyeable attrs\nsetKeyframe (\""+$listaObjs[$i]+"\");\n"); $poseData += ("\n"); $nombreSinNS = ""; } $poseData += "// End of PoseMAN file"; // string $projectURL = `workspace -q -fullName`; string $poseURLFull = ($gCurrentCharPath + "/" + $nombreSeccion[$idTabSeccion-1] + "/"); if (poseMan_checkPoseName($gCurrentChar, ($nombreSeccion[$idTabSeccion-1]), ($nombrePose+".pose")) == 0) { $fileID = `fopen ($poseURLFull + $nombrePose+".pose") "w"`; fprint $fileID $poseData; fclose $fileID; // Thumbnail part... // Renderiza el playblast int $currentTime = `currentTime -q`; select -cl; if (`about -windows`) { setAttr "defaultRenderGlobals.imageFormat" 20; playblast -v false -frame $currentTime -w 160 -h 160 -orn 0 -cf ($poseURLFull + $nombrePose + $imgExtension) -fmt "image"; } if (`about -linux` ||`about -mac`) { setAttr "defaultRenderGlobals.imageFormat" 7; playblast -v false -frame $currentTime -w 160 -h 160 -orn 0 -cf ($poseURLFull + $nombrePose + ".iff") -fmt "image"; system ("imgcvt " + ($poseURLFull + $nombrePose + ".iff" + " " + $poseURLFull + $nombrePose + ".xpm")); sysFile -delete ($poseURLFull + $nombrePose + ".iff"); } } else { error "// This name pose already exists!"; } $gCurrentTabId = $idTabSeccion; // Añadimos la pose al archivo de poses poseMan_addPoseToConfigFile ($nombreSeccion[$idTabSeccion-1], $nombrePose); // Añadimos la pose al UI addPoseToUI $nombreSeccion[$idTabSeccion-1] $nombrePose; } // -------------------- // Añade una pose al ui // -------------------- global proc addPoseToUI (string $sectionName, string $poseName) { global string $gCurrentChar; global string $gCurrentCharPath; global int $gCurrentTabId; global string $imgExtension; global int $gCurrentTabId; global string $gProjectURL; // ACTUALIZAMOS LA POSE PUESTA global string $gMainLayout; global string $gTabs; string $ventana = "poseManWindow"; string $formPrincipal = $gMainLayout; string $tabs = $gTabs; string $menu = ($gTabs + "|" + $sectionName); $poseThumbnailFormLayout = `formLayout -p $menu`; $pose = ($poseName + ".pose"); // icono pose $poseIcon = ($gCurrentCharPath + "/" + $sectionName+ "/" + $poseName + $imgExtension); $thumbPose = `iconTextButton -dragCallback howToDragCB -dropCallback howToDropCB`; iconTextButton -e -i1 $poseIcon -c ("poseMan_applyPoseFast(\""+$sectionName+"\", \""+$pose+"\")") -w 80 -h 80 -mh 0 -mw 0 $thumbPose; // Submenu popupMenu; menuItem -l ("Asign " + $poseName) -c ("poseMan_applyPose(\""+$sectionName+"\", \""+$pose+"\", 1)"); menuItem -divider true; menuItem -en 1 -l "Mix pose Slider" -c ("sliderMix(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -divider true; menuItem -en 1 -l "Update (All controls)" -c ("poseMan_updatePose(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -en 1 -l "Add selected controls" -c ("poseMan_addControlsToPose(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -en 0 -l "Remove selected controls (wip)" -c ("poseMan_removeControlsFromPose(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -en 1 -l "Select controls" -c ("poseMan_selectControlsFromPose(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -divider true; menuItem -en 1 -l "Override ..." -c ("poseMan_rewritePoseData(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -en 1 -l "Override Thumbnail..." -c ("poseMan_reCaptureNewPoseUI(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -divider true; menuItem -en 1 -l "Move to..." -c ("poseMan_movePoseUI(\""+$sectionName+"\", \""+$pose+"\")"); menuItem -en 1 -l "Rename ..." -c ("poseMan_renamePoseUI(\""+$pose+"\")"); menuItem -l "Delete pose" -c ("poseMan_deletePoseSimple(\""+$sectionName+"\", \""+$pose+"\")"); // texto string $i1 = `text -align "center" -l $poseName -w 80 -h 20 -bgc 1 1 1`; setParent ..; formLayout -e -attachForm $thumbPose "top" 0 -attachForm $thumbPose "left" 0 -attachForm $i1 "top" 80 -attachForm $i1 "left" 0 $poseThumbnailFormLayout; } // -------------------- // Borra la pose del UI // -------------------- global proc deletePoseFromUI (string $sectionName, string $poseName) { global string $gTabs; string $menu = ($gTabs + "|" + $sectionName); string $hijosSeccion[] = `shelfLayout -q -ca $sectionName`; for ($form in $hijosSeccion) { string $botonYtexto[] = `formLayout -q -ca $form`; string $textoForm = $botonYtexto[1]; string $label = `text -q -label $textoForm`; if ($poseName == $label) { deleteUI ($form); } } } // ------------------ // Delete pose window // ------------------ global proc poseMan_deletePoseUI (string $tabName) { global string $gCurrentCharPath; global int $gSizeableFlag; global string $gCurrentChar; int $tabIndex = `tabLayout -q -sti $tabName`; string $sectionsList[] = `poseMan_getSectionsFromConfFile $gCurrentCharPath`; string $currentSection = $sectionsList[$tabIndex-1]; if (`window -exists poseListWindow`) { deleteUI -window poseListWindow; } string $posesListWindow = `window poseListWindow`; string $mainLayout = `frameLayout -lv 0 -bv 0 -bs "etchedIn" poseMan_deletePoseLayout`; columnLayout -adj 1 -rs 1; string $posesListLayout = `textScrollList -numberOfRows 8 -allowMultiSelection 1`; string $posesList[] = poseMan_getPosesFromHD ($currentSection); for ($i=0;$i0) { for ($i=0;$i1) { $nombreSinNamespace = $bufferNamespace[1]; } if ($nombreDelObjeto == $nombreSinNamespace) { $filePoseData += ("poseMan_mixAttr (\""+$nombreDelObjeto+"\", \""+$gCurrentCharNamespace+"\", \""+$propiedadDelObjeto+"\", \""+$valorDelObjeto+"\", \""+$mix+"\", -1000000);\n"); } } } else { $filePoseData += ("poseMan_mixAttr (\""+$nombreDelObjeto+"\", \""+$gCurrentCharNamespace+"\", \""+$propiedadDelObjeto+"\", \""+$valorDelObjeto+"\", \""+$mix+"\", -1000000);\n"); } } else { // No se añade a filePoseData las líneas de un objeto que no existe. } } $nextLine = `fgetline $fileID`; } // Cerramos el archivo fclose $fileID; // Evaluamos la pose eval ($filePoseData); // info print ("// "+(`substring $poseName 1 (size($poseName)-5)`)+" pose asigned\n"); } // ------------------- // Apply a pose (FAST) // ------------------- global proc poseMan_applyPoseFast (string $sectionName, string $poseName) { global string $gCurrentCharNamespace; global string $gCurrentCharPath; //string $projectURL = `workspace -q -fullName`; string $buffer[]; string $bufferNamespace[]; string $bufferObj[]; string $filePoseData = ""; string $filePoseObjects[]; string $nombreSinNamespace; $fileID = `fopen ($gCurrentCharPath + "/" + $sectionName + "/" + $poseName) "r"`; string $objList[] = `ls -sl`; // leemos una linea $nextLine = `fgetline $fileID`; // leemos todas las lineas while ( !`feof $fileID` ) { // La línea es // o \n if (`substring $nextLine 1 2` == "//" || `substring $nextLine 1 2` == "\n" || `substring $nextLine 1 5` == "ctrl:") { // esta linea no nos vale } else { tokenize $nextLine " * " $buffer; $nombreDelObjeto = $buffer[0]; $propiedadDelObjeto = $buffer[1]; $valorDelObjeto = $buffer[2]; if (size($objList)>0) { // comprobamos si el objeto existe if( `objExists ($gCurrentCharNamespace + $nombreDelObjeto)` == true ) { $filePoseData += ("poseMan_mixAttrFast (\""+$nombreDelObjeto+"\", \""+$gCurrentCharNamespace+"\", \""+$propiedadDelObjeto+"\", \""+$valorDelObjeto +"\");\n"); } } else { // comprobamos si el objeto existe if( `objExists ($gCurrentCharNamespace + $nombreDelObjeto)` == true ) { $filePoseData += ("poseMan_mixAttrFast (\""+$nombreDelObjeto+"\", \""+$gCurrentCharNamespace+"\", \""+$propiedadDelObjeto+"\", \""+$valorDelObjeto +"\");\n"); } } } $nextLine = `fgetline $fileID`; } // Cerramos el archivo fclose $fileID; // Evaluamos la pose eval ($filePoseData); // info print ("// "+(`substring $poseName 1 (size($poseName)-5)`)+" pose asigned\n"); } // --------------------- // Mix attributes (FAST) // --------------------- global proc poseMan_mixAttrFast (string $objeto, string $objectNamespace, string $propiedad, float $valor) { global string $gCurrentCharNamespace; global string $gSetKeyOnPose; string $buffer[]; int $nTokens; string $objetoCompleto; // Procesamos el nombre del objeto para añadir el namespace en caso de que sea un nombre "compuesto" tipo nombre|nombre|nombre|.... tokenize $objeto "|" $buffer; $objetoCompleto = ""; for ($i=0;$i0) { // obtenemos los atributos son keyables $atributosKeyable_temp = `cleanArray $channelBoxAttrs $atributosKeyable`; $atributosKeyable = $channelBoxAttrs; } // Procesamos el nombre del objeto para quiarle el/los namespace/s // Primero separamos los diferentes objetos de la "ruta" del nombre compuesto tipo: nombre|nombre|nombre|etc.. $nTokens = `tokenize $poseControls[$i] "|" $buffer`; for ($k=0;$k<$nTokens;$k++) { // Ahora por cada uno, le quitamos el namespace $nTokens2 = `tokenize $buffer[$k] ":" $buffer2`; $nombreSinNS += ($buffer2[size($buffer2)-1] + "|"); $buffer2 = {""}; } $nombreSinNS = `substring $nombreSinNS 1 (size($nombreSinNS)-1)`; $poseData += ("ctrl:" + $nombreSinNS + "\n"); // Ahora pasamos atributo por atributo recogiendo el valor for ($j=0;$j> " mode; button -e -en 0 -bgc 0.855 0.955 0.731 -c ("readCamPreset(1)") p1; button -e -en 1 -bgc 0.855 0.955 0.731 -c ("readCamPreset(1)") p1; button -e -en 0 -bgc 0.855 0.955 0.731 -c ("readCamPreset(2)") p2; button -e -en 1 -bgc 0.855 0.955 0.731 -c ("readCamPreset(2)") p2; button -e -en 0 -bgc 0.855 0.955 0.731 -c ("readCamPreset(3)") p3; button -e -en 1 -bgc 0.855 0.955 0.731 -c ("readCamPreset(3)") p3; button -e -en 0 -bgc 0.855 0.955 0.731 -c ("readCamPreset(4)") p4; button -e -en 1 -bgc 0.855 0.955 0.731 -c ("readCamPreset(4)") p4; button -e -en 0 -bgc 0.855 0.955 0.731 -c ("readCamPreset(5)") p5; button -e -en 1 -bgc 0.855 0.955 0.731 -c ("readCamPreset(5)") p5; } else { button -e -bgc 0.822 0.396 0.396 -l " << Write " mode; button -e -en 0 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(1)") p1; button -e -en 1 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(1)") p1; button -e -en 0 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(2)") p2; button -e -en 1 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(2)") p2; button -e -en 0 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(3)") p3; button -e -en 1 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(3)") p3; button -e -en 0 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(4)") p4; button -e -en 1 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(4)") p4; button -e -en 0 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(5)") p5; button -e -en 1 -bgc 0.955 0.731 0.731 -c ("writeCamPreset(5)") p5; } } // ----------------------------- // Refresh PoseMAN (main) window // ----------------------------- global proc poseMan_refreshMainWindow() { global string $gTabs; // Obtenemos nombres de tab, shelf e hijos de shelf. string $hijosTab[] = `tabLayout -q -ca $gTabs`; string $sections[] = $hijosTab; string $hijosShelf[]; // Borramos todos los hijos de todos los shelf, las poses. for ($section in $sections) { $hijosShelf = `shelfLayout -q -ca $section`; for ($item in $hijosShelf) { deleteUI $item; } } // Añadimos las poses for ($section in $sections) { addFormsAsPoses $section $section; } } global proc string[] mydgc ( string $dragControl, int $x, int $y, int $mods ) { print $dragControl; return { $dragControl }; } global proc mydpc ( string $drag, string $drop, string $msgs[], int $x, int $y, int $type ) { print $drag; print $drop; print $msgs; } // ----------------------------- // Refresh PoseMAN (main) window when create new character // ----------------------------- global proc poseMan_refreshMainWindowWhenNewCharacter () { global string $gTabs; global string $gCurrentChar; global string $gCurrentCharPath; global string $gTabs; global int $gCurrentTabId; global string $gMainLayout; global string $gCurrentSection; deleteUI $gTabs; $gTabs = `tabLayout -p $gMainLayout poseManTabLayout`; // Lista de secciones string $sectionsList[] = `poseMan_getSectionsFromConfFile $gCurrentCharPath`; // ui for ($seccion in $sectionsList) { // SECCIONES // Genera el shelfLayout por sección, donde van las poses shelfLayout -p $gTabs -h 300 -cw 82 -ch 102 $seccion; popupMenu; menuItem -l "Create new Pose..." -c "poseMan_captureNewPoseUI($gTabs)"; menuItem -l "Delete Poses..." -c "poseMan_deletePoseUI($gTabs)"; setParent ..; // POSES (loop) // Genera todos los layouts para las poses addFormsAsPoses $seccion $seccion; } global string $gMainLayout; // Elegimos el tab por defecto tabLayout -e -sti 1 poseManTabLayout; $gCurrentTabId = 1; formLayout -e -ac $gTabs "top" 5 characterAvatarLayout -af $gTabs "left" 0 -af $gTabs "right" 0 -af $gTabs "bottom" 35 $gMainLayout; int $secIndex = `findElementAndGetIndex $gCurrentSection $sectionsList`; if ($secIndex == -1) { $secIndex = 0; } tabLayout -e -sti ($secIndex+1) poseManTabLayout; // Activamos los menus de crear secciones y poses menu -e -en 1 -l "Sections" sectionMenu; menu -e -en 1 -l "Poses" poseMenu; // añadimos el nombre del personaje al character info text layout text -e -l ("Character name: " + $gCurrentChar) characterNameTextLayout; } // -------------------------------------------------- // Refresh PoseMAN (main) window when delete sections // ------------------------------------------------- global proc poseMan_refreshMainWindowWhenDeleteSections() { global string $gTabs; global string $gCurrentChar; global string $gCurrentCharPath; global string $gTabs; global int $gCurrentTabId; global string $gMainLayout; deleteUI $gTabs; $gTabs = `tabLayout -p $gMainLayout poseManTabLayout`; // Lista de secciones string $sectionsList[] = `poseMan_getSectionsFromConfFile $gCurrentCharPath`; // ui for ($seccion in $sectionsList) { // SECCIONES // Genera el shelfLayout por sección, donde van las poses shelfLayout -p $gTabs -h 300 -cw 82 -ch 102 $seccion; // POSES (loop) // Genera todos los layouts para las poses addFormsAsPoses $seccion $seccion; } global string $gMainLayout; // Elegimos el tab por defecto tabLayout -e -sti 1 poseManTabLayout; $gCurrentTabId = 1; formLayout -e -ac $gTabs "top" 5 characterAvatarLayout -af $gTabs "left" 0 -af $gTabs "right" 0 -af $gTabs "bottom" 35 $gMainLayout; } // ---------------------------- // Go Up proc of reorder window // ---------------------------- global proc poseMan_goUp (string $layoutName) { // Guardamos todos los items string $allItems[] = `textScrollList -q -ai $layoutName`; // El id seleccionado int $selectedItemList[] = `textScrollList -q -sii $layoutName`; if ($selectedItemList[0]>1) { int $selectedItem = ($selectedItemList[0]); int $topItem = $selectedItem-1; string $seleccionado = $allItems[$selectedItem-1]; string $elDeArriba = $allItems[$topItem-1]; $allItems[$selectedItem-1] = $elDeArriba; $allItems[$topItem-1] = $seleccionado; textScrollList -e -ra $layoutName; for ($i=0;$i