Jump to content
miccetro

object along curve with correct orientation in SOPS

Recommended Posts

Hi community, I'm trying to use the primuv vex function to move an object along a curve in sops and have it correctly oriented as well. Any ideas?

I've attached a hip file. Thanks.

obj_along_path_SOPS_01.hip

Share this post


Link to post
Share on other sites

You'll need to have a normal 'N' attribute on the curve to start with.
The Path Utility tool creates such a curve.

Plus, you'll need to evaluate the position using primuv() a little bit ahead of the sampling position to get the direction vector.

n = primuv( using "N", at ulocation ) -> returns an up vector.
p0 = primuv( using "P", at ulocation ) returns the position.
p1 = primuv( using "P", at ulocation + 0.01 ) returns the position ahead.
dir = p1-p0;

then you can use the lookat vex function to build a rotation matrix.

So the trick is to get a good way to define the normal direction on the curve.

 

Edited by Guillaume

Share this post


Link to post
Share on other sites

Thanks for responding Guillaume, if you could send a file that would be great.:)

Share this post


Link to post
Share on other sites

Thanks pusat, I used it but my problem is how to make the rotation matix correctly for this and apply it to the object.

Share this post


Link to post
Share on other sites
3 hours ago, Guillaume said:

dir = p1-p1;

I guess you meant dir = p0 - p1

Share this post


Link to post
Share on other sites
1 hour ago, miccetro said:

Thanks pusat, I used it but my problem is how to make the rotation matix correctly for this and apply it to the object.

You can use maketransform VEX function and pass 2 of the vectors from PolyFrame depending on how you want the matrix to be oriented. This will give you a rotation matrix.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×