Attribute expression
You can add an expression to an attribute. Atoms uses C++ as an expression language.
On a expression, you have three variable as input that you can use to access various data:
agent: is an AgentWrapper object. You can use it to access agent metadata, or pose transforms.
agentGroup: is an AgentGroupWrapper object. You can use it to access other agents or do space queries.
defaultValue: it contains the default value of the attribute.
Finally, you can change the attribute value by assigning a value to the “output” variable.
Example
Create an agent group and add a grid layout and a state machine module.
Press on the randomize button net to the state attribute until you activate the expression mode.
Now press the “open editor” button to open the expression editor.
Add the expression like in the picture below and press save.
If you press play, the agent switches its state to 1 when the frame is higher then 20.
For example if you want only the agent with groupId 1 to switch to state 1, you can write an expression like this:
if (agent.groupId == 1 && agentGroup.time() > 20)
{
output = 1;
}
else
{
output = defaultValue;
}
You can do the same by checking if an agent has a specific metadata value:
if (agent.getIntMetadata("myMeta") == 1 && agentGroup.time() > 20)
{
output = 1;
}
else
{
output = defaultValue;
}
Copyright © 2017, Toolchefs LTD.