How could I promote an attribute in wrangle?

   3470   4   0
User Avatar
Member
426 posts
Joined: Aug. 2015
Offline
Hi guys;
In a point wrangle, I want to get the Normal of a specified primitive (from input geometry) and pass the value as @MyNewNormal point attribute to output. (Normal from a “Primitive” to Normal of a “Point”)

I tried these codes, but it doen't work:

int PrimNumber;
vector Prim_uv;
float maxdist = 10;
float dist = xyzdist(1, @P, PrimNumber, Prim_uv, ch("MaxDist"));
i@PrimNumber = PrimNumber;

v@MyNewNormal = prim(1, "N", PrimNumber);
Edited by Masoud - Oct. 16, 2017 04:09:25
Masoud Saadatmand (MSDVFX)
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
If you want to get the normal from a specific prim (f.ex prim zero) you can use:
int success;
v@N = primattrib(1, 'N', 0, success);
By using xyzdist you get the normal from the primitive that is closest to the point your wrangle is running over.

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
426 posts
Joined: Aug. 2015
Offline
Thank you bonsak;
As you said, I tried xyzdist, and it worked:
vector Norm = xyzdist(1, @N, PrimNumber, Prim_uv, ch("MaxDist"));
@N=Norm;
Masoud Saadatmand (MSDVFX)
User Avatar
Member
9416 posts
Joined: July 2007
Offline
Masoud
Thank you bonsak;
As you said, I tried xyzdist, and it worked:
vector Norm = xyzdist(1, @N, PrimNumber, Prim_uv, ch("MaxDist"));
@N=Norm;
xyzdist just returns the float distance, so if it looks like it works in your case, it may just be a coincidence
to get the real primitive normal use:
int pid;
vector puv;
xyzdist(1, @P, pid, puv, ch("MaxDist"));
if (pid!=-1) {
    @N = prim_normal(1, pid, puv);
}
if you want interpolated normal in case vertex or point N exists then:
int pid;
vector puv;
xyzdist(1, @P, pid, puv, ch("MaxDist"));
if (pid!=-1) {
    @N = primuv(1, "N", pid, puv);
}
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
426 posts
Joined: Aug. 2015
Offline
Thank you “Tamte”

You are right, it was my mistake.
Masoud Saadatmand (MSDVFX)
  • Quick Links