help needed with particle instancing based on poly normal direction.

Become a member of the CGSociety

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

Thread Tools Display Modes
  07 July 2009
Question help needed with particle instancing based on poly normal direction.

Hi there

I'm having difficulty getting the particle instancer to behave a certain way. In a nutshell what I want to do is emit particles with instanced poly planes that face the same direction as the poly normals that they are emitted from.

and I am stuck! haha
Here is an image of what it looks like at the moment.

All I want is to be able to have those instanced planes to be facing outward from birth.

here is the above scene:
I would appreciate it if anyone could help me.
  07 July 2009
place a locator at the centre of your sphere and put this code in creation and runtime

vector $pos = worldPosition;
$px = $pos.x;
$py = $pos.y;
$pz = $pos.z;
//now make a custom vector att (aimDir)
aimDir = <<$px,$py,$pz>>;

and plug that into the aim direction of your instancer. As long as your sphere doesnt deform or translate without the the locator your good to go.

good luck
  07 July 2009
Thanks mandark for the quick reply, It hadnt occured to me to make them aim at a locator ahha... but its not working quite how I want it to. the instances stay the way they were and if i move the locator up a bit they rotate 90 degrees which happens with aim constraints when they arent set up right I think.

Is there a way that I could find the direction of the polygon normal and plug that into the instancer rotation? so its not dependent on aiming and I could make it work on any shaped object.

  07 July 2009
Maya has a closestPointOnMesh node that can also return the closest normal. I did a test with a particle expression that queries the cPOM node and sets a per particle attribute to orient the instance based on the normal:

scene file

Seems to animate nicely and your geometry can be any shape.
twitter | vimeo
  07 July 2009
Here's yet another option...

First make sure you have "Need Parent UV" ticked in your Basic Emitter Attributes.

Then make the sphere a goal for the particles. Make sure the goal weight is NOT zero (use 1.0 if you want them to stick to an animated surface)

Select the particle object. Look in the Attribute Editor, find the particleShape node/tab. Look in the section called "Per Particle (Array) Attributes" for the following attributes:

Parent U, Parent V, Goal U, and Goal V.

If they are not there, you need to add them - you do this in the section just below, called "Add Dynamic Attributes", hit the "General" button. You will find them in the "particle" tab.

Enter a Creation Expression for the particles (right-click on one of the Per Particle attributes and select "Creation Expression...". This opens the Expression Editor.) Type in the following:

goalU = parentU;
goalV = parentV;

and hit the "Create" button in the Expression Editor.

In the Attribute Editor, on the particleShape node, look for "Goal Weights and Objects". Hit the button "Create GoalWorldNormal 0 PP".

In the "Instancer (Geometry Replacement)" section, set the "Aim Direction" to be GoalWorldNormal0PP.

(In short, you have now made the particles aware of their place of birth on the object, in terms of U and V coordinates. These coords are then set to be their birth goal, and is then used to read the normal from the object. And you then feed this to the instancer.)

Now, this is more specific to the scene you had already made...
- you had Rotation Type (in the Instancer section) set to "Force". Set it to "None" as is the default.

- select the polyPlane (the object you use for instancing).
- in the channel box, enter -90 for Rotation Z.
- Freeze Transformations (if your polyPlane is not at the origin of the scene, then you will want to use the option to only freeze rotations)

The polyPlane's object X-axis is now pointing same direction as the normal of the polyPlane, and it will align as you described.

Note: you can hide your instance object, so you don't have to move it away from the scene origin. Making the original instance object invisible will not affect rendering of the particle instances.

Last edited by ctp : 07 July 2009 at 12:41 PM.
  07 July 2009

"YourDaftPunk" and "ctp", thanks so much, I tried out both of your techniques and they work great!!.

exactly what I wanted to achieve,
  07 July 2009
my bad the expression should have had the locator name in it too lol. Im glad you found a solution that worked.
  07 July 2009
I've also seen this done with follicles. Cool script!

  10 October 2009

Just a question : how can i give a random rotation on all instancer ? (with the YourDaftPunk scene for example).

I tried a random vector in the "rotation" in the instancer, it isn't work.

  10 October 2009
Hi everyone... I also have a question about this subject:

I created a particle grid with simple cubes instanced, and aplied a white shader to a face of the cube, and a black shader to the opposing side, then I made the particles collide with a plane with a sine deformer, and made the point in wich they collide the particle's goal position, and used ctp's method to make the instances get the poly normal direction.

So.. what I got so far is a bunch of particles that sticks to a plane and get a nice curvy form (from the sine deformer). the trick however is that I need to animate the rotation of that instance based on its position to a locator, so.. when the locator is close to the particle the instance is rotated 0 degrees showing the white face, and when is far away.. the instance rotates 180 degrees to show the black face of the cube.. the problem is: I can't get the curvy shape (wich I get setting "aim direction" to goalWorldNormal0pp) and the control of the rotation (using a custom atribute called "RotationPP" conected to Rotation), kind of like one overrides the other or something.

I'm now realizing that my question is basically the same as bigbossfr's.. so... I'm sorry for that extra words... basically what I want to know is if there is a way to add rotation to a instance.. and still conserve all the normal aiming goodnes.. kind off..

here's my scene if anyone cares to take a look (maya2010, but an ascii file is included)

Thank you everyone..
ps. English is obviusly not my first languaje and therefore is kind of I have to use a lot of words to try to understand myself.. sorry about that
  10 October 2009
Up for my question.
  12 December 2009
I found this thread, which helped me a lot (YourDaftPunk's methode, that is).
But I too need a way to give the instances a random rotation (still they have to be perpendicular to the surface but with random rotation along the arrow's length axis).
Old thread reanimated ;o)
  12 December 2009

gotta love the undead threads

duplicate your instanced geo a couple of times and rotate them randomly in y.
freeze all transforms
instance with indexPP set to rand( 0 , numOfInstances+1 )

its kind of a cheat because the idea is to just make a connection instead of duplicating and making your scene bigger. but sometimes getting it done is more important than doing it "properly"
Just like when someone hands you a scene file with an outliner thats 5000 pages long of unnamed nodes and you dump in a new group named "screwYouUnorganizedJerk"
...or maybe its just me. haha

  12 December 2009
Thanks mthorson,

if I don't find a more elegant way that's certainly a possibility.
Thing is, I already have at least 10 different objects that are distributed randomly with the indexPP method. I would have to duplicate all of them several times and rotate them, which would give me loads of objects...
  12 December 2009
There is a scrpt called vector2rot, use it to get the rotations, then add a random value to the y rotation.
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 03:44 AM.

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