// Creation Date: Sept-18-2002 // // Author: // // ------------------------- // --------------------------- // Klaus Stangl // Student@TU Graz // Demoartist/Developer // Educator@Siliconstudio Graz // www.worldofmaya.com // office@worldofmaya.com // ----------------------------- // ------------------------------- // // Thanks to: // Mark Davies / http://www.3dluvr.com/lightengine3d // // // Script Name: // particleImage (version 1.0) // // Syntax: // particleImage() // // Tested with: // Maya 4.0.2 for NT // // Example: // source particleImage.mel; particleImage; // // Description: // // The script takes an Image in IFF-format and creates one particle for every pixel (with Color and Alpha value!) // // !!! This script can take some time to work... !!! // !!! Press ESC do stop... !!! // // // 1. Creates Particle Grid // 2. Particle scale -1 to get right ID order // 3. Create Per Particle Color // 4. Create Per Particle Opacity // 5. Uses iffPixelArray from http://www.3dluvr.com/lightengine3d to read Imagedata! // // !!!! You need to download the plugin, before you can use this Script !!!! // // !!!! 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! // global proc particleImage( ) { int $runX; int $runY; int $runZ; float $maxX; float $maxY; string $particleName[]; string $shadingNodeName; string $imagePath; int $progressAmount = 0; int $linePERcent; string $xyString; string $IFFcommand; int $IFFSampels; int $arraySize; float $iffRGBArray[]; source AEfileTemplate.mel; $shadingNodeName = `shadingNode -asTexture file`; string $workspace = `workspace -q -fn`; setWorkingDirectory $workspace "image" "sourceImages"; fileBrowser (("AEassignTextureCB "+$shadingNodeName+".fileTextureName"), "Open", "image", 0); $maxX = `getAttr("file1.outSizeX")`; $maxY = `getAttr("file1.outSizeY")`; $imagePath = `getAttr($shadingNodeName+".fileTextureName")`; select -r $shadingNodeName; delete; $iffRGBArray = `iffPixelArray $imagePath -convertRGB 1 0 0`; if($maxX>0) { progressWindow -title "Creating particleImage..." -progress $progressAmount -status "Image Y Row: 0" -max $maxY -isInterruptable true; $particleName = `particle -ll 0.1 0 0.1 -ur ($maxY/10) 0 ($maxX/10) -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]; for ($runY = 0; $runY < $maxY; $runY++) { $xyString =""; if ( `progressWindow -query -isCancelled` ) break; for ($runX = 0; $runX < $maxX; $runX++) { $xyString += ($runX+" "+$runY+" "); } $IFFSampels = $maxX; $IFFcommand = ("iffPixelArray \""+$imagePath+"\" -convertRGB "+$IFFSampels+" "+$xyString); $iffRGBArray = `eval $IFFcommand`; $arraySize = `size $iffRGBArray`; for ($runX = 0; $runX < $maxX; $runX++) { particle -e -or ($maxX*$runY+$runX) -at rgbPP -vv $iffRGBArray[$runX*4] $iffRGBArray[($runX*4)+1] $iffRGBArray[($runX*4)+2] $particleName[1] ; particle -e -or ($maxX*$runY+$runX) -at opacityPP -fv $iffRGBArray[($runX*4)+3] $particleName[1] ; } progressWindow -edit -status ("Image Y Row: " + $runY) -pr ($runY+1); } print("All Pixels written!\n"); progressWindow -endProgress; } } // End of particleImage()