Jump to content
Librarian

HUD-FUI-UI-DESIGN IN HOUDINI

Recommended Posts

in this order
 

int dim = sqrt(@numelem);
vector pos = set(@elemnum%dim,@elemnum/dim)/(dim-1);

float point_spacing = 1.0/(dim-1) + 0.00001;
pos -= {0.5,0.5};
if (length(pos)*2<0.9*noise(pos*5.1)*@Time){
int pt = addpoint(0,pos);
setpointattrib(0,"pt_sp",pt,point_spacing);
}
int near_pts[] = pcfind(0,"P",@P,@pt_sp,999);

if (len(near_pts)<chi("fate"))
@Cd = hsvtorgb(dot(@P,{1,1,1}),1,1);
else @Cd = {0,0.1,0};
vector pos = @P;
i@class = pcfind (1,"P",pos,1000,2)[0];
@Cd = rand(@class);
int pts[] = pcfind(0,"P",@P,@pt_sp,999);
i[]@pt= pts;
int near_pts;
int class;

foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
    
    
if(near_pts<chi("fate")) 
@P.z += 0.001*@class+0.3;
else 
@Cd ={0,0.1,0};
int pts[] = pcfind(0,"P",@P,@pt_sp+ch("r"),999);
i[]@pt= pts;
int near_pts;
int class;

foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
    
    
if(near_pts<chi("fate")) 
@P.x -= 0.7;

//@P.z += 0.001*@class+0.1;
else {@P.x -=1.4;}
int pts[] = pcfind(0,"P",@P,@pt_sp,999);
i[]@pt= pts;
int near_pts;
int class;

foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
if(@P.z == 0 && near_pts<chi("fate")){
    @P.z += 0.1;
    @Cd = {1,0,0};
    }
    else if(@P.z == 0.1) @Cd = rand (@class);

foreach
 

int pts[] = pcfind(0,"P",@P,@pt_sp,999);
i[]@pt = pts;
int near_pts;
int class;
foreach(int pt; pts){
    int bool = @class == point(0,"class",pt);
    if(bool) near_pts++;
    }
    
float u =float(detail(1,"iteration"))/(detail(1,"numiterations")-1);
if(@P.z == 0 && near_pts<chi("fate")){
    @Cd = rand(@class);
    @P.z += 0.1*chramp("ramp",u);
    }

 

cfunsgsuuyyyssssff.gif

sgsgsgsgsg.jpg

Share this post


Link to post
Share on other sites

cut any dir
 

string in0 = @OpInput1;
int nprims = nprimitives(in0);

int op;
string operation = chs("keep");
if(operation == "above")op= 1;
if(operation == "below")op= 2;
else op= 0;

vector cutDir = normalize(chv("cutDir"));
vector cutOrigin = chv("cutOrigin");
float dist = ch("dist");

//////////////////////////////////////////////////////////////////

for(int primnum = 0; primnum < nprims; primnum++)
{
    int vers[] = primvertices(0, primnum);
    int length = len(vers);
    
    int border=0;
    int prim0pts[];
    int prim1pts[];
    int numNewPts = 0;
    
    // check if this mesh is split
    for(int i = 0; i< length; i++)
    {
        int srcPoint = vertexpoint(in0, vers[i]);
        vector srcP = point(in0, "P", srcPoint);
        vector srcPDir = normalize(srcP - cutOrigin);
        
        float dot = dot(cutDir, srcPDir);
        
        if(dot<=0)border += 1;
    }
    
    // if it is not cut, maybe remove and done.
    if(border == 0)
    {
        if(op == 2)removeprim(geoself(),primnum,1);
        //        continue;continue;
    }
    else if(border == length)
    {
        if(op == 1)removeprim(geoself(),primnum,1);
        //continue;
    }
    
    else
    {
        // cut mesh
        int srcPoint;
        float srcDot;
        
        for(int i = 0; i< length; i++)
        {
            int hedge = vertexhedge(in0, vers[i]);
            
            //int primary = hedge_isprimary(in0, hedge);
            //if(primary == 0)continue;
            
            int destVtx = hedge_dstvertex(in0, hedge);
                    
            srcPoint = vertexpoint(in0, vers[i]);
            int destPoint = vertexpoint(in0, destVtx);
            vector srcP = point(in0, "P", srcPoint);
            vector destP = point(in0, "P", destPoint);
            
            vector srcPDir = normalize(srcP - cutOrigin);
            vector destPDir = normalize(destP - cutOrigin);
            srcDot = dot(cutDir, srcPDir);
            float destDot = dot(cutDir, destPDir);
            
            if(srcDot > 0)
            {
                push(prim0pts, srcPoint);
            }
            else if(srcDot == 0)
            {
                push(prim0pts, srcPoint);
                push(prim1pts, srcPoint);
            }
            else if(srcDot < 0)
            {
                push(prim1pts, srcPoint);
            }
            
            
            if((sign(srcDot) != sign(destDot)) && srcDot != 0 && destDot != 0)
            {
                //@Cd=set(float(i)/length, float(border)/length, 0);
                float bias = -destDot/(srcDot - destDot);
                int newPt = addpoint(geoself(), lerp(destP, srcP, bias));
                push(prim0pts, newPt);
                push(prim1pts, newPt);
        
                numNewPts += 1;
            }
        }
        
        
        
        // remove original mesh, and add 2 meshes which cover original
        
        removeprim(geoself(),primnum,1);
        if(op != 2)
        {
            int newPrim = addprim(geoself(), "poly");
            foreach(int pt; prim0pts)
            {
                addvertex(geoself(), newPrim, pt);
            }
        }
        if(op != 1)
        {
            int newPrim = addprim(geoself(), "poly");
            foreach(int pt; prim1pts)
            {
                addvertex(geoself(), newPrim, pt);
            }
        }
    }
}

alpha+info

 

cut.jpg

e90.hiplc

info.jpg

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

×