Creating Geometry From Scratch

Here we explain how to generate geometry procedurally. There are two node types that allow tho do this: Nodes of type Attribute Wrangle allow to specify geometry using the programming language VEX. Nodes of type Python allow to do the same in the Python language. In general you should keep in mind the following: Quite often the same task implemented in VEX leads to a much better performance than the corresponding implementation in python. The reason is that VEX is compiled on the fly in such a way as to exploit all available possibilities for parallelization. On the other hand, Python offers a wealth of numerical libraries. This means that many tasks have to be done in Python, but the standard choice should be VEX.

tet-cone-simple

For example we already showed several times a cone over the one-skeleton of a tetrahedron. To create this geometry in Houdini on can use an Attribute Wrangle node and paste into the text field labeled “VEXpression” the following code:

Here you also see how to define custom functions in VEX. For a general introduction to VEX we refer to the documentation. The same task could also be accomplished with a Python node. The necessary Python code looks as follows:

wheel-11

It is also possible to add interactive parameters to nodes. As an example we create a wheel with a variable number of spokes: Create a node of type Attribute Wrangle. Add a parameter of type float named numSpokes with label “number of spokes” to the node (see the documentation for the details how to do this). The needed VEX code is the following:

This entry was posted in Lecture. Bookmark the permalink.