Vex and solver

   1438   0   0
User Avatar
Member
141 posts
Joined: 3月 2016
オフライン
Hello

As part of learning Houdini and vex, i've been adapting some stuff from Daniel Shiffmans excellent Nature of Code book, in this case a pretty basic random walker.

To make it my own I've used a Solver followed by a trail node and metaballs to create a fairly cool organic mitosis setup.

It's all working okay but im just really conscious that by trying to teach myself i might not be doing things in the most efficent way possible and was hoping someone could offer any tip/suggestion on ways they might condense/optimize the code

In the solver ive setup two Attribute Wrangles (that's all there is in the sop), the first is set to run over a single point in the first frame and then multiple points as frames progress.

The second wrangle is a set to detail to create new points.

Wrangle 1
string RandDir = "none";
float ranLoc = fit01(rand(@ptnum),-0.01,0.01);

float ranNum = rand(@ptnum+@numpt);

    if (ranNum > 0 && ranNum < 0.2){
    RandDir = "up";
    i@Age = i@Age +1;
    @P.z = @P.z +ranLoc;
    } 
    
    else if (ranNum > 0.2 && ranNum < 0.4) {
    RandDir = "down";
    i@Age = i@Age +1;
    @P.z = @P.z -ranLoc;
    }
    
    else if (ranNum > 0.4 && ranNum < 0.6){
    RandDir = "left";
    i@Age = i@Age +1;
    @P.x = @P.x -ranLoc;
    }
    
    else {
    RandDir = "right";
    i@Age = i@Age +1;
    @P.x = @P.x +ranLoc;
    }

Wrangle 2 linked to Wrangle 1

i@Age = point(0,'Age',0);
vector pos = point(0,'P',i@numberOfPoints);

//Adds a new point from the last point every XX frames
if (i@Age == 10){
addpoint(0,pos);
setpointattrib(0,'Age',0,0,"set");
i@numberOfPoints++;
}

Any comments much appreciated
Also should this type of thing actually be posted in the Indie/Apprentice channel?
Edited by Hatchery - 2020年6月8日 07:37:41
Love Houdini
  • Quick Links