mdz

Wrangle snippets


//PRIM Convert "shop material path" to groups
string group = split(s@shop_materialpath, "_")[-1];
setprimgroup(0, group, @primnum, 1);
//DETAIL_Set word attribute on font SOP 
//(Pre Requisite:enable "text attribute" on font sop > add a sort SOP based on "text index" attribute )
     int id = 0;
     int id_old = 0;
     int wordcounter = 0;

     for(int i=0; i<@numprim; i++)
     {
         id = prim(0,"textindex",i);
         
         if(id > id_old + 1) 
         wordcounter++;
         
         setprimattrib(0,"word",i,wordcounter);
         
         id_old = id; 
     }
//PRIM_Set group based on word attribute on font SOP (Pre Requisite: create "word attribute")
     if (@word == chi("select_word_index")){
         @group_blue= 1;
     }else{
         @group_pink=1 ;
         }	
//Velocity Curl Noise With Offset 
    float amp = chf("amp");
    float mult = chf("mult");
    float speed = chf("speed");
    v@N = v@N;
    v@v += cross(v@N,(curlnoise(v@N*amp+@Time*speed)))*mult;
//Initialize Glue Attributes on Constraints
    s@constraint_name = "Glue";
    s@constraint_type = "all";
    i@propagate_iteration = chi("propagate_iteration");
    //These attributes can be used to customize the properties of individual glue bonds.
    //f@strength = -1;
    //f@impulse_halflife = 0.1;
    //f@propagate_rate = 1.0;
//Dashed Lines on resampled curves 
    float u = vertexprimindex(0, @vtxnum) / float(primvertexcount(0, @primnum));
    float u_length = u * primintrinsic(0, 'measuredperimeter', @primnum);
    float u_anim = (u_length + @Time * chf('speed'));

    int waves = sin(u_anim * M_PI * chf('frequency')) < chf('gaps');
    v@Cd = hsvtorgb( set(u, 1.0, 1.0) ) * waves;
    @width= chf('width');
//Melt
    float m= chf("melt");
    float rx= chramp("effect",relbbox(@P).y);
    float rz= chramp("effect",relbbox(@P).y);
    float t= chf("thickness");

    @P= set(@P.x*m*rx+@P.x,clamp(@P.y+t*@N.y-m,getbbox_min(0).y+t*@N.y,getbbox_max(0).y),@P.z*m*rz+@P.z);
//Function convert spherical to cartesian cordinates
    vector sphereToCart(float lat, lon, rad){
        float x = -cos(lat) * cos(lon);
        float y = sin(lat);
        float z = cos(lat)* sin(lon);
        return rad * set(x, y, z); 
    }

    v@P = sphereToCart(radians(@lat), radians(@lon), 1.0);

    v@N = normalize(@P);  
//Taper
    if(chi("axis")==0){
        @P=set(@P.x,@P.y*chramp("profile",relbbox(@P).x)*ch("mult"),@P.z*chramp("profile",relbbox(@P).x)*ch("mult"));
    }
    else{
        if(chi("axis")==1){
        @P=set(@P.x*chramp("profile",relbbox(@P).y)*ch("mult"),@P.y,@P.z*chramp("profile",relbbox(@P).y)*ch("mult"));
        }
        else{
            @P=set(@P.x*chramp("profile",relbbox(@P).z)*ch("mult"),@P.y*chramp("profile",relbbox(@P).z)*ch("mult"),@P.z);
        }
    }

Resources

https://forums.odforce.net/