top of page

Maya Node - dhPointWrangle

  • Writer: Dominik Haase
    Dominik Haase
  • Jun 14, 2020
  • 3 min read

Updated: Oct 10, 2023

The dhPointWrangle node is my attempt of bringing Houdini's 'Attribute Wrangle' node to Maya. The main purpose of this node is to execute whatever code you through in there at runtime for each vertex. The code can be changed at any time and even be hooked up to an attribute (though I can't really think of any useful situation for this lol).




As Houdini and Maya have quite a few differences in their nodes and how they work, the Maya node is not an exact clone. I also didn't have time to write my own VEX for Maya and simply stuck with Python.


Inputs

The most important imports are the input_preCommand, input_perVertexCommand and input_postCommand. These inputs take the code that will be executed. Pre and post command are executed only once before and after the loop while the main command is executed for each point in the first mesh. This is where I sacrificed the first feature of Houdini's Attribute Wrangle. In the current version, I cant switch the component type that will be iterated from vertex to something else. BUT as the user can write code for the pre and post command, he or she is free to manually iterate over whatever data they want :) So not a big issue.

In my current implementation, there are four inputs each for meshes, matrices, vectors, floats so that there is enough data available to do some tests. I plan to change the inputs to arrays and at one point, I will also support nurbsCurve, nurbsSurface and string data inputs.


Commands

The commands fully support Python input and give the user full access to the Maya Python API. As the commands are executed inside the node, accessing data that does not come from the compute functions data parameter, can cause Maya to crash as it will likely break the DG. (That's nothing I am concerned about during the project though.)

VEX is super easy to work with and there is not much to think about when asking for the length of the current position (-al vector) or setting the color to the current normal direction.

Not so with the Maya API. MPoint, MFloatPoint, MVector, MFloatVector and MColor are all used but are not all compatible with each other. To solve this (and to get a little closer to VEX) I introduced quite a few abbreviations. Too many to list them all but here are some to give you an idea (Houdini users might recognize that I stole pretty much all the common ones :) )


@P -> current position as MVector

@N -> current point normal as MVector

@Cd -> current vertex color as MVector (added .r, .g, .b properties to class)

@ptnum -> current index

@numpt -> total point count

@Mesh -> current OpenMaya.MFnMesh

@Float -> first float input @opinput#_attr -> for second, third and fourth inputs position, normal, color, etc

@Frame -> current frame

REMAP -> remap value

SIN/COS/TAN/... -> math.(any trigonometric function)

LERP -> linear interpolation for float and MVector objects

and many more...


In VEX, using an @ will not only read, but also add an attribute onto the geometry if it doesn't exist yet. This is another feature that I am currently missing but that (or at least some, to Maya adapted form of it) is definitely on my to-do-list.


Output(s)

This is currently the limiting part. The current version only outputs mesh data and therefore limits the use of the node in its current state as there is no way to output calculated vectors, values, matrices or other data. So, that's what I am gonna do now :) Expect more to come soon!



Cheers!




Comments


  • Schwarz LinkedIn Icon
  • Schwarz Vimeo Icon
  • iconfinder_imdb-2048-black_167622_edited
  • Schwarz Instagram Icon
  • Schwarz Facebook Icon
bottom of page