Communication with Maya

MGL operates on points data like position, normal, scale or user defined properties. Computations of new values are performed within mgAutomata node. Communication with Maya environment is achieved through node attributes:

mgAutomataAttrmgAutomata attributes

Data input from Maya scene to mgAutomata is realized by attributes visible in script scope under same identifier as long names of node attributes:

vert v = inMesh[0];
vert p = inPoints[0];
vector a = inVector[0];
float f = inFloat[0];
int i = inInt[0];

Computation results are respectively exposed through node attributes:

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.


If mesh connected to inMesh attribute of mgAutomata node has vertex color set named colorSet, then in order to access per-vertex colors within script scope declare vector field with the same identifier as color-set name:

vert v = inMesh[0];
vector v.colorSet;
v.position += v.normal * v.colorSet.x;
outMesh[0] = v;

colorSet-InColor set transferred to script scope utilized in mesh transformations

Every vector field of vert variable that is outputted to outMesh attribute is converted to color set as well:

vert p = inMesh[0];
vector p.newColor;

if(p.position.y < 0)
    p.newColor.x = 1;
    p.newColor.z = 1;

outMesh[0] = p;



The same approach applies to array attributes (inPoints, outPoints). If connection made to inPoints[n] contains array of integers named type, then in order to access those values declare int field of vert variable and perform input operation.

Consider following network as example:


Input to mgAutomata node comes from mgSampler node, that computes texture values for given set of points. Values are exported to output array under noise identifier:


To access texture values, in script scope declare vector field of vert object with same identifier as input array. Grab values from input:

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 arrays with same identifiers as field name.

Previous: Built-in functions | Language reference | Next: Flow control