Took me some time to figure out how to set the points color (“Cd”) attribute with data stored initially in custom points attributes. I kept trying to use the Color SOP node with a “point()” function in its R, G, B fields attempting to refer to the wanted attributes but it didn’t work for me, I also tried various loop setups iterating the geometry points, couldn’t get that to work either.. * I’m new to Houdini so the fact these approaches didn’t work for me doesn’t mean they can’t be used for this..
I finally managed to do this using a Point Wrangle node with the following VEX expression that sets the Cd (color) attribute’s vector components by referring to the 3 custom attributes “att_a”, “att_b” and “att_c” (see image below):
@Cd = set(@att_a,@att_b,@att_c);
What the Point Wrangler node does that I couldn’t achieve by writing expressions into the RGB fields of the Color node or by using loops is that it iterates all its input SOP’s points, and within its expression the attribute name i.e. “att_a” etc. automatically refers to that named attribute in the same point that is now being iterated over.
Note: The reason I need such a workflow in the first place is to generate geometric property masks for a Houdini asset, that will be available for the target shading system via vertex color input. * The Houdini point color attribute propagates to vertex color on output.
After setting the point color, I added an Attribute Delete SOP node to delete the no more necessary custom attributes:
This is an example of procedurally animating a mesh’s vertices via Python script.
1. The model has to be converted to Editable Mesh before the script is run.
* unless the scrip will be extended to do it.
2. The model must be selected for the script to work.
from MaxPlus import INode
from MaxPlus import TriObject
from MaxPlus import SelectionManager
from MaxPlus import Factory
from MaxPlus import Animation
from MaxPlus import Point3
from MaxPlus import Control
ticks_frame = 160
sel = 
for n in SelectionManager.Nodes:
node = sel
obj = node.GetObject()
Tri = TriObject._CastFrom(obj)
mesh = Tri.GetMesh()
num_verts = mesh.GetNumVertices()
mesh_anim = obj.GetSubAnim(0)
pnt_ctrl = Factory.CreateDefaultMasterPointController()
for i in range(num_verts):
bezp3 = Factory.CreateDefaultPoint3Controller()
for t in range(100):
time = t * ticks_frame
for i in range(num_verts):
vert_anim = mesh_anim.GetSubAnim(i)
vert_ctrl = Control._CastFrom(vert_anim)
vert_val = mesh.GetVertex(i)
vert_val.SetZ(vert_val.GetZ() + math.sin(((Animation.GetTime()*0.5)/(ticks_frame))+i))
* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.