Jump to content
CinnamonMetal

No tangent on point ?

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 = 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×