|07 July 2009||#1|
help needed with particle instancing based on poly normal direction.
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: http://www.eye-for-complexity.com/Misc/HelpInstance.zip
I would appreciate it if anyone could help me.
|07 July 2009||#2|
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.
|07 July 2009||#3|
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||#4|
Have Polygons/Will Travelportfolio
Look Effects, Inc.
New York, US
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:
Seems to animate nicely and your geometry can be any shape.
|07 July 2009||#5|
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.
|10 October 2009||#9|
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||#10|
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 bad..so I have to use a lot of words to try to understand myself.. sorry about that
|12 December 2009||#12|
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||#13|
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||#14|
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...
|Thread Closed share thread|