Jump to content

(SOLVED) Deform with particles or in SOP in X and Z directione


Recommended Posts

  • Librarian changed the title to (SOLVED) Deform with particles or in SOP in X and Z directione

i found a way Yupiiii:wub:

s@name = sprintf("piece_%d", i@iy);
// get actors names
string name = sprintf(s@name);
// split actors name up into array using space as delimiter
string actorSplit[] = split(name, " ");
// join array with underscores to create the group name
string groupName = join(actorSplit, "_");
// set group name
setpointgroup(0, groupName, @ptnum, 1, "set");
float k = 2 *noise(@Time);
@P *= set(1/sqrt(k),k,1/sqrt(k));
@P += @P *flownoise(@P*3,@Time);
i[]@pCaptPts = pcfind(1,"P",@P,1e15,8);
float r = 1.1 *distance(point(1,"P",@pCaptPts[-1]),@P);

vector delta;
float totalweight_cpt;
matrix3 totalxform_cpt;

foreach(int cpt;@pCaptPts){
    vector oldcenter = point(1,"P",cpt);//Rest_POint_latice
    vector newcenter= point(2,"P",cpt);//deformed_point_latice
    
    matrix3 xform_cpt = 1;
    int n[] = neighbours(1,cpt);
    //int n[] = neighbours(2,cpt);
    
    matrix3 totalxform = 0;
    float totalweight = 0;
        if (len(n)>1){
        vector lastdp,lastrestdp;
        for (int i;i<len(n);i++){
        
        if(i==0){
        
        lastdp = point(1,"P",n[-1])-oldcenter;
        lastrestdp = point(2,"P",n[-1])-newcenter;
        
        }
        vector dp = cross(dp,lastdp);
        vector restdp = cross(restdp,lastrestdp);
        
        vector up = cross(dp,lastdp);
        vector restup = cross(restdp,lastrestdp);
        
        float w = sqrt(length(up)*length(restup));
        
        matrix3 restxform = maketransform(normalize(restdp),normalize(restup));
        
        matrix3 xform = maketransform(normalize(dp),normalize(up));
        
        totalxform += w*invert(xform)*restxform;
        totalweight += w;
        
        lastrestdp = restdp;
        lastdp = dp;
        
        }
        
        if(totalweight!=0){
            totalxform/= totalweight;
            if(chi("rigidprijection"))
            totalxform = polardecomp(totalxform);
            xform_cpt = totalxform;
            
        }
 }  
 
float dist = distance(oldcenter,@P);
float weight = pow(1-pow(dist/r,2),2);
vector diff = point(2,"P",cpt)-oldcenter;

vector newp = @P;
newp -= oldcenter;
newp *= xform_cpt;
newp += oldcenter;

newp += diff;
delta += weight*(newp-@P);
totalweight_cpt += weight;
totalxform_cpt += xform_cpt*weight;
}


delta /= totalweight_cpt;

@P += delta;

 

fire35eee.gif

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