align object to velocity direction

   14697   14   2
User Avatar
Member
512 posts
Joined: July 2009
Offline
hello,

i've got a little issue here, been trying and trying but can't figure out a solution, i guess it's not complicated, i just don't get it

here's the thing. I created a sphere and added normals to each point with a point SOP. Then i connected a POPNET to it and emitted a particle for each point and let it fly in the normal direction of the points. (attributes>velocity>$NX, $NY, $NZ)

Next i created a cylinder. Through the copy node i wanted to align a cylinder to each emitted particle's velocity direction. How can i achieve this?

some help would be appreciated,
thx & with the best regards,

Manu
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
349 posts
Joined: Aug. 2006
Offline
you need to orient the tube to its z-axis in world space, as that is how to copySOP works.

See file attached.

Attachments:
align_to_normals1.hipnc (52.7 KB)

User Avatar
Member
8769 posts
Joined: July 2007
Offline
the “v” attribute is automatically recognised by copy SOP and the copies are z-axis aligned with it as ragupasta said

but you need to keep in mind that “v” is not the only attribute according to which copies can be aligned, actually it has the lowest priority

so if your particles have “N” attribute as well, then the copies are aligned to “N” attribute
the “orient” attribute overrides both “v” and “N”
and “rot” attribute kind of sums up with “N” or “v' or ”orient“ alignment

the last one is ”up“ attribute which complements ”N“ or ”v“ and gives you more control of how the copies are aligned

so if you want to align copies with ”v“ make sure that there is no ”N“,”rot“ or ”orient" attribute on the points/particles

all the above apply to instances as well
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
512 posts
Joined: July 2009
Offline
thx a lot guys, that's exactly what i was looking for!
I didn't create an “add velocity” (ch(“nx”)) in the particle rollout of the point SOP in the first place, i guess that was fault nr.1?? then i didn't orientate my object to the z-axis in world space, i guess that was my second.

but hmm Tamte, the stuff you're telling me, it's a little confusing I'm new to houdini. I basically know that one can create attributes for the particles and access them on the geometry level, but that's about all i know. It's definitely a field that i want to learn more about. Has the stuff you told me something to do with the attribute node or else with the attribute rollout of the copy node?
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
8769 posts
Joined: July 2007
Offline
i didn't mean to confuse you
just ignore it for now if your problem is solved

i only posted that info because when you look at ragupasta's example
it seems to work ok, but add gravity to particles and you'll clearly see that the copies are aligned to normals and not velocity
it may work for your needs though

it may not tell you much at this time maybe, just feel free to return to this page when you advance a bit and it'll start making sense to you.
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
512 posts
Joined: July 2009
Offline
of course! thx anyway for the advice.
But hmm the more i contemplate about ragupastas example — why did he put this channel expression in the particle velocity attribute of the point node? doesn't make sense to me and if i switch it off, nothing happens, the whole thing is still intact?!
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
512 posts
Joined: July 2009
Offline
btw Tamte, where can i learn more about those attributes you talked about? like “N”, “ROT” “ORIENT” etc. ???
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
8769 posts
Joined: July 2007
Offline
if you are using Inherit Velocity for particles you need either normals “N” attribute or velocity “v” attribute on your source geometry

since that Point SOP creates both, you can left one of them off

i recommend you to set normals to Keep Normals
and velocity to Add Velocity with values $NX, $NY, $NZ

this way the source geometry will have only “v” attribute for particles to inherit velocity from

particles will have no “N” attribute, so the copied objects will be aligned with velocity
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8769 posts
Joined: July 2007
Offline
asnowcappedromance
btw Tamte, where can i learn more about those attributes you talked about? like “N”, “ROT” “ORIENT” etc. ???

http://www.sidefx.com/docs/houdini10.0/copy/ [sidefx.com]
http://www.sidefx.com/docs/houdini10.0/copy/varying [sidefx.com]
http://www.sidefx.com/docs/houdini10.0/copy/instanceattrs [sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
8769 posts
Joined: July 2007
Offline
oh, and welcome to the forum

i hope i didn't scare you too much for start
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
512 posts
Joined: July 2009
Offline
thx a lot mate!! really nice of you!
and well … i'm not scared, en contraire i'm looking forward to learn this software although there will be a lot i wont understand straightaway, i'm new to expressions and maths ))
lets see first i have to go through all those example files and try to get an overview to all those nodes and expressions and then … i'm psyched of the possibilites houdini provides, before i used 3DS Max and compared with that, Houdini is a whole new experience …

cheers!
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
512 posts
Joined: July 2009
Offline
tamte
if you are using Inherit Velocity for particles you need either normals “N” attribute or velocity “v” attribute on your source geometry

since that Point SOP creates both, you can left one of them off

i recommend you to set normals to Keep Normals
and velocity to Add Velocity with values $NX, $NY, $NZ

this way the source geometry will have only “v” attribute for particles to inherit velocity from

particles will have no “N” attribute, so the copied objects will be aligned with velocity

one last thing, after that let's call it a day )
didn't you mean “Add Velocity with values $VX, $VY, $VZ” ??? :?
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
8769 posts
Joined: July 2007
Offline
asnowcappedromance

didn't you mean “Add Velocity with values $VX, $VY, $VZ” ??? :?


no, the values $NX, $NY, $NZ are correct
it will create “v” attribute with the the values as normals
it actually knows $NX, $NY, $NZ even it there is no “N” attribute on the geometry

but the values for $VX, $VY, $VZ will be 0,0,0 if there is no “v” attribute before
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
512 posts
Joined: July 2009
Offline
got it
again, thx for the help buddy )))
http://vimeo.com/user2522760 [vimeo.com]
http://stormbornvfx.com/ [stormbornvfx.com]
Manuel Tausch
User Avatar
Member
5 posts
Joined: Aug. 2013
Offline
Hey guys! I dig up this topic cause I've a related doubt.

What if, for example, my particles are a fish cluster swimming aligned to its velocity, who stops at some point and we'd like them to point at a specific direction?

I'm not sure if I'm doing rigth, but bellow is how I'm trying to blend the velocity orientation (p@vel_orient) with the target orientation (p@target_orient).

//Blend from velocity orientarion to target orientation
@orient = lerp(p@vel_orient, p@target_orient, chf(“blend”));

The target is working fine, but I'm stucked in how to replicate the same align to velocity behaviour to save under the p@vel_orient attribute in order to work with the interpolation?

Or, if there is a better way, please let me know. Thanks!

UPDATED BELLOW

I found this other discussion answered by Matt (tokeru)
https://forums.odforce.net/topic/27316-rotateorientalignmentquaternionsetc/ [forums.odforce.net]

The code bellow does the trick, but the orientation gets crazy when the speed gets closer to zero.
p@vel_orient = dihedral({0,0,1} ,@v);

A blur in the velocity make it better but don't fix all the problem.
Now I'm trying to fix that.

Any suggestions are welcome.
Thanks!
Edited by Marco_M - Oct. 13, 2020 21:58:32
Marco Melantonio

FX/CFX Artist
https://www.endorfina.me/ [www.endorfina.me]
  • Quick Links