-
Notifications
You must be signed in to change notification settings - Fork 22
Operators
An operator takes care of extracting data from the scene. Operators can save any kind of data not necessarily having to do with animation data.
Operators can be channel operators or item operators. Channel operators handle channel data, while item operators handle data related to an item (i.e. a maya or nuke node).
Currently 3 channels operators are supported:
- Curves Operator: for reading/writing animation curves from/to a channel
- Static Operator: for reading/writing a static value from/to a channel
- Bake operator: for reading/writing baked values to a channel
And 1 item operator:
- World Space Operator: for reading/writing the world space matrix of a 3D object
You can extend operators and register them into the Operators factory like this:
from kiko.operators.staticoperator import staticoperator
from kiko.operators.factory import OperatorsFactory
factory = OperatorsFactory()
factory.register(staticoperator.StaticOperator)
You should never call app specific modules from inside an operator, you should always call the arg facade methods instead. If you write a new operator, please make sure the facade methods you will call are implemented for all the facades you wish to support.
Chunks are saved in a default or user defined order. They are read in the same order when a kiko file is loaded. Users can still define the priority (the order) in which they are read at loading time. Any operator can prevent other subsequent operators to run at load time. This can be done with the ignore_following_operators() method of the BaseOperator class.
Here a very simple example which shows how you can build your own operator:
from kiko.constants import APPS, KIKO_TANGENT_TYPES
from kiko.operators.baseoperator import BaseOperator, BaseOperatorLoader
class StaticOperatorLoaderV1(BaseOperatorLoader):
@staticmethod
def version():
return 1
@staticmethod
def load(data, facade, node, import_anim_method, start_frame, end_frame,
frame_value, channel=None, time_multiplier=1):
facade.set_channel_value(node, channel, data['value'])
class MyStaticOperator(BaseOperator):
#IMPORTANT: need to have these two class static members declared in each
#operator class
_loaders = {}
_max_loader_version = None
@staticmethod
def name():
return "MyStaticOperator"
@staticmethod
def validate(facade, node, channel=None, force=False):
return force or not facade.is_channel_connected(node, channel)
@staticmethod
def ignore_following_operators():
return True
@staticmethod
def is_app_supported(app_name):
return app_name in APPS.all()
@staticmethod
def is_channel_operator():
return True
@staticmethod
def bakeable():
return False
@staticmethod
def get_frame_range(facade, node, channel=None):
return None
@staticmethod
def run(facade, node, channel=None, start_frame=None, end_frame=None):
return {'value': facade.get_channel_value(node, channel)}
StaticOperator.register_loader(StaticOperatorLoaderV1)