Jump to content

"GameDev Path Deform" issue with overlapping areas...


Masoud

Recommended Posts

Hi guys;

I tried to deform a box using "GameDev Path Deform" as you can see in the image below which works fine but how can I fix the artifacts (penetrations) at the overlapping areas?

(I mean I need to fix the penetrations and make a clean topology).

 

Thanks for helping.

PathDeform.hip

PathDeform01.jpg

Edited by Masoud
Link to comment
Share on other sites

100 % Its possible .I'm just not qualified for that Task ;)..I can visualize and draw in mine Head  ..but lack of the knowledge  ..

someone maybe gonna Help :wub:
Maybe if we use this code for intersection inside Path deform and make something different
 

//verti
vector getIntersection(vector A;vector B;vector C;vector D;int test)
{
   if(A==B || C==D) return B;
   vector n1 = normalize(B-A);
   vector n2 = normalize(D-C);


   if(abs(1.0-abs(dot(n1,n2)))<1e-5){
       test = 0;
       return B;
   }

   vector AC = C - A;
   float d1 = ( dot(n1,AC) - dot(n2,AC)*dot(n1,n2) ) / ( 1 - dot(n1,n2)*dot(n1,n2) );
   float d2 = ( -dot(n2,AC) + dot(n1,AC)*dot(n1,n2) ) / ( 1 - dot(n1,n2)*dot(n1,n2) );

 
   if(d1<0 || d2<0){test=0;return B;}
   else if(d2>distance(C,D)){test=0;return B;}

   
   vector p1,p2;
   p1 = A + d1*n1;
   p2 = C + d2*n2;
   test = 1;
   return p2;
}

int listPoints1[] = primpoints(1, 0);
vector A = point(1,"P",listPoints1[0]);
vector B = point(1,"P",listPoints1[1]);
int curPrimOnC= vertexprim(0,@vtxnum);
int curPrimOnD= vertexprim(0,@vtxnum+1);
if(curPrimOnC!=curPrimOnD){
    removepoint(0,vertexpoint(0,@vtxnum));
    return;
}
vector C = point(0,"P",vertexpoint(0,@vtxnum));
vector D = point(0,"P",vertexpoint(0,@vtxnum+1));
vector p=C;
int test = 0;
p = getIntersection(A,B,C,D,test);
removepoint(0,vertexpoint(0,@vtxnum));
if(test==1){
    addpoint(1,p);
}
//prim
vector getIntersection(vector A;vector B;vector C;vector D)
{
   if(A==B || C==D) return B;
   vector n1 = normalize(B-A);
   vector n2 = normalize(D-C);

   
   if(abs(1.0-abs(dot(n1,n2)))<1e-5) return B;

   vector AC = C - A;
   float d1 = ( dot(n1,AC) - dot(n2,AC)*dot(n1,n2) ) / ( 1 - dot(n1,n2)*dot(n1,n2) );
   float d2 = ( -dot(n2,AC) + dot(n1,AC)*dot(n1,n2) ) / ( 1 - dot(n1,n2)*dot(n1,n2) );

   
   if(d1<0 || d2<0) return B;
   else if(d2>distance(C,D)) return B;

   
   vector p1,p2;
   p1 = A + d1*n1;
   p2 = C + d2*n2;
   return p2;
}

int listPoints1[] = primpoints(0, @primnum);
vector A = point(0,"P",listPoints1[0]);
vector B = point(0,"P",listPoints1[1]);
vector p=B;
float minimumDist = 1e+6;
for(int i=0;i<nprimitives(1);i++){
    int listLinearVertices[] = primvertices(1, i);
    for(int curIndex=0;curIndex<len(listLinearVertices);curIndex++){
        int curPrimOnC = vertexprim(1,listLinearVertices[curIndex]);
        int nextIndex = curIndex+1;
        int curPrimOnD = vertexprim(1,listLinearVertices[nextIndex]);
        if(curPrimOnC!=curPrimOnD){
            continue;
        }
        vector C = point(1,"P",vertexpoint(1,listLinearVertices[curIndex]));
        vector D = point(1,"P",vertexpoint(1,listLinearVertices[nextIndex]));
        vector outP = getIntersection(A,B,C,D);
        if(outP!=B && distance(B,outP)<minimumDist){
            p = outP;
            minimumDist = distance(B,outP);
         }
    }
}
removeprim(0, @primnum, 1);
addpoint(0,p);

It works if  You make poly expand before Path deform :wub:

Edited by Librarian
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...