PDA

View Full Version : Particle instances to regular instances


ASW
06-06-2006, 06:57 PM
I'm wondering if theres a way to turn particles instances into regular instances. I've got the nsDesinstancer script that turns particles instances into regular geometry, but I need to keep the particle instances as instances otherwise the scene wont render. Thanks alot for your help in advance.

azshall
06-07-2006, 01:08 AM
I've got the nsDesinstancer script that turns particles instances into regular geometry

What is this script and where can I find it? Did a search on google and highend3d, no matches found...

az

Jozvex
06-07-2006, 01:29 AM
Instances are just the one shape node connected into multiple transform nodes. I don't know how MEL savvy you are but you could try writing a script to read in all the selected nodes, then delete their shape nodes. A second script could then connect the specified shape node up to a list of selected transforms?

Bonedaddy
06-07-2006, 01:40 AM
I was working on writing something up quick for you, but I got tripped up on how to access the list of instanced geo in a particleInstancer node. If you post up that mel script, I can probably tweak it real quick to do instancing instead of copying. Got to head out for now, though.

ASW
06-07-2006, 02:28 AM
sorry I got the name wrong, its a plugin not a mel. Thanks alot for your help.

http://student.vfs.com/~angusw/nsUninstancer.rar

Bonedaddy
06-07-2006, 07:41 AM
Well carp, if it's a plugin I can't really slough through it too well.

I'll investigate further tomorrow. For right now, it's 1 am and I need to sleep.

gottesgerl
06-07-2006, 05:25 PM
Perhaps this may help you out.
Just a little script I wrote some days ago. Its quick and dirty, but should do its job.
First select all SHAPES you want to change (perhaps by using the Down-Arrow-Key) then last-select the SHAPE you want all the others to become.
Run the script and pray.
Hopefully it gets you there. :)
If you want to backup the old-Shapes --> set the $backup-variable to 1.

-----------------------------------------------------------------------




global proc hg_changeShapes ()
{
int $backup = 0;
int $verbose = 1;

string $newShape[];
string $parents[];
string $shapes[];
string $shortShapeName[];
int $tokCount;

string $sel[] = `ls -sl -l -s`;
if (size($sel)<2) {error "Not enough Objects selected.";}

$newShape[0] = $sel[size($sel)-1];
string $oldShapes[] = `stringArrayRemove $newShape $sel`;

for ($s in $oldShapes)
{
$parents = `listRelatives -p -ap -f $s`;

for ($p in $parents)
{
$shapes = `listRelatives -s -f $p`;
$tokCount = `tokenize $s "|"$shortShapeName`;

if (!`objExists ("BACKUP_of_"+$shortShapeName[$tokCount-1])` && $backup)
{
group -empty -n ("BACKUP_of_"+$shortShapeName[$tokCount-1]);
if ($verbose>0) {print ("-----> BACKUP created for Shape: \t"+$shortShapeName[$tokCount-1]+"\n");}
parent -add -s $s ("BACKUP_of_"+$shortShapeName[$tokCount-1]);
}

for ($sh in $shapes)
{
parent -rm -s $sh;
}
if ($verbose>0) {print ("----->\tAssigned new Shape for\t"+$p+"\n");}
parent -add -s $newShape[0] $p;
}
}

}
hg_changeShapes;





----------------------------------------------------------------------------


If you run into trouble with it, please report.


Thats it for now,
stay fine,
Hannes.

Bonedaddy
06-07-2006, 07:45 PM
Alright, so, here's me taking a crack at it. It may be wrong, as my computer's tied up running a sim right now and I'm coding this blind, so I'll test it and edit when I get a chance.



// USAGE:
// 1) Replace the $instancerAttrName, $rotAttrName, and $posAttrName vars below
// 2) Select the particle, then the instancer.
// 3) Run this script.
//
// Only do one particle system at a time if you have
// more than one particle system you want to do this to.

$instancerAttrName="REPLACE ME";
$rotAttrName="rotPP"; //replace if necessary
$posAttrName="worldPosition"; //replace if necessary


$select=`ls -sl`;
$tmpParticleName=`listRelatives -c $select[0]`;
$particleName=$tmpParticleName[0];
$instancer=$select[1];

string $geoTransList[]=`listConnections ($instancer+".inputHierarchy")`;

/*
// looks like this isn't necessary, but just in case
// the instanced shape nodes are needed, keeping this
string $geoList[];
for ($transform in $geoTransList) {
$tmpGeo=`listRelatives -c $transform`;
$geoList[]=$tmpGeo[0];
}
*/

$count=`getAttr ($particleName+".count")`;

for ($i=0;$i<$count;$i++) {
$tmpInstId=`getParticleAttr -at $instancerAttrName ($particleName+".pt["+$i+"]")`;
int $instId=$tmpInstId[0];
$pos=`getParticleAttr -at $posAttrName ($particleName+".pt["+$i+"]")`;
$rot=`getParticleAttr -at $rotAttrName ($particleName+".pt["+$i+"]")`;
$newInst=`instance $geoTransList[$instId]`; // -name ($geoTransList[$instId]+"_instance_"+$i)`;
xform -ro ($rot[0]) ($rot[1]) ($rot[2]) $newInst;
xform -r -t ($pos[0]) ($pos[1]) ($pos[2]) $newInst;
}




I'm almost certain it's riddled with errors (I'm coding blind), but if you want to bughunt it real quick, it should be workable once bug-free.

JamesPiechota
07-06-2006, 01:06 AM
Hi,

I've updated the nsUninstancer plug-in to support copying the particle instanced geometry as regular instances. You can now also bake a particle instancer with geometry cycles to blendshapes. The plug-in's still in "beta" so I haven't posted it on Highend yet, but you can download it here:

http://forums.cgsociety.org/showthread.php?p=3685171

Currently it's only compiled for Maya 7 on Windows.

CGTalk Moderation
07-06-2006, 01:06 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.