VEX
General
- https://yakymoto.com/vex
- https://gist.github.com/killiantimsit/ddfef8b357289d884f774cdcf890c3d2
- for each string pattern matching https://www.sidefx.com/forum/topic/53141/
- printf("Hello World");
- print2f("Hello World with Point %d\n", @ptnum);
- total: @numpt, @numvtx, @numprim
- currentid: @ptnum, @vtxnum, @primnum
- One of the most comprehensive VEX attribute reference: https://wiki.johnkunz.com/index.php?title=VEX_Attribute_Glossary#What_is_VEX.3F
- https://www.sidefx.com/docs/houdini/vex/functions/match.html
- View Vex Code through VOPS rmb VEX Click.
@mops_falloff="0.2-0.3" @mask=0-0.1
group ws
\\ Rotate the sphere on an orbit like that nucleus/proton/electron illustration
Center X: (sin($F * 8) * 2)
Center Y: (cos($F * 8) * 2)
``Infinite Carve Loop Expression
carve expression fit01((($F-1) % 15) / 15, 0, 1)
\\ IF/ELSE STATEMENT
\\ A
if (@P.y>0) {@N.y=1;}
else {@N.y=-1;}
\\ B
valueToSet = (condition) ? valueIfTrue: valueIFalse;
@N.y = (@P.y>0) ? 1 : -1;
\\ Generate Orient Values from @N and @up attributes
vector nN = normalize(v@N);
vector nup = normalize(v@up);
p@orient = quaternion(maketransform(nN, nup));
\\ Another Orient values but animated
@N = {0,1,0};
float s = sin(@Time);
float c = cos(@Time);
@up = set(s,0,c);
@orient = quaternion(maketransform(@N, @up));
\\ Create Group using vex instead of the Group Node
\\ The @group_name syntax is the key
float @stiffness;
int @group_inside;
if(@group_inside==1) {
@stiffness = 1;
}
else {
@stiffness = 1000;
}
\\ FOR LOOP STATEMENT
s[]@groupNames = {"trunk","leaves","branch"};
foreach (string name; @groupNames)
{
if(match(sprintf("*%s*",name),s@path)==1){
setprimgroup(0,name,@primnum,1,"set");
}
}
int npt = npoints(0);
vector all_pos[];
resize(all_pos, npt);
for(int i = 0; i < npt; i++) {
all_pos[i] = point(0, "P", i);
}
//
int numPoints = npoints(0);
// Iterate through each point
for (int pt = 0; pt < numPoints; ++pt) {
foreach (int @tag; t) {
if (pt==tag) {
v@Cd = {1,0,0};
}
}
}
int isTagged = 0; // Initialize a variable to track if the point is tagged
foreach (int tagValue; tag) {
if (pt == tagValue) {
isTagged = 1; // Set the flag if the point is tagged
break; // Exit the loop since we found a match
}
}
foreach (tag; t) {
if (pt==t) {
v@Cd = {1,0,0};
}
}