matrix3 m = maketransform(@N,@up);@orient = quaternion(m); vector4 pitch = quaternion({1,0,0}ch(‘pitch’)); vector4 yaw = quaternion({0,1,0}ch(‘yaw’));vector4 roll = quaternion({0,0,1}*ch(‘roll’)); @orient = qmultiply(@orient, pitch);@orient = qmultiply(@orient, yaw);@orient = qmultiply(@orient, roll);
vex
VEX: Rotation Around Axis
float angle = chf(“angle”); vector4 rot = quaternion(radians(angle), {1,0,0}); @N=qrotate(rot, @N);
VEX: Create Points at Prim Centres
int Pt_Num; @N = @N; Pt_Num = addpoint(0, @P); setpointattrib(geoself(), "N", Pt_Num, @N, "set"); removeprim(0, @primnum, 1);
VEX: split string and convert to integer
//Split @anotherAttribute based on ‘_’ string myString[] = split(s@anotherAttribute, “_”); //Use last element as attribute value s@tempString = myString[-1]; //convert string to integer i@myIntegerFromString = atoi(s@tempString);
VEX: Bend Wrangle
Taken from https://tosinakinwoye.com/2017/01/23/houdini-vex-snippets/ //Input is a line //Resample SOP on line for more points //Activate curveu attrib in resample SOP //Remap curveu to shape of bend @curveu=chramp(“ramp”,@curveu); float bamt = chf(“bend_amt”); //bend amount vector benddir = chv(“bend_dir”); //bend direction @P+= benddir * bamt * @curveu;
VEX: SOP Rotation
f@speed = fit01(rand(@ptnum), ch('minSpeed'), ch('maxSpeed')); float angle = (ch('angle')+@ptnum)*@speed; vector axis = sample_direction_uniform(rand(@ptnum*ch('seed'))); @orient = quaternion(angle, axis);