1. Houdini tutorial to create tentacles that shoot out and grab floating ameba using Dops.

    NOTICE: Houdini 14 - Point wrangle syntax has changed. Put @ in front of global variables, and look out for errors.

    The web page containing the wrangle code no longer exists. Use the code below instead:
    SOPS INITIAL SETUP
    ######################################################
    ######################################################
    //***Cd_v_and_grps
    //---Make noise
    float noff = ch("noise_offset");
    vector n = vector(noise(@P*.4+noff))-.5;
    //---P Noise
    @P += n*20*@uv.x;
    //---v Noise
    @v = n*5;
    @Cd = {1,0,0};
    //---Anchor point group for tentacles
    if(@uv.x==0)
    @group_anchor = 1;
    //---End point group for tentacles
    if(@uv.x>=1.0)
    @group_ends = 1;


    //***anim_start_and_end_frames
    //Params
    float start_frm = 30;
    float rand_start = 45;
    float anim_frms = 5;
    float pullin_frms = 75;
    //---
    //Start and end frames for animation events
    float rnd = floor(random(@id)*rand_start);
    f@start = start_frm + rnd;
    f@end = @start + anim_frms;
    f@pullin_end = @end+pullin_frms;


    //***pullin_ameba
    //---Params
    float pullin_mult = .05;
    float pullin_freq = 8;
    float pullin_pause = 30;
    //---Calculations
    vector P2;
    getattribute(@OpInput2, P2, "point", "P", @id, 0);
    vector P_new = (P-P2)*pullin_mult+P2;
    P = fit(Frame, @end+pullin_pause, @pullin_end+pullin_pause, P, P_new);
    //---Add noise to pullin
    if(Frame>@end+pullin_pause){
    float n = fit(noise(Time*pullin_freq+@id*888),.4,.6,.5,1.5);
    P = (P-P2)*n+P2;
    }


    INSIDE DOPS
    ######################################################
    ######################################################
    //***react_when_stabbed
    vector pull_vec = normalize(P - v@tentacle_origin);
    v += fit(dot(pull_vec, N), -1, -.8, 20, 0) * -N;
    v += fit(dot(pull_vec, N), .8, 1, 0, 20) * N;


    //***v_pull_away_from_tenticle
    //---Params
    float pull_deform_amt = 0;
    float vel_mult = .95;
    float pull_vel_amt = 40;
    float pull_freq = 18;
    float pull_dir_range = .5;
    float pull_dir_freq = 5;
    //---
    //---Calc
    float pullnoise = fit(noise(Time*pull_freq+@id*100), .4, .6, -.6, 1);
    vector pull_vec = normalize(P - v@tentacle_origin);
    vector rot_rand = set(noise(Time*pull_dir_freq+@id*33)-.5, noise(Time*pull_dir_freq+@id*44)-.5, noise(Time*pull_dir_freq+@id*55)-.5);
    rot_rand *= 720 * pull_dir_range;
    4@rot_mx = maketransform(0,0,set(0,0,0),rot_rand,set(1,1,1));
    pull_vec *= @rot_mx;
    //---Deform geom
    P += fit(dot(pull_vec, N), .8, 1, 0, pull_deform_amt) * N * pullnoise;
    //---Velocity
    v *= vel_mult;
    v += fit(dot(pull_vec, N), .85, 1, 0, pull_vel_amt) * N * pullnoise;


    #***switch_pre_post_strike
    {
    float hit_frame = point(opinputpath(".", 0), 0, "end", 0);
    if($FF==hit_frame)
    return 1;
    else if($FF>=hit_frame+2)
    return 2;
    else
    return 0;
    }


    //***pointwrangle_strike
    //Params
    float track_frms = 24;
    float track_amt = .02;
    //---
    //---Vector from tenticle base to ameba center
    vector P2;
    getattribute(@OpInput2, P2, "point", "P", 0, 0);
    vector P3;
    getattribute(@OpInput3, P3, "point", "P", 0, 0);
    vector strike_vec = P3-P2;
    //---
    //---Target pt along strike_vec
    float strike_len = length(strike_vec);
    vector strike_norm = normalize(strike_vec);
    vector P_target = P2 + strike_norm*strike_len*@uv.x;
    //---
    //Track - pts start tracking towards ameba
    if(Frame>=@start-track_frms && Frame<=@start){
    float blend = fit(Frame, @start-track_frms, @start, 0, 1);
    P = fit(blend*track_amt, 0, 1, P, P_target);
    }
    //---
    //Strike - pts strike ameba
    if(Frame>@start && Frame<=@end){
    float blend = fit(Frame, @start, @end, 0, 1);
    vector P_start = P-(P_target - P)*blend;
    vector P_new = fit(blend, 0, 1, P_start, P_target);
    P = P_new;
    }


    #***switch_pick_obj
    {
    if(strmatch("ameba*", stamps("..", "OBJNAME", "NULL")))
    return 1;
    else if(strmatch("tentacle*", stamps("..", "OBJNAME", "NULL")))
    return 2;
    else
    return 0;
    }


    SOPS TENTACLES
    ######################################################
    ######################################################
    //***calc_grow_ends
    vector P1;
    getattribute(@OpInput1, P1, "point", "P", 0, 0);
    vector P2;
    getattribute(@OpInput1, P2, "point", "P", Npt-1, 0);
    N = normalize(P1-P2);


    //***prep_curves
    @width = chramp("./set_width", @uv.x);
    @width *= .5;
    //---
    if(@uv.x < .5)
    P += (chramp("./grow_curve", @uv.x))*N*ch("grow_amt");
    if(@uv.x > .5)
    P -= (chramp("./grow_curve", @uv.x))*N*ch("grow_amt");
    //---
    addvariablename("width", "WIDTH");

    # vimeo.com/119029196 Uploaded 4,799 Plays 5 Comments

tutorial

kim duk rae

Browse This Channel

Shout Box

Heads up: the shoutbox will be retiring soon. It’s tired of working, and can’t wait to relax. You can still send a message to the channel owner, though!

Channels are a simple, beautiful way to showcase and watch videos. Browse more Channels.