メタデータの末尾にスキップ
メタデータの先頭に移動

このページの古いバージョンを表示しています。現在のバージョンを表示します。

現在のバージョンとの相違点 ページ履歴を表示

« 前のバージョン バージョン 4 次のバージョン »

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.
Variation filters are called when the scenes are being translated to render engine (i.e. Arnold, Renderman, etc).

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.

Example 1

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())

Example 2

import Atoms
import Atoms.ui.constants
from Atoms.singletons import get_atoms_variation_filters_singleton


class NewVariationFilter:
    def filter(self, variations, atomsNode, origin_data):
		variations = Atoms.Variations()
		atv = Atoms.AgentTypeVariation()
		varGeo1 = Atoms.VariationGeometry()
		varGeo1.setGeometryFile("${ATOMS_DATA}/variations/geometries/atomsRobot/robot1_body.geos")
		atv.setGeometry("body",varGeo1)
		varGeo2 = Atoms.VariationGeometry()
		varGeo2.setGeometryFile("${ATOMS_DATA}/variations/geometries/atomsRobot/robot1_head.geos")
		atv.setGeometry("head",varGeo2)

		material1 = Atoms.VariationMaterial()
		material1.setMaterialFile("")
		atv.setMaterial("robot1_material",material1)
		geoGroup = Atoms.VariationGroup(atv)
		geoGroup.addCombination("body","robot1_material")
		geoGroup.addCombination("head","robot1_material")
		atv.setGroup("Robot1", geoGroup)
		atv.setLookFile("${ATOMS_DATA}/variations/materials/atomsRobot/lookFile.ass")
		variations.setAgentTypeVariation("atomsRobot", atv)
		print variations.toString(True)
		#to write the variation table a json st]irng use variations.toString(False)
		#to load a variation object from a stirng use Atoms.loadVariationFromString(json_string) or Atoms.loadVariationFromFile(json_file_path)
		return variations


def load():  
    filters = get_atoms_variation_filters_singleton()
    filters.append(NewVariationFilter())
    
  • ラベルがありません