#include <xsi_operatorcontext.h>
This class is provided as the context object in the Operator update callback for a Self-Installed CustomOperator object (see PluginRegistrar::RegisterOperator).
This object offers all the context information necessary to implement a normal operator. However for advanced operators it is possible to retrieve more information via the CustomOperator object, which is available through Context::GetSource.
The Context::GetUserData and Context::PutUserData functions provide a convenient way to store non-persisted, per-instance state information for the operator. A common pattern is to use user data to store a pointer to C++ objects that actually implement the operator algorithm and store the operator's state.
Public Member Functions |
|
OperatorContext () | |
~OperatorContext () | |
OperatorContext (const CRef &in_ref) | |
OperatorContext (const OperatorContext &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
OperatorContext & | operator= (const OperatorContext &in_obj) |
OperatorContext & | operator= (const CRef &in_ref) |
CRef | GetOutputTarget () const |
CRef | GetOutputPort () const |
CTime | GetTime () const |
CValue | GetInputValue (LONG in_port, LONG in_group=0, LONG in_instance=0) const |
CValue | GetInputValue (const CString &in_port, const CString &in_group=CString(), LONG in_instance=0) const |
CValue | GetParameterValue (const CString &in_name) const |
OperatorContext | ( | ) |
Default constructor.
~OperatorContext | ( | ) |
Default destructor.
OperatorContext | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | Constant reference object. |
OperatorContext | ( | const OperatorContext & | in_obj | ) |
Copy constructor.
in_obj | Constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | Class type. |
Reimplemented from Context.
siClassID GetClassID | ( | ) | const [virtual] |
OperatorContext& operator= | ( | const OperatorContext & | in_obj | ) |
Creates an object from another object.
in_obj | Constant class object. |
OperatorContext& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | Constant class object. |
Reimplemented from Context.
CRef GetOutputTarget | ( | ) | const |
Returns the target object connected to the OutputPort. The only state of the XSI scene that an operator should modify during its evaluation is via the functions available on the object returned by this function. For example, if an operator writes to a ClusterProperty (for example, a Weight Map) then this function will return the ClusterProperty and the operator code can set the values of the property via CClusterPropertyElementArray::PutArray.
In the case of a multi-output operator the operator is called once per output, and this function will return the currently evaluating target. In this case it may be necessary to also call OperatorContext::GetOutputPort to determine the name of the current output port, in order to know which output is being evaluated.
CRef GetOutputPort | ( | ) | const |
Returns the OutputPort that represents the connection to the currently evaluating output target. In the case of a multi-output operator this object can be used to determine which output is currently being evaluated.
When the operator is writing to a Parameter use the OutputPort::PutValue function on the returned OutputPort to set a new value on the parameter.
CTime GetTime | ( | ) | const |
Returns the evaluation time. An operator should not assume that the evaluation time is the same as the current scene time or that it is evaluated just once per frame.
CValue GetInputValue | ( | LONG | in_port, |
LONG | in_group = 0 , |
||
LONG | in_instance =
0 |
||
) | const |
Returns the value of a given InputPort on the CustomOperator by index. If the connected object is a Parameter this will return the actual value of the Parameter value, not the Parameter object. Otherwise it will return the object that represents the input object, and this object can be used to retrieve information about the state of the input object. For example if the operator is connected to a Parameter of type double this will return a double. And if the operator is connected to a Primitive this will return a Primitive.
in_port | Port index. If the operator was created by a function like Parameter::AddCustomOp then the index is easy to determine based on the order of the inputs in the input argument. If the operator was built manually then the index can be determined based on the order of calls to CustomOperator::AddInputPort or CustomOperator::AddIOPort |
in_group | PortGroup index. Use this parameter for advanced operators that have more than one PortGroup. Otherwise it can be assumed that the input is on the first group (group 0) |
in_instance | PortGroup instance index. Use this parameter for advanced operators that support having more than one object connecting to a particular PortGroup. Otherwise it is assumed that the input is on the first group instance. |
CValue GetInputValue | ( | const CString & | in_port, |
const CString & | in_group = CString() , |
||
LONG | in_instance =
0 |
||
) | const |
Returns the value of a given input port by name. This variation works based on the string names of the InputPort and PortGroup objects.
Returns the current value of the specified Parameter, if any, of the CustomOperator. This function provides access only to parameters defined for the CustomOperator. For example, an Operator often has parameters that allow the user or the plug-in to configure the operator's behavior, such as "RecursionDepth", "UDivisions", "Height" or "CenterX".
in_name | scripting name of the parameter for which we want to get the value. |