Jump to content

implicit uv problem


Recommended Posts

Hi guys,

I have a bit of a mindbender. My idea was to make a complete line trail from a point, make some attributes on the line and then carve that line to emit particles behind an object (reading the percentage attribute off the points). I went ahead and computed percent along the path for each point on the line. Except that when I use that percentage in a primuv expression, it does not align with the point. Here is the vex code (run in detail mode in a wrangle node) used to calculate percentage along the path:

float perimeter = prim(0,"perimeter",0);
float len = 0;
for (int i=0; i<(@numpt-1); i++){
    len += float(length(vector(point(0,"P",i+1))-vector(point(0,"P",i))));
@totallen = len;

the last bit is just to check if my aggregated length is the same as the measure sop length (which it is).

As you can see in the attached HIP file, the point follows the line, but diverges from the original point positions (which is the whole point of the setup). Hope it is something very obvious I'm missing and you guys can point me in the right direction.


Link to comment
Share on other sites

Okay, found a workaround (as it usually happens, within seconds of asking other people :). I used a xyzdist to transfer the implicit uv to the points instead of calculating the procentage. If somebody can explain why the implicit u coordinate differs from calculated percentage that much, I would be very thankful. Might save me some headache in the future.

P.S. for anybody interested,  here is the wrangle code used to get the u coordinate:

int prim;
vector uv;
@perc = uv[0];


Link to comment
Share on other sites

Procedural UVs more like @vtxnum / (@numvtx-1) than marched_length / curve_length.

One way to go is to use uvsample function:

float perc = fit(@Frame, 1, 100, 0, 1);
vector pos = uvsample("op:../CURVE","P", "uv", set(perc, 0, 0));  // @uv is set(@perc, 0, 0).
addpoint(0, pos);

Another is to use primuvconvert. No need to compute percentage then:

#include <math.h>
float perc = fit(@Frame, 1, 100, 0, 1);
vector2 uv = primuvconvert("op:../CURVE", set(perc, 0), 0, PRIMUV_UNITLEN_TO_UNIT);
vector pos = primuv("op:../CURVE", "P", 0, uv);
addpoint(0, pos);


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.

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...