A wrapper around the interfaces for MDL material and function definitions. More...
Public Member Functions | |
General methods | |
Definition_wrapper (ITransaction *transaction, const char *name, IMdl_factory *mdl_factory) | |
Constructs an MDL definition wrapper for a fixed material or function definition. More... | |
bool | is_valid () const |
Indicates whether the definition wrapper is in a valid state. More... | |
Element_type | get_type () const |
Indicates whether the definition wrapper acts on a material definition or on a function definition. More... | |
const char * | get_mdl_definition () const |
Returns the MDL name of the material or function definition. More... | |
const char * | get_module () const |
Returns the DB name of the corresponding module. More... | |
bool | is_exported () const |
Indicates whether the material or function definition is exported by its module. More... | |
Size | get_parameter_count () const |
Returns the number of parameters. More... | |
const char * | get_parameter_name (Size index) const |
Returns the name of the parameter at index . More... | |
Size | get_parameter_index (const char *name) const |
Returns the index position of a parameter. More... | |
const IType_list * | get_parameter_types () const |
Returns the types of all parameters. More... | |
const IType * | get_return_type () const |
Returns the return type. More... | |
const char * | get_thumbnail () const |
Returns the resolved file name of the thumbnail image for this MDL definition. More... | |
Methods related to argument defaults | |
const IExpression_list * | get_defaults () const |
Returns the defaults of all parameters. More... | |
template<class T > | |
Sint32 | get_default (Size index, T &value) const |
Returns the default of a non-array parameter. More... | |
template<class T > | |
Sint32 | get_default (const char *name, T &value) const |
Returns the default of a non-array parameter. More... | |
Methods related to annotations | |
const IAnnotation_block * | get_annotations () const |
Returns the annotations for a material or function definition. More... | |
const IAnnotation_list * | get_parameter_annotations () const |
Returns the annotations of all parameters. More... | |
const IAnnotation_block * | get_return_annotations () const |
Returns the annotations of the return type. More... | |
const IExpression_list * | get_enable_if_conditions () const |
Returns the enable_if conditions of all parameters. More... | |
Size | get_enable_if_users (Size index) const |
Returns the number of other parameters whose enable_if condition might depend on the argument of the given parameter. More... | |
Size | get_enable_if_user (Size index, Size u_index) const |
Returns the index of a parameter whose enable_if condition might depend on the argument of the given parameter. More... | |
Methods related to instantiation of definitions | |
IScene_element * | create_instance (const IExpression_list *arguments=0, Sint32 *errors=0) const |
Creates an instance of the material or function definition. More... | |
template<class T > | |
T * | create_instance (const IExpression_list *arguments=0, Sint32 *errors=0) const |
Creates an instance of the material or function definition. More... | |
Methods related to member access. | |
ITransaction * | get_transaction () const |
Get the transaction. More... | |
IMdl_factory * | get_mdl_factory () const |
Get the MDL factory. More... | |
const IScene_element * | get_scene_element () const |
Get the MDL function or material definition. More... | |
Element_type | get_element_type () const |
Get the element type. More... | |
const std::string & | get_name () const |
Get the DB name of the MDL function or material definition. More... | |
A wrapper around the interfaces for MDL material and function definitions.
The purpose of the MDL definition wrapper is to simplify working with MDL material and function definitions. The key benefit is the unified treatment of material and function definitions which avoids duplication of code. For example, a GUI editor for the arguments can be essentially identical for materials and functions.
See mi::neuraylib::IMaterial_definition and mi::neuraylib::IFunction_definition for the underlying interfaces. See also mi::neuraylib::Argument_editor for a similar wrapper for MDL material instances and function calls.
|
inline |
Constructs an MDL definition wrapper for a fixed material or function definition.
transaction | The transaction to be used. |
name | The name of the wrapped material or function definition. |
mdl_factory | A pointer to the API component mi::neuraylib::IMdl_factory. Needed only by create_instance() if called with NULL as first argument, can be NULL otherwise. |
|
inline |
Creates an instance of the material or function definition.
arguments | If not NULL , then these arguments are used for the material instance or function call (all parameters without default need to be present). If NULL , then the default for a parameter is used, or the argument is default-constructed for parameters without default. | |
[out] | errors | An optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
|
NULL
in case of errors.
|
inline |
Creates an instance of the material or function definition.
arguments | If not NULL , then these arguments are used for the material instance or function call (all parameters without default need to be present). If NULL , then the default for a parameter is used, or the argument is default-constructed for parameters without default. | |
[out] | errors | An optional pointer to an mi::Sint32 to which an error code will be written. The error codes have the following meaning:
|
NULL
in case of errors.T | Either mi::neuraylib::IMaterial_instance or mi::neuraylib::IFunction_call. |
|
inline |
Returns the annotations for a material or function definition.
Sint32 mi::neuraylib::Definition_wrapper::get_default | ( | Size | index, |
T & | value | ||
) | const |
Returns the default of a non-array parameter.
If a literal 0
is passed for index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
index | The index the parameter in question. | |
[out] | value | The default of the specified parameter. |
false
.index
is out of range, or there is no default for this parameter.T
. Sint32 mi::neuraylib::Definition_wrapper::get_default | ( | const char * | name, |
T & | value | ||
) | const |
Returns the default of a non-array parameter.
name | The name of the parameter in question. | |
[out] | value | The default of the specified parameter. |
false
.name
is invalid, or there is no default for this parameter.T
.
|
inline |
Returns the defaults of all parameters.
|
inline |
Get the element type.
|
inline |
Returns the enable_if conditions of all parameters.
|
inline |
Returns the index of a parameter whose enable_if condition might depend on the argument of the given parameter.
index | The index of the parameter. |
u_index | The index of the enable_if user. |
Returns the number of other parameters whose enable_if condition might depend on the argument of the given parameter.
index | The index of the parameter. |
|
inline |
Returns the MDL name of the material or function definition.
|
inline |
Get the MDL factory.
|
inline |
Returns the DB name of the corresponding module.
|
inline |
Get the DB name of the MDL function or material definition.
|
inline |
Returns the annotations of all parameters.
|
inline |
Returns the number of parameters.
|
inline |
Returns the index position of a parameter.
name | The name of the parameter. |
name
is invalid.
|
inline |
Returns the name of the parameter at index
.
index | The index of the parameter. |
NULL
if index
is out of range.
|
inline |
Returns the types of all parameters.
|
inline |
Returns the annotations of the return type.
NULL
.
|
inline |
Returns the return type.
NULL
.
|
inline |
Get the MDL function or material definition.
|
inline |
Returns the resolved file name of the thumbnail image for this MDL definition.
The function first checks for a thumbnail annotation. If the annotation is provided, it uses the 'name' argument of the annotation and resolves that in the MDL search path. If the annotation is not provided or file resolution fails, it checks for a file module_name.material_name.png next to the MDL module. In case this cannot be found either NULL
is returned.
|
inline |
Get the transaction.
|
inline |
Indicates whether the definition wrapper acts on a material definition or on a function definition.
false
.
|
inline |
Indicates whether the material or function definition is exported by its module.
|
inline |
Indicates whether the definition wrapper is in a valid state.
The definition wrapper is valid if and only if the name passed in the constructor identifies a material or function definition. This method should be immediately called after invoking the constructor. If it returns false
, no other methods of this class should be called.