From Atoms Crowd 2.0.0, you can take advantage of the python plugin system for integrating Atoms Crowd even more into your pipeline.
A python plugin is defined as a folder on disk containing an __init__.py file and atomsinit.py file, of course you can have other files living under that folder.
In order to load your python plugins in Atoms you have define the ATOMS_PYTHON_PLUGINS_PATH environment variable. This env variable will have to point to the parent folder of your python plugin, in this way you will be able to have several python plugins under the same folder. (i.e. ATOMS_PYTHON_PLUGINS_PATH=C:\projects\atomscrowd\pythonplugins)
atomsinit.py
The atomsinit.py file will get called by Atoms at several stages. Atoms will search for the following functions and will call them in case they are defined:
- def load(): called when Atoms is initialized
- def unload(): called when Atoms is unitialized
- def loadScene(): called when a new scene using Atoms is loaded
- def unloadScene(): called when a scene using Atoms is unloaded
Example
The following example shows how you can create a new variation filter and register it.
import Atoms import Atoms.ui.constants from Atoms.singletons import get_atoms_variation_filters_singleton import random ''' This is an example how a filter can edit the variation table at runtime ''' class VariationFilter: def filter(self, variations, atomsNode, origin_data): atv = variations.getAgentTypeVariation("atomsRobot") if atv: for mat in atv.getMaterialNames(): material = atv.getMaterial(mat) if material: material.setDiffuseColorBlue(random.randint(0,255)) material.setDiffuseColorGreen(random.randint(0,255)) material.setDiffuseColorRed(random.randint(0,255)) #print variations.toString(True) print "My variation filter" return variations def load(): print "Hello!!!" filters = get_atoms_variation_filters_singleton() filters.append(VariationFilter()) def unload(): print "Bye bye" def loadScene(): print "Scene Loaded" def unloadScene(): print "Scene unloaded"