Before the First Anchor: 6. Oversimplified Vectors — As Data Types. 🟢

<aside> 🧩

TL:DR The Bookkeeping Principle: Houdini separates spatial data, geometric structure, and connectivity. Functions such as addpoint(), addprim(), and addvertex() build those relationships incrementally, while Houdini manages the underlying numbering and bookkeeping.

</aside>

The Workflow

<aside>

$$ \begin{gathered}\Large \textbf{1. Points}\\[4pt]\large \text{Spatial data}\\[4pt]\large \text{Where does the geometry exist?}\\[12pt]\downarrow\\[12pt]\Large \textbf{2. Primitive}\\[4pt]\large \text{Structural data}\\[4pt]\large \text{What kind of geometric element am I building?}\\[12pt]\downarrow\\[12pt]\Large \textbf{3. Vertices}\\[4pt]\large \text{Connectivity data}\\[4pt]\large \text{How are its points connected?}\end{gathered} $$

</aside>

<aside> ℹ️

Houdini separates position, structure, and connectivity.

This separation allows primitives to reference existing points rather than requiring every primitive to own unique points, giving you the flexibility to build complex geometry by reusing the same underlying data.

</aside>

oversiplified_anchor_bookkeeping_gerardojustel_re1mon.png

1. Points — Define the positions in space

<aside> 🧩

Points define positions in space where geometry can exist. They provide the spatial information that other geometric elements can reference.

</aside>

Imagine you're drawing a line on paper. You might begin by marking two locations with a pencil. Those locations give you the spatial information needed to construct the line.

//Creates a point at a position (0, 0, 0).
//Stores that returned number in an integer variable called pt0.
int pt0 = addpoint(0, set(0, 0, 0));

//Creates a point at a position (2, 0, 0).
//Stores that returned number in an integer variable called pt1.
int pt1 = addpoint(0, set(2, 0, 0));

What happens when we add points?

When addpoint() creates a point, Houdini assigns it a point number.

The first addpoint() creates a point and returns its point number, 0. The variable pt0 stores that value.

The second addpoint() creates another point. Since the first point already has number 0, the new point receives number 1. The variable pt0 stores that value.

pt0 = 0    Point 0
           Position: (0, 0, 0)

pt1 = 1    Point 1
           Position: (2, 0, 0)

https://www.sidefx.com/docs/houdini/vex/functions/addpoint.html

This example assumes the geometry starts empty. Existing points can affect point numbers.

<aside> ⚠️

Variable names and point numbers

pt1 is a variable name we choose. Its value is 1 because the second addpoint() call returns that point number.

We could name the variables first_point and second_point instead. The code would work exactly the same way.

</aside>

2. Primitive — Define the geometric element

<aside> 🧩

A primitive defines the type of geometric element we're creating. You can think of it as the structure that organizes points into an element such as a polygon, a polyline, or a surface.

</aside>

In our example, we're building a line. We've created the points, but they aren't connected yet. We need to tell Houdini what kind of geometric element we want to construct.

// Create a polyline primitive.
// Store the returned primitive number in prim.
int prim = addprim(0, "polyline");

https://www.sidefx.com/docs/houdini/vex/functions/addprim.html

<aside> ⚠️

Creating a point and connecting that point to a primitive are two different operations in Houdini

</aside>

3. Vertices — Define the connections

At this point, the geometry contains two points and one polyline primitive. However, the primitive has no vertices connecting it to those points yet.

<aside> 🧩

Vertices belong to primitives and reference points. Their order within a primitive determines how those points are connected.

</aside>

We are telling Houdini which points it should reference and in what order.

<aside> ℹ️

Vertices aren't independent objects that connect themselves to each other. Each vertex belongs to a primitive and references a point. The primitive's ordered vertex sequence defines the path.

</aside>

// Add a vertex referencing the first point.
addvertex(0, prim, pt0);

// Add another vertex referencing the second point.
addvertex(0, prim, pt1);

https://www.sidefx.com/docs/houdini/vex/functions/addvertex.html

This is where the three concepts come together: the points provide positions, the primitive defines the geometric element, and the vertices establish its connectivity.

When addvertex() executes, Houdini creates a vertex belonging to prim that references pt0.

What happens when we add vertices?

When you execute the final two lines, you're telling Houdini:

  1. Add a vertex to this primitive referencing Point 0.
  2. Add another vertex to the same primitive referencing Point 1.

Because this is a polyline with two vertices, Houdini can now form a line.

<aside> ⚠️

addvertex() doesn't create another point. The point already exists. It creates a vertex that references that existing point.

</aside>

<aside> ℹ️

addvertex() can also return a vertex number, but our code doesn't store that return value. We don't need it for this example because we're simply building the line.

</aside>

How is the vertex order determined?

// Create three points and store their point numbers.
int pt0 = addpoint(0, set(0, 0, 0));
int pt1 = addpoint(0, set(2, 0, 0));
int pt2 = addpoint(0, set(2, 0, 2));

// Create a polyline primitive and store its primitive number.
int prim = addprim(0, "polyline");

// Add vertices to the primitive in sequence.
// Each vertex references an existing point.
// The order in which vertices are added defines the polyline's path.
addvertex(0, prim, pt0);
addvertex(0, prim, pt1);
addvertex(0, prim, pt2);
Call Point referenced Vertex order in the primitive
First addvertex() Point 0 First vertex
Second addvertex() Point 1 Second vertex
Third addvertex() Point 2 Third vertex

<aside> ⚠️

Point order and Vertex order are not the same thing.

</aside>

<aside> 🧩

It uses the same underlying principle. The vertex order is determined by the order in which vertices are added to the primitive

</aside>

<aside> ℹ️

The order of vertices within a primitive is what defines the polyline's path.

</aside>

4. The Bookkeeping Principle

A point, a primitive, and a vertex each represent a different part of Houdini's geometry system.

Each function handles a different part of the process. Houdini keeps track of the geometry's elements and their numbering, while your code defines how those elements come together.

Why does this matter?

Points, primitives, and vertices each play a distinct role in Houdini's geometry system.

Points define positions in space. Primitives define geometric elements. Vertices establish connectivity by referencing points in a specific order.

As you build geometry, Houdini manages the numbering and bookkeeping behind these elements, while your code defines their relationships and structure.

<aside> 🧩

</aside>

// The complete code
// Create two points and store their point numbers.
int pt0 = addpoint(0, set(0, 0, 0));
int pt1 = addpoint(0, set(2, 0, 0));

// Create an empty polyline primitive.
int prim = addprim(0, "polyline");

// Add vertices to the primitive, referencing the points in order.
addvertex(0, prim, pt0);
addvertex(0, prim, pt1);

Continue Reading:

8. Oversimplified Arrays — The Lineup 🟡