# 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 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 on other sites

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

##### Share on other sites

PolyFrame SOP is a good way to create normal, tangent and bitangent vectors.

##### 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 on other sites
3 hours ago, Guillaume said:

dir = p1-p1;

I guess you meant dir = p0 - p1

##### 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 on other sites
20 hours ago, 6ril said:

I guess you meant dir = p0 - p1

yes!

##### Share on other sites

Thanks everyone, @petz provided some wonderful solutions, just in time too super amazing! Thanks petz.

Here's the file with solutions.

obj_along_path_SOPS_02.hipnc

• 2

## Create an account

Register a new account