Skip to content

Curves

Create frame for one segment in a poly curve

The polyframe sop doesn’t work with curves primitives with only one segment (2 points) this is a solution to build a frame with only two points

vex
//run over points
vector up = {0,1,0};
vector bitangent = cross(up, v@tangentu); // generated from resample node
v@tangentv = bitangent;
v@N = cross(v@tangentu, bitangent);

Curves misc

The following curves code was obtained from vex --- John Svensson

  1. Curve U Map

    Curve U Map - Runs over several primitives

    Creates two point attributes. One 0 - 1 and one 0 - 1 - 0 along each curve, based on point number / vertex order for each primitive.

    Run in a Wrangle SOP (Run over - Primitives)

    vex
    float umap, umap_half;
    addattrib(geoself(), "point", "umap", 0.0);
    addattrib(geoself(), "point", "umap_half", 0.0);
    prim_points = primpoints(geoself(), @primnum);
    for ( int i = 0; i < len(prim_points); i++ ){
    umap = float(i) / (len(prim_points) - 1);
    umap_half = clamp(umap, 0, 0.5) * clamp(umap * -1 + 1, 0, 0.5) * 4;
    setattrib(geoself(), "point", "umap", prim_points[i], 0, umap, "set");
    setattrib(geoself(), "point", "umap_half", prim_points[i], 0, umap_half, "set");
    }
  2. Curve Normals

    Curve Normals - Runs over a single primitive

    Creates a normal along a single curve, two point based, un normalized

    Run in a Wrangle SOP (Run over - Points)

    vex
    vector pos, nor_a, nor_b;
    if ( @ptnum == 0) {
    getattribute(@OpInput1, pos, "point", "P", @ptnum + 1, 0);
    @N = @P - pos;
    } else if ( @ptnum == (npoints(@OpInput1) - 1) ) {
    getattribute(@OpInput1, pos, "point", "P", @ptnum - 1, 0);
    @N = pos - @P;
    } else {
    getattribute(@OpInput1, pos, "point", "P", @ptnum - 1, 0);
    nor_a = pos - @P;
    getattribute(@OpInput1, pos, "point", "P", @ptnum + 1, 0);
    nor_b = @P - pos;
    @N = (nor_a + nor_b) / 2;
    }
  3. Filter the first and last point of a curve

    Used to group points in a group expression or in a smooth points nodes

    vex
    // vex expression
    @ptnum==@numpt-1||@ptnum==0