PDA

View Full Version : orient particles along surface normal


mechaniac
08-17-2009, 06:20 PM
hey
Ive used nParticles to emit an instanced geometry from a poly surface.
Its jewelry on a dress.

http://i65.photobucket.com/albums/h220/mechaniac12/diamond_dress_screenshot_01.jpg

They are all facing into the same direction now, but I want them to be oriented along the emitters surface normal. I guess there´s a way to do this... but we couldnt work it out.
any help very much appreciated.

best,
christof

swampjesus
08-17-2009, 06:36 PM
Umm, from the top of my head I think you can use "closestPointOnMesh" plugin and feed the particle position to the node in the creation/runtime expressions and set particle orientation that way ( you'll have to use setAttr and getAttr- commands for setting and getting the point and normal info to/from closestPointOnMesh ).

mechaniac
08-17-2009, 06:50 PM
hey swampjesus!
first of all, many thanks for your reply.
is it really that complicated? Ive got no idea how to program stuff like that. Actually... ive got no idea what your talking about.... :(
is there no way to tell a surface emitter to orient the particles into the normal direction? sthg like a button? (but I guess that would be too easy... for maya users at least)

YourDaftPunk
08-17-2009, 07:03 PM
I've demonstrated the cPOM node before:
http://forums.cgsociety.org/showpost.php?p=6006153&postcount=4
There's an example scene there.

That's from this thread (CPT's post after mine has another solution):
http://forums.cgsociety.org/showthread.php?f=86&t=789536

-shawn

Jacobborsting
08-18-2009, 08:42 AM
You could goal your particles to the surface and use 'Goal Point Normal' as the aim direction for your instanced objects.

Remember to check the "need parent UV" thingy on the emitter. Also add GoalU,V and parent U,V, and add this to your creation expression:

goalU = parentU;
goalV = parentV;

You may need to rotate your diamond object and freeze the transform, to get it to orient right.

edit: I just saw that this was the same solution as CPT's post :)

mechaniac
08-18-2009, 09:16 AM
hey Jacobborsting
hey YourDaftPunk
many thanks for your replies! very helpful indeed. Its working... BUT only with maya particles and not with nParticles... :(
porblem is, I dont know how to have maya particles self collide. So all my jewels are sticking into each other when rendering.

So i cant make maya particles self collide
and I cant make nParticles orient to the surface normals.... is there a solution?

Aikiman
08-18-2009, 10:43 AM
Instead of using surface emission you could just goal your particles with a value of 1 meaning they will line up to the vertices of your mesh, then just set initial state.

Phlok
08-18-2009, 10:53 AM
Give them an initial Speed of 1 and check for the velocity vector.

ctp
08-18-2009, 10:20 PM
It seems you're in need of a better way to distribute particles on a surface, so they don't overlap to begin with...?

I made a sort of "population test" a while back. I'm not going to take the time to explain it in detail, but you can download an example scene here. (http://3dhotdog.com/exampleScene/populationTest.zip)

In brief what it does is test the distance of every newborn particle to all existing particles (within same particleObject). If distance is lower than a certain value, the particle will be killed. It's gets a little slow after a while, but let it run till you've got the amount of particles you want, stop and set initial state, and zero out the emission.

Look in the expression editor for the expressions (creation and runtime before dynamics) regarding particleShape1. The certain value (distance) is found in the runtime expressions in a line that reads:

if ($distBetwGoals < 1)

Change the number to control the minimum distance required between particle positions.

Hope it will help you to a solution.

Cheesestraws
08-18-2009, 10:26 PM
If you use nParticles there is an option on the nParticleShape node called overlap pruning under the emission settings that will stop particles overlapping on emission. It is based on the particles radius, so if you increase the radius you can determine how close they will be on emission.

Jacobborsting
08-19-2009, 09:07 AM
I did a test using a radialfield as source field, and checking the lenght of the inputForce's vector to see how close a particle is to another. Inspired by Adrian Graham's boat example.

I think its a bit faster to evaluate, than looping through all the particles.

ctp
08-19-2009, 02:17 PM
I think you're right ;)

mahigitam
09-14-2009, 08:16 AM
Jacobborsting (http://forums.cgsociety.org/member.php?u=289111)
hi, i tried using ur method but its not woring for me..cud u plz c wer i did wrong..

used attribuets same as u

proxPP is t

clearedPP is cl


i used goal but not emission from surface

also cud u plz explain wat does inputForce[0] do...

as i understood,as long as the particles are in the range of field,their inputForce[0] value goes on increasing and when they come out of the range of field it decreases to 0...

thank u very much

Jacobborsting
09-14-2009, 10:05 AM
Hi Mahigtam,

Your radial field is connected as inputForce[1] not [0]. Check the connections between the field and the particleShape in the hypergraph.

The input index is unique and can only be used once, so if you disconnect the field and connect it again the index will have been changed and your expression needs to be updated.

mahigitam
09-14-2009, 10:16 AM
oh yeah i did a mistake there...checked everythign except that...thank u very verymuch

CGTalk Moderation
09-14-2009, 10:16 AM
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.