Jump to content
Noobini

VEXpression Presets

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

Share this post


Link to post
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 1

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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!!!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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;

 

Share this post


Link to post
Share on other sites

is it just me or has SESI put some of the snippets here into their H16.5 ?:

C:\Program Files\Side Effects Software\Houdini 16.5.268\houdini\VEXpressions.txt

(yes...my head is swelling at an alarming rate...)

  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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...

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I meant it's easy to copy "acos (dot(normalize(a), normalize(b)))" from the docs. My last best result in counting was "potato" before I run away.

Here is what I typically use to get 0-360 degrees:

 

  • Like 1

Share this post


Link to post
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") 

 

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

×