CGTalk > Software > Autodesk Maya > Maya Dynamics
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 07-26-2009, 02:44 PM   #1
EyeForComplexity
Guest
 
Posts: n/a
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: http://www.eye-for-complexity.com/Misc/HelpInstance.zip
I would appreciate it if anyone could help me.
 
Old 07-27-2009, 04:25 AM   #2
mandark1011
Expert
 
mandark1011's Avatar
portfolio
Michael Lemon
Fx Artist
Canada
 
Join Date: Apr 2003
Posts: 1,042
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
 
Old 07-27-2009, 08:13 AM   #3
EyeForComplexity
Guest
 
Posts: n/a
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.

Thanks
 
Old 07-27-2009, 10:04 AM   #4
YourDaftPunk
Have Polygons/Will Travel
 
YourDaftPunk's Avatar
portfolio
Shawn Lipowski
3D Artist
Look Effects, Inc.
New York, US
 
Join Date: Jun 2002
Posts: 439
Send a message via AIM to YourDaftPunk
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.
-shawn
__________________
twitter | vimeo
 
Old 07-27-2009, 10:19 AM   #5
ctp
Frequenter
Christian Toft
Denmark
 
Join Date: May 2004
Posts: 117
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-27-2009 at 12:41 PM.
 
Old 07-27-2009, 01:47 PM   #6
EyeForComplexity
Guest
 
Posts: n/a
Talking

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



exactly what I wanted to achieve,
Thanks!!!
 
Old 07-28-2009, 08:44 AM   #7
mandark1011
Expert
 
mandark1011's Avatar
portfolio
Michael Lemon
Fx Artist
Canada
 
Join Date: Apr 2003
Posts: 1,042
my bad the expression should have had the locator name in it too lol. Im glad you found a solution that worked.
 
Old 07-28-2009, 11:48 PM   #8
linuxInferno
VFX Artist
 
linuxInferno's Avatar
portfolio
Matt Thorson
USA
 
Join Date: Dec 2007
Posts: 88
Send a message via AIM to linuxInferno
I've also seen this done with follicles. Cool script!
__________________

 
Old 10-07-2009, 04:59 PM   #9
bigbossfr
aka DeeX
 
bigbossfr's Avatar
portfolio
Damien BATAILLE
Renderer/lighter/shading
Paris, France
 
Join Date: Feb 2005
Posts: 576
Lightbulb

Hi,
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.

Thank.
 
Old 10-08-2009, 11:05 PM   #10
TheRispo
legendary monkeytician
 
TheRispo's Avatar
portfolio
Jose Eduardo
Guadalajara, MX
 
Join Date: Oct 2009
Posts: 142
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)
http://rapidshare.com/files/2904695...ya2010.zip.html

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
 
Old 10-14-2009, 09:00 PM   #11
bigbossfr
aka DeeX
 
bigbossfr's Avatar
portfolio
Damien BATAILLE
Renderer/lighter/shading
Paris, France
 
Join Date: Feb 2005
Posts: 576
Up for my question.
 
Old 12-29-2009, 10:04 AM   #12
phleX
Veteran
 
Join Date: Jan 2005
Posts: 96
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)
 
Old 12-30-2009, 12:09 AM   #13
linuxInferno
VFX Artist
 
linuxInferno's Avatar
portfolio
Matt Thorson
USA
 
Join Date: Dec 2007
Posts: 88
Send a message via AIM to linuxInferno
Talking

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
__________________

 
Old 12-31-2009, 04:32 PM   #14
phleX
Veteran
 
Join Date: Jan 2005
Posts: 96
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...
 
Old 12-31-2009, 08:04 PM   #15
Derek Wolfe
Frequenter
 
Join Date: Nov 2004
Posts: 255
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 12:20 AM.


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