neuray API Programmer's Manual

mi::neuraylib::IMdl_factory Class Reference

[Materials (MDL)]

Description

Factory for MDL interfaces, e.g., modules with presets.

Public Member Functions

virtual Sint32 create_presets( ITransaction* transaction, const char* module_name, const IArray* preset_data) =0
Creates a new MDL module containing presets. More...

Member Functions

virtual Sint32 mi::​neuraylib::​IMdl_factory::create_presets( ITransaction* transaction, const char* module_name, const IArray* preset_data) [pure virtual]

Creates a new MDL module containing presets. A preset is basically a clone of another material definition (the prototype) with different defaults.

See also:

mi::neuraylib::IMdl_material_definition::create_preset() for an alternative way to create presets. However, the alternative is restricted to modules that contain exactly one preset.

Parameters

transaction
Unused, pass NULL.
module_name
The fully-qualified MDL name of the new module (including package names, starts with "::").
preset_data
A static or dynamic array of structures of type Preset_data. Such a structure has the following members:
  • const char* preset_name The name of the preset (non-qualified, without module prefix). The DB name of the preset is created by prefixing this name with the DB name of the new module plus "::".
  • const char* prototype_name The DB name of the prototype for this preset.
  • mi::neuraylib::IAttribute_container* defaults The preset inherits the defaults from the prototype. This member allows to change the defaults and/or to add new defaults. The type of an attribute in the attribute container must match the type of the parameter of the same name of the prototype. Note that the values in defaults are copied; passing an attribute container obtained from another MDL interface does not create a link between both instances. NULL is a valid value which is handled like an empty attribute container.
  • mi::neuraylib::IAttribute_container* annotations The preset does not inherit any annotations from the prototype. This member allows to specify annotations for the preset, i.e., for the material declaration itself (but not for its arguments). So far, only annotations with a single string argument are supported. Therefore, the type of an attribute in the attribute container must be a struct with a single string member. The name of that member does not matter. The predefined type name String_annotation can be used to create such attributes. The name of the attribute identifies the annotation (fully-qualified MDL name starting with a double colon, without signature). Note that the values in annotations are copied; passing an attribute container obtained from another MDL interface does not create a link between both instances. NULL is a valid value which is handled like an empty attribute container.

Returns

  • 1: Success (module exists already, creation was skipped).
  • 0: Success (module was actually created with the presets as its only material definitions).
  • -1: The module name module_name is invalid.
  • -2: Failed to compile the module module_name.
  • -3: The DB name for an imported module is already in use but is not an MDL module, or the DB name for a definition in this module is already in use.
  • -4: Initialization of an imported module failed.
  • -5: transaction, module_name or preset_data are invalid, preset_data is empty, or a struct member for the prototype name, defaults, or annotations has an incorrect type.
  • -6: A default for a non-existing parameter was provided.
  • -7: The type of a default does not have the correct type.
  • -8: Unspecified error.
  • -9: The type of an annotation value does not have the correct type (only annotations with a single string argument are supported).
  • -10: One of the annotations does not exist or does not have the correct type (only annotations with a single string argument are supported).