This page has been translated automatically.
编程
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::Materials Class

Header:#include <UnigineMaterials.h>

Interface for managing the list of material libraries that belong to the world manually via script. These material libraries are loaded/saved on world loading/saving. (This list is stored at the beginning of the corresponding *.world file.)

Materials Class

Members


Materials * get()

int isLibrary(const char * name)

Checks the material library by its name.

Arguments

  • const char * name - Material library name.

Return value

1 if the material library exists; otherwise, 0.

int isLibraryEditable(int index)

Returns the material library editable flag.

Arguments

  • int index - Material library number.

Return value

The editable flag.

const char * getLibraryName(int index)

Returns the material library name.

Arguments

  • int index - Material library number.

Return value

The name of material library.

Ptr<Material> getMaterial(int library, int num)

Returns the material.

Arguments

  • int library - Library number.
  • int num - Material number.

Return value

Material smart pointer.

int isMaterial(const char * name)

Checks the material by its name.

Arguments

  • const char * name - Material name.

Return value

1 if the material exists; otherwise, 0.

const char * getMaterialName(int library, int num)

Returns the material name.

Arguments

  • int library - Library number.
  • int num - Material number.

Return value

The name of material.

int getNumLibraries()

Returns the number of loaded material libraries.

Return value

The number of loaded material libraries.

int getNumMaterials(int index)

Returns the number of library materials.

Arguments

  • int index - Library number.

Return value

The number of library materials.

int getNumWorldLibraries()

Returns the number of material libraries that belong to the current world (such libraries are specified in the *.world file and automatically loaded on the world initialization).

Return value

Number of libraries belonging to the world.

const char * getWorldLibraryName(int index)

Returns the name of a library belonging to the current world by its index.

Arguments

  • int index - Index of the library.

Return value

Name of the library.

int addWorldLibrary(const char * filename)

Loads a library and associates it with the current world (such libraries are specified in the *.world file and automatically loaded on the world initialization). If the library file does not exist, an empty library is created. (For simple loading without association, see engine.materials.load().)

Arguments

  • const char * filename - Name of a material library to be loaded:
    • A full path (relative to the data folder).
    • Name without a file path. The first found library with this name is used in this case.

Return value

1 if the library is loaded or created successfully; otherwise, 0.

int clear(const char * library)

Clears the material library by its name.

Arguments

  • const char * library - Material library name.

Return value

1 if the material library is cleared successfully; otherwise, 0.

int cloneMaterial(const char * name, const char * dest_library, const char * dest_name)

Clones material into the specified material library.

Arguments

  • const char * name - Material name.
  • const char * dest_library - New material library name.
  • const char * dest_name - New material name.

Return value

1 if the material is cloned successfully; otherwise, 0.

int create(const char * name)

Creates an empty material library.

Arguments

  • const char * name - Material library name.

Return value

1 if the material library is created successfully; otherwise, 0.

int findLibrary(const char * name)

Finds the material library by its name.

Arguments

  • const char * name - Material library name.

Return value

Material library number.

int findLibraryMaterial(int library, const char * name)

Finds the material in the specified material library.

Arguments

  • int library - Library number.
  • const char * name - Material name.

Return value

Material number.

Ptr<Material> findMaterial(const char * name)

Finds the material by its name.

Arguments

  • const char * name - Material name.

Return value

Material smart pointer.

int findMaterialLibrary(const char * name)

Finds the material library by material name.

Arguments

  • const char * name - Material name.

Return value

Material library number.

int inheritMaterial(const char * name, const char * dest_library, const char * new_name)

Inherits material into the specified material library.

Arguments

  • const char * name - Material name.
  • const char * dest_library - New material library name.
  • const char * new_name - New material name.

Return value

1 if the material is inherited successfully; otherwise, 0.

int load(const char * filename, int addToWorldLibrary = 0)

Loads the material library from the file.

Arguments

  • const char * filename - File with the library to load.
  • int addToWorldLibrary - Set 1 to add material to the world library.

Return value

1 if the material library is loaded successfully; otherwise, 0.

int moveMaterial(const char * name, const char * dest_library, const char * dest_name)

Moves material into the specified material library.

Arguments

  • const char * name - Material name.
  • const char * dest_library - New material library name.
  • const char * dest_name - New material name.

Return value

1 if the material is moved successfully; otherwise, 0.

int reload(const char * name)

Reloads the material library from the file.

Arguments

  • const char * name - Material library name.

Return value

1 if the material library is reloaded successfully; otherwise, 0.

void reloadMaterials()

Reloads all material libraries

int removeMaterial(const char * name)

Removes material by its name.

Arguments

  • const char * name - Material name.

Return value

1 if the material is removed successfully; otherwise, 0.

int removeWorldLibrary(const char * name)

Deletes a given library from the list of material libraries that belong to the world (such libraries are specified in the *.world file and automatically loaded on the world initialization). This function does not unload the library if it has already been loaded.

Arguments

  • const char * name - Name of the library to be dissociated:
    • A full path (relative to the data folder); also used if a library is loaded from *.world file.
    • The same name as passed to engine.materials.addWorldLibrary()). The first found library with this name is used in this case.

Return value

1 if the library is removed successfully; otherwise, 0.

int replaceMaterial(const Ptr<Material> & material, const char * new_name)

Replaces material with a new one.

Arguments

  • const Ptr<Material> & material - Name of the material to be replaced.
  • const char * new_name - Name of the new material.

Return value

1 if the material is replaced successfully; otherwise, 0.

int replaceMaterial(const char * name, const char * new_name)

Replaces material with a new one.

Arguments

  • const char * name - Name of the material to be replaced.
  • const char * new_name - Name of the new material.

Return value

1 if the material is replaced successfully; otherwise, 0.

int save(const char * name)

Saves the material library into the file. To be saved, a library should be editable.

Arguments

  • const char * name - Material library name.

Return value

1 if the material library is saved successfully; otherwise, 0.
Last update: 2017-07-03
Build: ()