prim_normal

   3018   4   2
User Avatar
Member
767 posts
Joined: 4月 2014
Offline
I'm hoping someone can tell me what the prim_normal() function can be used for; besides possible creating a normal map ?
Edited by _Christopher_ - 2016年9月1日 23:56:18
【T】【C】【S】
User Avatar
Member
1799 posts
Joined: 10月 2010
Offline
I use it quite a lot actually. Prim_normal returns the interpolated normal of a primitive at any given baricentric UV location on such primitive.

For example, if you wanted to blast all primitives facing away from a camera (given a cameraViewVector variable that you created previously) , you can do this:

.
.
.
vector primN = prim_normal(0, @primnum, 0, 0);

if (dot(primN, cameraViewVector) > 0)
{
removeprim(0, @primnum, 1);
}

this is akin to the primuv function, but to get primitive normals more directly without having to have an N attribute


-G
User Avatar
Member
767 posts
Joined: 4月 2014
Offline
Helpful Gary, except what are the float u, float v arguments, the UV coordinates on the mesh and if so how can I find specific UV coordinates on the mesh ?
【T】【C】【S】
User Avatar
Member
1799 posts
Joined: 10月 2010
Offline
the U and V are the parametric coordinates of that particular primitive (i.e. baricentric coords of a triangle, or the U and V location of a nurbs patch). A lot of other functions/VOPs actually return those coordinates (i.e. the xyzdist and intersect VOPs return the u and v at the intersection point). if you just want the normal of a polygon prim, keep those at 0, 0, and you will be fine
-G
User Avatar
Member
767 posts
Joined: 4月 2014
Offline
【T】【C】【S】
  • Quick Links