Skip to content

Kuchavo/VEX-Snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Logo

VEX-Snippets

A collection of useful snippets for Houdini.

⚠️ Сurrently repository in development.

Geometry

Objects

View contents

Primitives

View contents

Vertices

View contents

Points

View contents

Normals

View contents

Camera

View contents

Arrays

View contents

Groups

View contents

Viewport

View contents

Math

View contents

Masks

View contents

maskFromMetaball

Mask creation from metaball.

// Mask from metaball [Point Wrangle]
  f@mask = clamp(metaweight(@OpInput2,@P),0,1);
  @Cd = f@mask;
Example


⬆ Back to top

remapRandom-11

Remapping random from 0:1 to -1:1.

// Remaping random from 0:1 to -1:1 [Point Wrangle]
  float random = rand(@ptnum)*2-1;


⬆ Back to top

circleOutOfCenterNormals

Sets normals in direction from center of circle (start of coordinate system (0,0,0)).

// Sets normals in direction from center of circle [Point Wrangle]
  vector k = set(0,0,0);
  v@N = normalize(k+@P);
Example


⬆ Back to top

geoWithoutLighting

Sets a geometry to always appear without lighting in scene.

// Set true (1) for ON and false (0) for OFF. Need Detail in Run Over [Attribute Wrangle]
  @gl_lit = 1;
Example


⬆ Back to top

wireframeInViewport

Showing a geometry as wireframes.

// Set true (1) for ON and false (0) for OFF. Need Detail in Run Over [Attribute Wrangle]
  @gl_wireframe = 1;
Example


⬆ Back to top

GroupExpand

Uniformly expanding group by a specified distance.

// Need a group filter ('group1') [Point Wrangle]
  int pc = pcopen(0, 'P', @P, ch('radius'), chi('maxpts'));
  while (pciterate(pc) > 0)
  {
    int currentpt;
    pcimport(pc, 'point.number', currentpt);
    setpointgroup(0, 'group1', currentpt, 1);
  }
Example


⬆ Back to top

createAGroup

Create a group.

// Creation of group called 'mask' (@group_ is a virtual attribute)
  i@group_mask = 1;
// Creation of group 'mygroup' for each point [Point Wrangle]
  setpointgroup(0, "mygroup", @ptnum, 1);
// Creation of group 'mygroup' for each primitive [Primitive Wrangle]
  setprimgroup(0, "mygroup", @primnum, 1);
// Creation of group 'mygroup' for each vertex [Vertex Wrangle]
  setvertexgroup(0, "mygroup", @primnum, 1);
// Creation of group 'mygroup' for each edge between
// @primnum and @primnum+1 [Attribute Wrangle with Edges Group Type]
  setedgegroup(0, "mygroup", @primnum, @primnum+1, 1);
Example


⬆ Back to top

PointsInGroupCounter

Shows how many elements in a group.

// Points in a group ('mygroup') counter [Point Wrangle]
  i@count = npointsgroup(0, 'mygroup');


⬆ Back to top

PrimitivesInGroupCounter

Shows how many elements in a group.

// Points in a group ('mygroup') counter [Point Wrangle]
  i@count = nprimitivesgroup(0, 'mygroup');


⬆ Back to top

VerticesInGroupCounter

Shows how many elements in a group.

// Points in a group ('mygroup') counter [Point Wrangle]
  i@count = nverticesgroup(0, 'mygroup');


⬆ Back to top

PointGroupsList

Returns a string array of existing point groups.

// Array of existing point groups
  s[]@list = detailintrinsic(0, 'pointgroups');


⬆ Back to top

PrimGroupsList

Returns a string array of existing primitive groups.

// Array of existing primitive groups
  s[]@list = detailintrinsic(0, 'primitivegroups');


⬆ Back to top

VertexGroupsList

Returns a string array of existing vertex groups.

// Array of existing vertex groups
  s[]@list = detailintrinsic(0, 'vertexgroups');


⬆ Back to top

EdgeGroupsList

Returns a string array of existing edge groups.

// Array of existing edge groups
  s[]@list = detailintrinsic(0, 'edgegroups');


⬆ Back to top

PointsListInGroup

Creation of list of points numbers in a group.

// List of points in a group [Point Wrangle]
  i[]@list = expandpointgroup(0, 'mygroup');


⬆ Back to top

PrimitivesListInGroup

Creation of list of primitives numbers in a group.

// List of primitives in a group [Primitive Wrangle]
  i[]@list = expandprimgroup(0, 'mygroup');


⬆ Back to top

VerticesListInGroup

Creation of list of vertices numbers in a group.

// List of primitives in a group [Vertex Wrangle]
  i[]@list = expandvertexgroup(0, 'mygroup');


⬆ Back to top

createAnArray

Create an array.

// Local integer array of size 5
  int array[] = {0,1,2,3,4};
// Global string array of size 2
  s[]@array = {'example_0.rat', 'example_1.rat'};
// Local string array of size 2
  string array[] = {'example_0.rat', 'example_1.rat'};


⬆ Back to top

generateAnArray

Generate an array.

// Procedurally generated array of size 10
  i[]@myarray;
  for(int i=0; i<10; i++){
      append(@myarray, i);
  }
// Output: [ 0,1,2,3,4,5,6,7,8,9 ]
// Procedurally generated vector array of size '@numpt'
    v[]@myarray;
    for(int i=0; i<@numpt; i++){
        vector item = point(0, 'P', i);
        insert(@myarray, 0, item);
    }
// Output: [ (4.24242, 0.0, 5.0), (3.53535, 0.0, 5.0), etc. ]


⬆ Back to top

iteratingOverArrayElements

Iterating over array elements (every second).

// Need listing input primitive numbers on detail
    int importarray[] = detail(0, 'prims');
    foreach(int i; importarray){
        if(i%2 == 0){
            setprimattrib(0, 'Cd', i, {0,1,0.2});
        }
    }
Example


⬆ Back to top

nGonsVisualize

Visualize of n-gons on geometry.

// Visualize of n-gons on geometry [Primitive Wrangle]
  if (primvertexcount(0, @primnum) < 4){
    @Cd = set(0, 1, 0.2);
  }
Example


⬆ Back to top

helixCurve

Creation of helix from curve.

// Creation of helix from curve [Point Wrangle]
  float freq, amp;
  vector pos = @P;

  freq = chf("freq");
  amp = chf("amp");

  pos.x += sin(pos.y * freq) * amp;
  pos.z += cos(pos.y * freq) * amp;
  @P = pos;
Example


⬆ Back to top

sortOfRingPoints

Sorting circle points.

//Sorting points in a circle (z and y axis) [Point Wrangle]
  vector center = getbbox_center(0);
  @P -= center;
  @grad = atan2(@P.z,@P.y);
  @P += center;
// After that needing sort by attribute 'grad'
Example


⬆ Back to top

inCenterOfPrimitives

Replacing primitives with points and adding points at each of their centers.

// Points in center [Primitive Wrangle]
  addpoint(0,@P);
  removeprim(0,@primnum,0);
Example


⬆ Back to top

pointsInAGroup

Assigning a point to a group. If points’ position on X axis is more than 0, assign the point to the “mygroup”.

// Points in a group [Point Wrangle]
  if(@P.x>0) @group_mygroup = 1;
Example


⬆ Back to top

ToTestAPointGroupMembership

Returns a boolean value whether a point is a member of specified group.

// Points in a group [Point Wrangle]
  i@ismember = inpointgroup(0, "group1", @ptnum);
Example


⬆ Back to top

ToTestAPrimitiveGroupMembership

Returns a boolean value whether a primitive is a member of specified group.

// Primitive in a group [Primitive Wrangle]
  i@ismember = inprimgroup(0, "group1", @primnum);
Example


⬆ Back to top

ToTestAVertexGroupMembership

Returns a boolean value whether a vertex is a member of specified group.

// Vertex in a group [Vertex Wrangle]
  i@ismember = invertexgroup(0, "group1", @vtxnum);
Example


⬆ Back to top

cutGeoFromCamera

Cut geometry from selected camera with the ability to crop.

// Camera Frustrum [Point Wrangle]
vector pos = toNDC("/obj/cam1", @P);
if (pos.x < 0+ch('overLeft')) removepoint(0, @ptnum);
if (pos.x > 1-ch('overRight')) removepoint(0, @ptnum);
if (pos.y < 0+ch('overDown')) removepoint(0, @ptnum);
if (pos.y > 1-ch('overUp')) removepoint(0, @ptnum);
Example


⬆ Back to top

silhouetteRetain

Preserves the silhouette of the geometry in the selected camera, regardless of its distance.

// Silhouette Retain [Point Wrangle]
vector pos = toNDC("/obj/cam1", @P);
pos.z += ch("offset");
@P = fromNDC("/obj/cam1", pos);
Example


⬆ Back to top

EXPRESSIONS

Getting digit in naming of current node (STR) atof(opdigits($OS))

About

A collection of useful VEX snippets for Houdini.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published