Jump to content

No tangent on point ?


CinnamonMetal

Recommended Posts

I'm hoping someone can help. 

I'm attempting to do a parallel transform for points on a mesh; whereas the tangent of the point follows the surface, another vector follows the edge to which the vector rests upon and finally the normal for the point.

If you take this code apply it to a sphere making sure the fuse sop is after the sphere followed by a primitive wrangler it should work with no errors.  This setup is taken from an Entagma tutorial; the first problem is, I'm not seeing tangents for each of the points after creating the attribute for the tangent ?

 

i[]@vrtList = primvertices(0,@primnum);
int vp1 = vertexpoint(0, @vrtList[0]);
int vp2 = vertexpoint(0, @vrtList[1]);
vector midpoint = lerp(point(0, "P", vp1), point(0, "P", vp2), 0.5);
i@PointList = addpoint(0,midpoint);

int pnts[] = primpoints(0,@PointList);
int pointCount = len(pnts);
vector firstTangent = normalize(point(0,"P",pnts[1]) - point(0,"P",pnts[0]));
vector firstNormal = {0,1,0};

vector helper = normalize(cross(firstNormal,firstTangent));
firstNormal = normalize(cross(firstTangent,helper));

// Forward Declarations

vector bitangent = {0,0,0};
float theta = 0;

vector tangents[] = {};
vector normals[] = {};

// fill arrays

for(int i = 0; i<pointCount-1;i++){
    push(tangents,normalize(point(0,"P",pnts[i+1]) - point(0,"P",pnts[i])));
    push(normals,firstNormal);
    }
// set values for last point

push(tangents,tangents[pointCount-2]);
push(normals,normals[pointCount-2]);

//parallel transport 


// set attributes
for(int j=0;j<pointCount;j++){
setpointattrib(0,"PT_tangent",pnts[j],tangents[j],"set");
}


//vector helper = cross(

//vector mainPoint = 

//vector firstTangent = 

 

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