Jump to content

VEX Get Path Matrix In SOPs?


Atom

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();
	

Untitled-2.jpg

Edited by Atom
Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...