// Creation Date: Dez-21-2002 // // Author: // // ------------------------- // --------------------------- // Klaus Stangl // Student@TU Graz // Demoartist/Developer // Educator@Siliconstudio Graz // www.worldofmaya.com // office@worldofmaya.com // ----------------------------- // // Script Name: // particleImage (version 1.0.2) // // Syntax: // particleImage2() // // Tested with: // Maya 4.5 for NT // // Example: // source particleImage2.mel; particleImage2; // // Description: // // The script takes an Image and creates one particle for every pixel! // // !!! This script can take some time to work... !!! // !!! Press ESC do stop... !!! // // // This script can work with every maya supported image format! // You can change the image afterwards! Just go to the particleShape and change the filename! // There is no problem using image sequences! // // // !!!! It creates an huge amount of data with high resolution Images !!!! // !!!! X*Y*RGBA -> this produces big Maya Scene Files !!!! // // // For more infos read the documentation on www.worldofmaya.com or mail! proc string confirm_Dialog(string $title) { global int $q_confirm; if ($q_confirm==0) { string $button_re=`confirmDialog -message $title -button "Yes" -button "No" -defaultButton "No" -ma "center" -t "particleImage2()" -cancelButton "No" -dismissString "No"`; return($button_re); } else { return("Yes"); } } global proc particleImage2( ) { //Initialize! int $runX = 0; int $runY = 0; int $currentTimeVar; int $progressAmount = 0; int $maxX = 0; int $maxY = 0; string $particleName[]; string $tempAryStrg[]; string $shadingNodeName = ""; string $rampName = ""; string $arrayMapperName = ""; string $imagePath = ""; string $workspace = ""; string $expressionStrg; global int $runXExpr = 0; global int $runYExpr = 0; int $temporaryInt = 0; //Initialize End! source AEfileTemplate.mel; $shadingNodeName = `shadingNode -asTexture file`; $shadingNodeName = `rename $shadingNodeName "particleImageFile#"`; $workspace = `workspace -q -fn`; setWorkingDirectory $workspace "image" "sourceImages"; string $command = "fileBrowser ((\"AEassignTextureCB "+$shadingNodeName+".fileTextureName\"), \"Open\", \"image\", 0);"; $temporaryInt = eval($command); //print("Eval returned: "+$temporaryInt + "\n"); $maxX = `getAttr($shadingNodeName+".outSizeX")`; $maxY = `getAttr($shadingNodeName+".outSizeY")`; $imagePath = `getAttr($shadingNodeName+".fileTextureName")`; print("------\n"); print("Workspace: " + $workspace + "\n"); print("Shadingnodename: "+$shadingNodeName+"\n"); print("Resolution: "+$maxX + "x" + $maxY + " -> Image: " + $imagePath + "\n"); print("------\n"); if (((confirm_Dialog("Manually set Resolution?"))=="Yes")||($maxX == 0)) { promptDialog -message "Enter X-Resolution:" -button "Ok" -button "Cancel" -defaultButton "Ok" -cancelButton "Cancel" -dismissString "Cancel"; $maxX = `promptDialog -q`; if($maxX > 0) promptDialog -message "Enter Y-Resolution:" -button "Ok" -button "Cancel" -defaultButton "Ok" -cancelButton "Cancel" -dismissString "Cancel"; if($maxX > 0) $maxY = `promptDialog -q`; } if($maxX>0) { $particleName = `particle -ll 0.1 0 0.1 -ur ($maxY/10.0) 0 ($maxX/10.0) -grs 0.1 -c 1 `; CenterPivot; move -rpr 0 0 0 ; setAttr ($particleName[0]+".scaleZ") -1; addAttr -ln "rgbPP" -dt vectorArray $particleName[1]; addAttr -ln "rgbPP0" -dt vectorArray $particleName[1]; addAttr -ln "opacityPP" -dt doubleArray $particleName[1]; addAttr -ln "opacityPP0" -dt doubleArray $particleName[1]; addAttr -ln xCoord0 -dt doubleArray $particleName[1]; addAttr -ln xCoord -dt doubleArray $particleName[1]; setAttr -e -keyable true ($particleName[1]+".xCoord"); addAttr -ln yCoord0 -dt doubleArray $particleName[1]; addAttr -ln yCoord -dt doubleArray $particleName[1]; setAttr -e -keyable true ($particleName[1]+".yCoord"); $rampName = `shadingNode -asTexture ramp`; $tempAryStrg = `arrayMapper -target $particleName[1] -destAttr rgbPP -inputU xCoord -inputV yCoord -mapTo $rampName`; $arrayMapperName = $tempAryStrg[0]; connectAttr -f ($shadingNodeName+".message") ($arrayMapperName+".computeNode"); connectAttr -f ($shadingNodeName+".outColor") ($arrayMapperName+".computeNodeColor"); saveInitialState $particleName[0]; $runXExpr = 0; $runYExpr = 0; $expressionStrg = "int $maxX = "+$maxX+";\r\nint $maxY = "+$maxY+";\r\nglobal int $runXExpr;\r\nglobal int $runYExpr;\r\nif (id==0) {$runXExpr =0;$runYExpr=0;}\r\nif ($runYExpr<$maxY)\r\n{\r\n\r\n if ($runXExpr == $maxX)\r\n {\r\n\t$runXExpr = 0;\r\n\t$runYExpr++;\r\n\r\n }\r\n\r\n if ($runXExpr > 0) xCoord0 = $runXExpr/($maxX-1.0);\r\n\telse $runXExpr =0;\r\n if ($runYExpr > 0) yCoord0 = $runYExpr/($maxY-1.0);\r\n\telse $runYExpr =0;\r\n $runXExpr++;\r\n}\r\n"; dynExpression -s $expressionStrg -r $particleName[1]; // Change time to take Effect $currentTimeVar = `currentTime -q`; currentTime -e ($currentTimeVar+1); currentTime -e ($currentTimeVar); $runXExpr = 0; $runYExpr = 0; // Delete it! dynExpression -s "" -r $particleName[1]; } else if ($imagePath != 0) warning("Maya seams to have a problem with the selected file! Try to convert it into iff!\n"); else warning("Something was wrong!"); select -cl; } // End of particleImage()