Transfer Point Positions based on attribute

   7837   4   0
User Avatar
Member
50 posts
Joined: May 2015
Offline
I have a mesh with a primitive group and another mesh where I've extracted that primitive group and done some work on it (in say Zbrush). The primitive group is part of a greater mesh. What I've done is created an attribute called pindex which is assigned the point number. when I do a delete node using my primitive group my pindex maintains the original point number value. Then I attribute copied that to my modified zbrush mesh since both topologies match. So far so good. Here's where things get murky for me. I want to use some form of a loop to check if pindex matches the pointnum from the original geometry upstream. Then I want to change the P vector so it matches the modified geometry. I thought to do this with a point VOP and perhaps a for loop vop, but I never get a value of true indicating that pointnum is equal to pindex. In the for loop vop I basically imported pindex from my second input (that's where I plugged in my modified geo), and ran a compare against ptnum. Anyone have any hints or maybe an even better way to go about this?
User Avatar
Member
678 posts
Joined: July 2005
Offline
AttribWrangle in Point mode:

int numpt2 = npoints(@OpInput2);
for (int i = 0; i < numpt2; i++)
{
int ID;
getattribute(@OpInput2, ID, “point”, “id”, i, 0);

if (i@ptnum == ID)
{
vector newPos;
getattribute(@OpInput2, newPos, “point”, “P”, i, 0);

v@P = newPos;
}
}


You could do the same in Detail mode and loop only thru second input points and modify P of first input point that you find with ID attribute from second input. It could be faster that way.
User Avatar
Member
50 posts
Joined: May 2015
Offline
Yeah much simpler. I need to learn more about VEX. I achieved the same result via nodes after playing around with connecting more inputs to the for loop hold hold much needed outputs.
User Avatar
Member
8554 posts
Joined: July 2007
Offline
or just
int pt = findattribval(1, “point”, “id”, @ptnum);
if (pt!=-1) @P = point(1, “P”, pt);
also should much faster
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
50 posts
Joined: May 2015
Offline
tamte I had to read yours and look at the documentation a bit, but yeah it's pretty ingenious actually. +1 internets for you.
  • Quick Links