Users can define new variation filters to edit the variation json table defined in their scenes or completely define a new variation definition based on some user defined criteria.
A variation filter is a class with a "filter" method, the arguments are the following:
- variations: the current variation object. This is the current variation object and at this stage it might have been already edited by other variation filters
- atomsNode: the name of the atomsNode from your scene
- origin_data: the original variation string. You can get a variation object from this string using the Atoms.loadVariationFromString function.
import Atoms import Atoms.ui.constants from Atoms.singletons import get_atoms_variation_filters_singleton import random 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 filters = get_atoms_variation_filters_singleton() filters.append(VariationFilter())