Need Help with Aiming Particles

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  11 November 2011
Need Help with Aiming Particles

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


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

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



/* 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;
  11 November 2011
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 06:13 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.