Share

User Callbacks

Golaem provides callback functions mechanism which is triggered every time a Golaem file is loaded / saved or a new Golaem node is created. They can be used to edit default node parameters or call custom pipeline code. The available callbacks are

Callbacks

File Callbacks

SaveFileUserCallback // whenever a file is loaded / saved

LoadFileUserCallback

Behavior Callbacks

addGolaemNode // whenever a new golaem node is created

addCrowdBehaviorUserCallback // whenever a new behavior is created

addCrowdBe[BehaviorName]UserCallback

addCrowdTri[TriggerName]UserCallback

addCrowdFieldUserCallback

addTerrainLocatorUserCallback

addPerceptionLocatorUserCallback

addPhysicsLocatorUserCallback

addFlockLocatorUserCallback

addTrafficLocatorUserCallback

addTheCharacterMakerLocatorUserCallback

addCrowdEntityTypeNodeUserCallback

addCrowdGroupEntityTypeNodeUserCallback

addSensorLocatorUserCallback

addTheCrowdManagerNodeUserCallback

glmPopToolHandleConnectionsUserCallback

addSimulationCacheProxyUserCallback

addBakeSimulationCacheProxyUserCallback

addEmptySimulationCacheProxyUserCallback

addCrowdRenderProxyUserCallback

Simulation Cache Library Callbacks

sclReadLibFileUserCallback

sclWriteLibFileUserCallback

sclImportLibFileUserCallback

sclAddLibItemUserCallback

sclRemoveLibItemUserCallback

sclClearLibItemsUserCallback

Python

The module to include is the following

import glm.callbackUtils

To register a callback function you can call the following utilty function available in the glm.callbackUtils module:

def registerUserCallback(callbackName, function)

To deregister a callback function you can call the following utilty function available in the glm.callbackUtils module:

def deregisterUserCallback(callbackName)

Those callback functions all share the same prototype:

def [functionName](files)    // whenever a file is loaded / saved (multiple files separated with ';'

def [functionName](nodeName) // whenever a new node is created

Here is an example of an implemented callback called whenever a new Motion Behavior is created:

def motionCbExample(nodeName):

    cmds.setAttr(nodeName + '.loop', 0)

glm.callbackUtils.registerUserCallback('addCrowdBeMotionUserCallback', motionCbExample)

MEL

Those callback functions all share the same prototype:

global proc [callbackFunctionName](string $nodeName);

The following functions are available for a callback to be implemented. When implemented and sourced in the Maya session, they will be called when the corresponding node is created via the Golaem Shelf or the Golaem Menus:

Here is an example of an implemented callback called whenever a new Motion Behavior is created:

global proc addCrowdBeMotionUserCallback(string $nodeName)

{   setAttr ($nodeName + ".loop") 0; // disable looping by default

}
 

Was this information helpful?