A wrapper around the interfaces for MDL material and function definitions. More...
Public Member Functions | |
General methods | |
Mdl_definition_wrapper (ITransaction *transaction, const char *name) | |
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_name () 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... |
|
Uint32 | get_parameter_count () const |
Returns the number of parameters. More... |
|
const char * | get_parameter_name (Uint32 index) const |
Returns the name of the parameter at index . More... |
|
Sint32 | get_parameter_index (const char *name) const |
Returns the index position of a parameter. More... |
|
const char * | get_parameter_type (Uint32 index) const |
Returns the type of the parameter at index . More... |
|
const char * | get_parameter_type (const char *name) const |
Returns the type of a parameter. More... |
|
bool | is_parameter_type_uniform (Uint32 index) const |
Indicates whether the type of a parameter is uniform. More... |
|
bool | is_parameter_type_uniform (const char *name) const |
Indicates whether the type of a parameter is uniform. More... |
|
const char * | get_argument_type (Uint32 index) const |
Returns the type of the argument at index . More... |
|
const char * | get_argument_type (const char *name) const |
Returns the type of an argument. More... |
|
const char * | get_return_type () const |
Returns the return type. More... |
|
bool | is_return_type_varying () const |
Indicates whether the return type is varying. More... |
|
Methods related to argument defaults | |
template<class T > | |
Sint32 | get_default (Uint32 index, T &value) const |
Returns the default initializer of a non-array parameter. More... |
|
template<class T > | |
Sint32 | get_default (const char *name, T &value) const |
Returns the default initializer of a non-array parameter. More... |
|
Methods related to annotations | |
const IAttribute_container * | get_annotations () const |
Returns the annotations for a material or function definition. More... |
|
const IAttribute_container * | get_parameter_annotations (Uint32 index) const |
Returns the annotations of the parameter at index . More... |
|
const IAttribute_container * | get_parameter_annotations (const char *name) const |
Returns the annotations of a parameter. More... |
|
const IAttribute_container * | get_return_annotations () const |
Returns the annotations for the return type. More... |
|
Methods related to instantiation of definitions | |
IScene_element * | create_instance (const IAttribute_container *arguments=0, Sint32 *errors=0) const |
Creates an instance of the material or function definition. More... |
|
template<class T > | |
T * | create_instance (const IAttribute_container *arguments=0, Sint32 *errors=0) const |
Creates an instance of the material or function 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::IMdl_material_definition and mi::neuraylib::IMdl_function_definition for the underlying interfaces. See also mi::neuraylib::Mdl_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 use for all DB interactions. |
name | The name of the wrapped material or function definition. |
|
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 initializer need to be present). If NULL , then the default initializer for a parameter is used, or the argument is default-constructed for parameters without default initializer. |
|
[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 initializer need to be present). If NULL , then the default initializer for a parameter is used, or the argument is default-constructed for parameters without default initializer. |
|
[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::IMdl_material_instance or mi::neuraylib::IMdl_function_call. |
|
inline |
Returns the annotations for a material or function definition.
|
inline |
Returns the type of the argument at index
.
If a literal 0
is passed for index
, the call is ambiguous. You need to explicitly cast the value to mi::Uint32.
index | The index of the argument. |
NULL
if index
is out of range.
|
inline |
Returns the type of an argument.
name | The name of the argument. |
NULL
if name
is invalid. Sint32 mi::neuraylib::Mdl_definition_wrapper::get_default | ( | Uint32 | index, |
T & | value | ||
) | const |
Returns the default initializer 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::Uint32.
index | The index the parameter in question. | |
[out] | value | The default initializer of the specified parameter. |
false
.index
is out of range, or there is no default initializer for this parameter.Sint32 mi::neuraylib::Mdl_definition_wrapper::get_default | ( | const char * | name, |
T & | value | ||
) | const |
Returns the default initializer of a non-array parameter.
name | The name of the parameter in question. | |
[out] | value | The default initializer of the specified parameter. |
false
.name
is invalid, or there is no default initializer for this parameter.
|
inline |
Returns the DB name of the corresponding module.
|
inline |
Returns the MDL name of the material or function definition.
|
inline |
Returns the annotations of the parameter at index
.
If a literal 0
is passed for index
, the call is ambiguous. You need to explicitly cast the value to mi::Uint32.
index | The index of the parameter. |
NULL
if index
is out of range.
|
inline |
Returns the annotations of a parameter.
name | The name of the parameter. |
NULL
if name
is invalid.
|
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 type of the parameter at index
.
If a literal 0
is passed for index
, the call is ambiguous. You need to explicitly cast the value to mi::Uint32.
index | The index of the parameter. |
NULL
if index
is out of range.
|
inline |
Returns the type of a parameter.
name | The name of the parameter. |
NULL
if name
is invalid.
|
inline |
Returns the annotations for the return type.
NULL
.
|
inline |
Returns the return type.
NULL
.
|
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 type of a parameter is uniform.
If a literal 0
is passed for index
, the call is ambiguous. You need to explicitly cast the value to mi::Uint32.
index | The index of the parameter. |
true
if the parameter is uniform, otherwise false
(including invalid index
).
|
inline |
Indicates whether the type of a parameter is uniform.
name | The name of the parameter. |
true
if the parameter is uniform, otherwise false
(including invalid name
).
|
inline |
Indicates whether the return type is varying.
true
if the return type is varying, otherwise false
.
|
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.