MGL operates on a point data like position, normal vector, scale or user defined properties. Computations of new values are performed within mgAutomata node. Communication with Maya environment is achieved through node attributes:
mgAutomata attributes
Data input from Maya scene to mgAutomata is performed through attributes visible in script scope, under the same identifier as long name of node attribute:
vert v = inMesh[0]; vert p = inPoints[0]; vector a = inVector[0]; float f = inFloat[0]; int i = inInt[0];
Computation results are exposed through node attributes in the same manner:
outMesh[0] = v; outPoints[0] = p; outVector[0] = a; outFloat[0] = f; outInt[0] = i;
As input and output operations of numeric data are straightforward, there are some custom rules for point and mesh data.
Mesh
If mesh connected to inMesh attribute of mgAutomata node has vertex color set named colorSet, then in order to access per-vertex colors within a script, declare vector field with the same identifier as a color-set name:
vert v = inMesh[0]; vector v.colorSet; v.position += v.normal * v.colorSet.x; outMesh[0] = v;
Color set transferred to script scope
Every vector field of vert variable that is outputted to outMesh attribute is converted to a color set as well:
vert p = inMesh[0]; vector p.newColor; if(p.position.y < 0) { p.newColor.x = 1; }else{ p.newColor.z = 1; } outMesh[0] = p;
Points
The same approach applies to array attributes (inPoints, outPoints). If connection made to inPoints[n] contains array of integers named prop, then in order to access those values declare int field of vert variable named prop and perform input operation.
Consider following network as example:
Input to mgAutomata node comes from mgSampler node, which computes texture values for given set of points. Values are exported to output array under noise identifier:
To access texture values, declare vector field of vert object with same identifier as input array:
vert p = inPoints[0]; vector p.noise; // Now per-point texture values are accessible by this field vector p.scale = p.noise*3; // Use texture to drive instances scale outPoints[0] = p; // scale field is exported as an array
Noise texture used as driver for instances scale
Vector, float or int fields of vert object are exported as point cloud attributes with the same identifiers as field names.
Previous: Built-in functions | Language reference | Next: Flow control