Jump to content

VEX Get Path Matrix In SOPs?

Recommended Posts

I have a NULL at the object level moving along a path.

I have another GEO object that pulls in a source mesh.

I want that source mesh to follow the path as well. However, I am inside SOPs.

I am looking for the VEX code that will transfer the NULL object matrix into the Translate, Rotate and Scale XYZ values of a Transform node at the SOP level.

I can fetch the matrix from the object but I am not sure how to assign it?

matrix m = optransform("obj/null_FOLLOWS_PATH", @Time);
//rotate ( m, radians ( 20 ), { 0, 1, 0 } );
v@path_P *= m;


Here is some pseudo code to demonstrate the intention of the code I am looking for.

	matrix m = optransform("obj/null_FOLLOWS_PATH", @Time);
	v@my_pos = m.extract_transform();
	v@my_rot = m.extract_rotation();
	v@my_scale = m.extract_scale();


Edited by Atom

Share this post

Link to post
Share on other sites

Thanks F1, that is a great example file. I think the transform by attribute is the simplest for my needs.

But the explicit code example is valuable as well.

#include <math.h>
#define XFORM_T 0
#define XFORM_R 1
#define XFORM_S 2

matrix xform = optransform("/obj/null1");
vector pivot = {0,0,0};

v@t = cracktransform(XFORM_SRT, XFORM_XYZ, XFORM_T, pivot, xform);
v@r = cracktransform(XFORM_SRT, XFORM_XYZ, XFORM_R, pivot, xform);
v@s = cracktransform(XFORM_SRT, XFORM_XYZ, XFORM_S, pivot, xform);






Edited by Atom

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