PDA

View Full Version : Need Help with Aiming Particles


lineberry30
11-10-2011, 06:49 PM
Hello there,
This is my first post (of hopefully many), and I'm having a time figuring out how to aim my instanced objects down a curve. I'm not really fluent in MEL yet, so a bit of an explanation would be much appreciated. The object follow the curve just fine, but they don't point in the correct direction. Any tips on how to accomplish this?

Here's my script:

proc antline()

{

curve -d 3 -p 0.571267 0 12.098043 -p 0.982586 0 8.913835 -p 1.805225 0 2.545417
-p 7.707394 0 -3.383342 -p 7.5082 0 -8.159985 -p 7.408603 0 -10.548307
-k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 3 -k 3 ;

string $selection_list[] = `ls -sl`;
string $curveSelected = $selection_list[0]; //select curve

int $curveLength = `getAttr "curve1.spans"`; //find length of the curve


pointOnCurve -ch on -pr 0 $curveSelected; //find the point on the curve
//with construction history


emitter -pos 0 0 0 -type dir -r 1 -sro 0 -nuv 0 -cye none -cyi 1 -spd 0.0 -srn 0 -nsp 1
-tsp 0 -mxd 0 -mnd 0 -dx 1 -dy 0 -dz 0 -sp 0 ; //create emitter

particle;

setAttr particleShape1.lifespanMode 1; //set lifespan mode to constant
setAttr "particleShape1.lifespan" ($curveLength); //set lifespan to the length of the curve

connectDynamic -em emitter1 particle1;



particleInstancer -addObject -object "nurbsSphere1" -cycle none
-cycleStep 1 -cycleStepUnits Frames -levelOfDetail Geometry
-rotationUnits Degrees -rotationOrder XYZ
-position worldPosition -age age particleShape1; //instance the ant to
//each particle emitted

particleInstancer -q -name particle1;

particleInstancer -name instancer1 -q -position particle1; // query the particle
//attribute name
//corresponding to the position
//attrib for the instancer


//Expressions
dynExpression -s "float $scaleOffset = (.2); \n \nsetAttr pointOnCurveInfo1.parameter (particleShape1.age); \n\nfloat $pos[] = `getAttr pointOnCurveInfo1.position`; \n\nvector $posvec = <<$pos[0], $pos[1], $pos[2]>>; \n\nparticleShape1.position = $posvec + $scaleOffset;" -c particleShape1;

dynExpression -s "float $scaleOffset = (.2); \n \nsetAttr pointOnCurveInfo1.parameter (particleShape1.age); \n\nfloat $pos[] = `getAttr pointOnCurveInfo1.position`; \n\nvector $posvec = <<$pos[0], $pos[1], $pos[2]>>; \n\nparticleShape1.position = $posvec + $scaleOffset;" -rad particleShape1;

playbackOptions -min 1 -max 500; //move time slider to 500

playButtonForward;
playbackStateChanged;

}

/* Expression in a more readable format.

float $scaleOffset = (.2);

setAttr pointOnCurveInfo1.parameter (particleShape1.age);

float $pos[] = `getAttr pointOnCurveInfo1.position`;

vector $posvec = <<$pos[0], $pos[1], $pos[2]>>;

particleShape1.position = $posvec + $scaleOffset;
*/

CGTalk Moderation
11-10-2011, 06:49 PM
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.