Hi all. First of all, I am fairly new to MEL. Now that that is out of the way, let me say that I have been working with some simple scripts that I have written in order to work with particles. What I want to happen is for a particle system to leave geometry behind after a particle has collided with an object. Imagine a bird laying an egg after it hist a window. I have succeeded in creating a Particle Collision Procedure that creates a pSphere when the particles collide, so not very difficult. But what I want is for those sphere to be placed where the particle collides. The procedure works, in some odd and wrong way. Basically, spheres are placed in the positions, but there is some erronious looping that occurs . . .like 10400 extra loops, but maya doesn't crash, it just computes and continues, but it takes a long time. Some of the lat part of the code I have used successfully as a runtime expression to connnect geometry to particles. I thought I would try to use it in this manner. Any help would be appreciated as I am a little lost at this point. I have a simple working model that would work for simple presentation purposes, but this is supposed to work in a model of a downtown area of a city. Thanks!
CODE
//----------------------------------------------------------------
//--------Initiate Global Procedure-------------------------------
//----------------------------------------------------------------
global proc pTest014(string $particleName, int $particleId, string $objectName)
{
//----------------------------------------------------------------
//--------Create Seeds--------------------------------------------
//----------------------------------------------------------------
print ("Collided with" + $objectName + "\n" + "\n");
print ($particleId + "\n");
polySphere;
//----------------------------------------------------------------
//--------Place $particleID in array------------------------------
//----------------------------------------------------------------
int $seedsInScene[];
for ($i=0;$i<100;$i++)
{
$seedsInScene[$i] = $particleId;
print ($seedsInScene);
//----------------------------------------------------------------
//--------Go Through $seedsInScene[] array with $seedObject-------
//----------------------------------------------------------------
int $seedObject;
for ( $seedObject in $seedsInScene)
{
//----------------------------------------------------------------
//For each $particleId collision stored in $seedsInScene, place---
//psphere at the position of the particle that collided-----------
//----------------------------------------------------------------
$pos = getParticleAttr -at position ($particleName + ".pt[" + $seedObject + "]")
;
setAttr ("pSphere"+$seedObject+".tx") $pos[0];
setAttr ("pSphere"+$seedObject+".ty") $pos[1];
setAttr ("pSphere"+$seedObject+".tz") $pos[2];
}
}
};