Jump to content

VEXpression Presets


Noobini

Recommended Posts

Ground Zero: pretty obvious what this does....ie. no more bothering with getting the box's height then half it and move it up blah blah blah...just do this 'one' liner....

attribexpression/snippet
    Ground Zero
    @P;@P.y -= getbbox_min(0).y

 

Edited by Noobini
Link to comment
Share on other sites

(Dirty) LookAt:

attribexpression/snippet
    Lookat 2nd Input
    (@P - getbbox_center(0)) * lookat(getbbox_center(1),getbbox_center(0)) + getbbox_center(0)

Why dirty ? coz it's manipulating points....not actually transforming the object

I used the Pighead as an easy object for illustration. By default, the pig is looking down on its Z axis...so if you are using a pointy object (ie. cone)...point your object down its Z axis first...

 

Edited by Noobini
  • Like 2
Link to comment
Share on other sites

Align: (to bbox extremities)

(sorry for breaking the 'one line' rule...)

attribexpression/snippet
    Align
    @P;
    int alignaxis = chi("axis");
    float offset = ch("offset");
    if(alignaxis == 0){
        @P.y -= getbbox_min(0).y - offset;
    }
    else if(alignaxis == 1){
        @P.y -= getbbox_max(0).y - offset;
    }
    else if(alignaxis == 2){
        @P.x -= getbbox_min(0).x - offset;
    }
    else if(alignaxis == 3){
        @P.x -= getbbox_max(0).x - offset;
    }
    else if(alignaxis == 4){
        @P.z -= getbbox_min(0).z - offset;
    }
    else {
        @P.z -= getbbox_max(0).z - offset;
    }

 

Edited by Noobini
Link to comment
Share on other sites

Stack:

attribexpression/snippet
    Stack
    @P;
    int stackaxis=chi("axis");
    float stackoffset=ch("offset");
    @P+=getbbox_center(1);
    if(stackaxis==0){
        @P.x+=getbbox_max(1).x-getbbox_center(1).x-getbbox_min(0).x+stackoffset;
    }
    else if(stackaxis==1){
        @P.y+=getbbox_max(1).y-getbbox_center(1).y-getbbox_min(0).y+stackoffset;
    }
    else{
        @P.z+=getbbox_max(1).z-getbbox_center(1).z-getbbox_min(0).z+stackoffset;
    }

 

Edited by Noobini
  • Like 2
Link to comment
Share on other sites

On 29/6/2017 at 0:06 AM, Noobini said:

Collision Deform:
- 1st input - Geo to deform
- 2nd input - Collider


attribexpression/snippet
    Collision Deform
    length(@P-point(1,"P",nearpoint(1, @P)))<ch("dist")?lerp(@P,@P+@N,ch("deform")*chramp("lip",fit(length(@P-point(1,"P",nearpoint(1,@P))),0,1,0,1))*(1-length(@P-point(1,"P",nearpoint(1,@P))))):@P

 

 

CheapAssCollisionDeform.hipnc

DUDE YOU'RE  AWESOME!!!

Link to comment
Share on other sites

  • 2 months later...

Planar Symmetrical Taper: unlike a 'normal' Taper that tapers from one end to the other, this taper starts from centre and
symmetrically tapers out to the 2 ends.

EDIT: orig version has hardcode of '- 0.5', now I've used 'cent' instead so you can slide the centre to where ever
you want, but normal usage is when you first apply the Point SOP, create the params then assign Centre  = 0.5 as default.

attribexpression/snippet
    PlanarSymTaper
    @P;
    int plane = chi("TaperPlane");
    float tap = 10*ch("Taper");
    float cent = ch("Centre");
    if(plane==0)
        {
        @P.x *= cos(tap*abs(relbbox(0,@P).y - cent));
        }
    else if(plane==1)
        {
        @P.y *= cos(tap*abs(relbbox(0,@P).x - cent));
        }
    else if(plane==2)
        {
        @P.x *= cos(tap*abs(relbbox(0,@P).z - cent));
        }
    else if(plane==3)
        {
        @P.z *= cos(tap*abs(relbbox(0,@P).x - cent));
        }
    else if(plane==4)
        {
        @P.y *= cos(tap*abs(relbbox(0,@P).z - cent));
        }
    else
        {
        @P.z *= cos(tap*abs(relbbox(0,@P).y - cent));
        }

 

Edited by Noobini
Link to comment
Share on other sites

so I watched this intro video:
https://www.thegnomonworkshop.com/tutorials/houdini-fast-track-vol-1-fundamentals

and saw the barrel, basically after you bend the staves, they have to be tapered to fit at the ends, so as you can see in the video, a Linear taper (in the Bend) was used....nah....doesn't look right, using the Smooth option got close..but still not quite right...plus you can see the
thickness of the stave is compromised...hence I thought, stuff it...I'll do my own Taper...and so PlanarSymTaper was conceived.

Then did me own barrel of fun HDA too...ahoy me zombie...

PlanarSymTaper1.jpg

Link to comment
Share on other sites

PlanarSymTaper:

ok, this version is improved. Previously, your geo needs to be properly centred around the world origin, so if you transform your 'box' somewhere...you'd notice the Taper effect goes wonky...

Now it does not matter where your geo is in the world, the Taper effect is always relative to the 'local' bbox.

attribexpression/snippet
    PlanarSymTaper
    @P;
    int plane = chi("TaperPlane");
    float tap = 10*ch("Taper");
    float cent = ch("Centre");
    vector c = getbbox_center(0);
    vector relbbox = relbbox(0,@P);
    
    @P -= c;
    if(plane==0)
        {
        @P.x *= cos(tap*abs(relbbox.y - cent));
        }
    else if(plane==1)
        {
        @P.y *= cos(tap*abs(relbbox.x - cent));
        }
    else if(plane==2)
        {
        @P.x *= cos(tap*abs(relbbox.z - cent));
        }
    else if(plane==3)
        {
        @P.z *= cos(tap*abs(relbbox.x - cent));
        }
    else if(plane==4)
        {
        @P.y *= cos(tap*abs(relbbox.z - cent));
        }
    else
        {
        @P.z *= cos(tap*abs(relbbox.y - cent));
        }
    @P += c;

 

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

Radar Selection:
(why separate expressions ? coz the GroupVEXpressions doesn't allow multiple statements, strictly 1 liner)

groupexpression/snippet
    Radar X
    chi("X_Axis")==0 ? degrees(acos(normalize(set(@P.x,0,@P.z)).x))<ch("angle") : degrees(acos(-normalize(set(@P.x,0,@P.z)).x))<ch("angle")

groupexpression/snippet
    Radar Y
    chi("Y_Axis")==0 ? degrees(acos(normalize(set(@P.x,@P.y,0)).y))<ch("angle") : degrees(acos(-normalize(set(@P.x,@P.y,0)).y))<ch("angle")

groupexpression/snippet
    Radar Z
    chi("Z_Axis")==0 ? degrees(acos(normalize(set(@P.x,0,@P.z)).z))<ch("angle") : degrees(acos(-normalize(set(@P.x,0,@P.z)).z))<ch("angle")

Please note: from 16.5 on, the VEXpressions.txt file is found in C:\Program Files\Side Effects Software\Houdini 16.5.xxx\houdini

(just edited to make it work for 3D object as well, ie. a box, not just flat objects)

 

 

Edited by Noobini
  • Like 2
Link to comment
Share on other sites

while fiddling about with the Radar...I couldn't find vangle()...does anyone know where it's gone ? I then followed the 'help' to try and get the signed angle...seems a bit convoluted so ended up doing my own basic trig...

Link to comment
Share on other sites

hillbillies aren't very good at maths, they can count to only 20 or 21...so how trivial does this vangle look ? I tried to do what the help told me to:

vangle(a, b ) will return the same result as acos ( dot (normalize(a), normalize(b)) ). It will not produce a negative result because the dot product is symmetric, and does not take the order of a and b into consideration.

You can define a turning order with the left hand rule or something similar.

Tip

Try the following expression to get a signed result: sign(dot(cross(cross(a,b),b),a)) * vangle(a,b)

but for whatever reason couldn't get it to work...so did my own thing in the end...

esp. the signed thing, so imagine 12oclock, I want to know the angle between the vector {0,0,-1} and some vector, assuming also flat on the ground...so I was hoping to get results from 0 - 360 degrees...but with my current setup, if you want 45degs selection, you'd actually get 45deg on either side of 12oclock

Edited by Noobini
Link to comment
Share on other sites

Radar: (all in one)

groupexpression/snippet
    Radar
    chi("Axis")==0 ? degrees(acos(normalize(set(@P.x,0,@P.z)).x))<ch("angle") :
    chi("Axis")==1 ? degrees(acos(-normalize(set(@P.x,0,@P.z)).x))<ch("angle") :
    chi("Axis")==2 ? degrees(acos(normalize(set(@P.x,@P.y,0)).y))<ch("angle") :
    chi("Axis")==3 ? degrees(acos(-normalize(set(@P.x,@P.y,0)).y))<ch("angle") :
    chi("Axis")==4 ? degrees(acos(normalize(set(@P.x,0,@P.z)).z))<ch("angle") : degrees(acos(-normalize(set(@P.x,0,@P.z)).z))<ch("angle") 

 

Link to comment
Share on other sites

  • 1 year later...

been awhile...in H18 the presets are in:

C:\Program Files\Side Effects Software\Houdini 18.x.xxx\houdini\VEXpression.txt

top points:

groupexpression/snippet
    top points
    relbbox(0,@P).y==1

 

bottom points:

groupexpression/snippet
    bottom points
    relbbox(0,@P).y==0

obviously it wouldn't work if your geo is uneven like a tube with mountain applied to it.

Link to comment
Share on other sites

midsection points:

groupexpression/snippet
    midsection points
    abs((relbbox(0,@P).y)-0.5)<ch("spread")

hmmm...interesting...if I change to prims, it still works !!! might revise the snippets soon.

Edited by Noobini
Link to comment
Share on other sites

revised snippets: work for both prims/points. Since absolute 1 or 0 are no longer there, just enter 0.001 for points in spread, slightly more for prims.

top:

groupexpression/snippet
    top
    relbbox(0,@P).y> (1-ch("spread"))

 

bottom:

groupexpression/snippet
    bottom
    relbbox(0,@P).y < ch("spread")

 

Edited by Noobini
Link to comment
Share on other sites

Corner Points:

groupexpression/snippet
    Corner Points
    chf("concav_vexity")==0?@curvature<-1:chf("concav_vexity")==1?@curvature>1:abs(@curvature)>chf("concav_vexity")

0 - concave only

1- convex only

other - both concave/convex depending on magnitude, note magnitude can exceed 1.

works best on 2D objects, ie. if you extrude some flat object, I'm not sure how the measure curvature algo works for this.

EDIT: ahh got it, I thought it didn't work properly but it did, I just forgot to enable Output Back in the extrude, so once Output Back is enabled, it will select the corners correctly on both top and bottom level of the extruded object. I will not select 'inline' points tho.

Extruded_Corner_Points.jpg

Edited by Noobini
  • Like 1
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...