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 CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2011
Sweet!

Just wanted to say a massive thanks to all who contributed to this thread.

Massive help!
 
  05 May 2011
Hi everyone,

How do i then offset the particles along the surface normal (and possibly animate it over time)?

Thanks
F
__________________

 
  05 May 2011
goal offset attribute in particle shape.
 
  06 June 2011
Question

can you do that with nparticles the same way?
i do not get the instance normal alignment working..
 
  06 June 2011
There's some great information here, I have something I've been trying to do related to this.

I'm trying to create an enormous flock of bats that can be dynamically influenced. One problem I'm having is getting the direction of the individual bats and awareness of the other bats around it.

Anybody have ideas?
 
  07 July 2011
Trying to keep this little kick ass thread alive.

I have bugs crawling along skin and I've got them rotating around based on the normals which is great. And random Y rotation is easy enough.

I am however trying to figure out how I can get the Y rotation to aim in the direction that the particles are moving.

Any ideas?
 
  03 March 2012
Bringing this one back.

Anyone have a solution for the above post.

I'm working on something similar and can't seem to get the insects to aim in the direction of the velocity and have them orient to the surface normal.
 
  03 March 2012
Figured it out like 2 minutes later and thought I'd post the solution in case anyone else needs it.

Aim Direction : Velocity
Aim World Up: goalWorldNormal0PP

With that setup in the instancer, the particles will aim toward their velocity and still be oriented correctly on the surface.
 
  06 June 2012
Hey guys,

I don't know what i'm doing wrong..
I guess that when it comes to scripting I get lost most of the times...

Anyways, could someone help me figure out why this is not working for me? All I wanted is for the instances make a kind of grid with crosses, using the sphere as a dome with a cross on each vertex...

I used YDP scene file as a start and copied the expressions...

I uploaded my scene.
please, guys...
Thanks a lot!!!
Attached Files
File Type: zip Teste_Particulas_01.mb.zip (8.5 KB, 22 views)
__________________
Check out my REEL
 
  06 June 2012
Ok....hmm

I managed to constrain the instances to the sphere's normals.
__________________
Check out my REEL
 
  09 September 2012
Originally Posted by ctp: Runtime expression:
// define a variable with the particle position
   vector $p = particleShape1.position;
   
   // get surface normal at particle position
   vector $normal = `nearestPointOnMesh -ip ($p.x) ($p.y) ($p.z) -normal -q pPlane1`;
   
   // define worldUp
   vector $worldUp = <<0,1,0>>;
   
   // calculate normalized directions by which to align the y and z axis of the instance object
   vector $directionOfZaxis = unit(cross( $normal, $worldUp ));
   vector $directionOfYaxis = unit(cross( $directionOfZaxis, $normal ));
   
   // solve each angle, result in degrees
   float $rotZ = rad_to_deg(( atan2( ($normal.y), ($normal.x) ) ));
   float $rotY = rad_to_deg(( asin( -($normal.z) ) ));
   
   // feed result into the rotationPP attribute
   particleShape1.rotationPP = << particleShape1.randomRotationX, $rotY, $rotZ >>;
   


Optionally you can add the runtime expressions in the creation too.
Also, notice the "pPlane1", which should be corrected to match the name your poly object.


ctp,

I'm trying a variation of yours but i can't seem to get it right! I work with the Z up and thus i'm attempting to modify your code for one with the Z up.

This is the expression that i'm creating:

// sets the orient axis for the instance
particleShape1.aimUp = <<0,0,1>>;

// get surface normal at particle position
vector $particlePos = particleShape1.position;
vector $normal = `nearestPointOnMesh -ip ($particlePos.x) ($particlePos.y) ($particlePos.z) -nr -q pPlane1`;

// orient the instance
particleShape1.aimDir = $normal;

// random rotation for Z axis
particleShape1.randomRotationZ = rand(360);

//solve each angle, convert to degrees
float $rotX = rad_to_deg( atan2( ($normal.y), ($normal.z) ) );
float $rotY = rad_to_deg( asin( -($normal.x) ) );

// asign random rotation in Z
particleShape1.rotationPP = << $rotX, $rotY, particleShape1.randomRotationZ >>;

any help with this will be greatly appreciated, i've attached my file for your reference.

Thanks,

-G
Attached Files
File Type: zip Test Instancer.mb.zip (121.1 KB, 36 views)

Last edited by gdepena : 09 September 2012 at 05:19 PM.
 
  10 October 2012
[ should have read the posts above, ignore me]

Acidream = genius.

Last edited by vsPiotr : 10 October 2012 at 02:00 AM.
 
  02 February 2013
hey guys

great thread and another resurrection!

so i was mucking around with YourDaftPunks scene (thanks) and stimuli's post trying to aim the poly planes to a camera in the y axis whilst maintaning the orientation to the surface.

i am trying to replicate a ground cover system in a game engine. don't ask why, but I am!

i think stimulis solution for aiming would break the surface orientation?

thanks for the informative read guys.

Kev
__________________
akewt.com
 
  04 April 2013
Originally Posted by linuxInferno: 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


He can add a custom attribute randomRotation and give and give it this expression :

particleshape1.randomRotation = rand(0,0.360,0)

and map it to the rotation, like that he will get random rotation on all the instances on the Y axis.
the bad thing about doing it with Index is that more indexes in the instances effect the ram during the rendering and slow down a bit the render if the objects instances get pretty big with complicated shader network complicated .
thanks
 
  10 October 2013
getting degrees with angleBetween command, and with random X rotation

// getting particle location
vector $p = nParticleShape1.position;

// calculating normal
vector $normal = `nearestPointOnMesh -ip ($p.x ) ($p.y) ($p.z) -normal -q pSphere1`;

// solving angles
float $angBet[] = `angleBetween -euler -v1 1 0 0 -v2 ($normal.x)($normal.y)($normal.z)`;

// setting rotation with random
nParticleShape1.rotationPP = <<($angBet[0]+rand(180)), $angBet[1], $angBet[2]>>;

here your object for instancing should be heading x direction with its "up"

Last edited by PurpleRainbow : 10 October 2013 at 09:09 PM.
 
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
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 06:03 AM.


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