Jump to content

VEX: Point rotate around curve axis


morn66

Recommended Posts

Hi Julien,

you need to first transform the point to its local coordinate space before applying the rotation. This is done via (@P-hit_P), then you apply the matrix and finally restore the transform to the world position by adding hit_P again.

vector @P;

// Get the nearest hit attributes
int hit_prim_id = -1;
vector hit_prim_uv;
xyzdist(1,@P,hit_prim_id,hit_prim_uv);
vector hit_P = primuv(1,"P",hit_prim_id,hit_prim_uv);
vector hit_N = normalize(primuv(1,"N",hit_prim_id,hit_prim_uv));

// Rotate around the nearest hit point
matrix m = ident();
float angle = radians(ch('amount'));
rotate(m, angle, hit_N);
@P = (@P-hit_P) * m + hit_P;

 

I've gone ahead and updated your file. I've also switched to the xyzdist() instead of nearpoint() function to always get a smoothly interpolated Position and Normal.

If you have further questions let me know :)

Cheers,

Luca

 

 

Vex_pointRotateAroundCurveAxisFixed.hiplc

  • Thanks 1
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...