This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine::Materials Class

Header: #include <UnigineMaterials.h>

Interface for managing loaded materials via the code.

All materials existing in the project are preloaded at Engine initialization depending on the materials preload mode specified by the materials_preload console command and saved on world's saving or on calling the materials_save console command.

See Also#

  • C++ API sample located in the folder <UnigineSDK>/source/samples/Api/Systems/Materials

Materials Class

Members


Ptr<Material> loadMaterial ( const char * path ) #

Loads a material stored by the given path. The function can be used to load materials created during application execution or stored outside the data directory.

Arguments

  • const char * path - A path to the material (including its name).

Return value

A loaded material.

bool isMaterialGUID ( const UGUID & guid ) const#

Returns a value indicating if a material with the specified GUID exists.

Arguments

Return value

true if the material with the specified GUID exists; otherwise, false.

int getNumMaterials ( ) const#

Returns the number of materials loaded for the current project.

Return value

The number of materials.

Ptr<Material> getMaterial ( int num ) const#

Returns the material by its number.

Arguments

  • int num - Material number.

Return value

A material.

Ptr<Material> findManualMaterial ( const char * name ) const#

Searches for a manual material by the given name.

Arguments

  • const char * name - A manual material name.

Return value

A manual material smart pointer.

Ptr<Material> findMaterialByGUID ( const UGUID & guid ) const#

Searches for a material with the given GUID.

Arguments

Return value

A material smart pointer.

Ptr<Material> findMaterialByFileGUID ( const UGUID & guid ) const#

Searches for a material with the given GUID of a material file.

Arguments

  • const UGUID & guid - A GUID of a material file.

Return value

A material smart pointer.

Ptr<Material> findMaterialByPath ( const char * path ) const#

Searches for a material stored by the specified path.

Arguments

  • const char * path - A loading path of the material (including a material's name).

Return value

A material smart pointer.

void setCachedMaterial ( const Ptr<Material> & mat ) #

Arguments

Ptr<Material> getCachedMaterial ( ) #

void setCachedState ( const char * name, int value ) #

Arguments

  • const char * name
  • int value

bool removeMaterial ( const UGUID & guid, bool remove_file = 0, bool remove_children = 1 ) #

Deletes a material. If the remove_file flag is enabled, the material file will be deleted as well. If the flag is disabled, the deleted material will be loaded again on the next application start-up. If the remove_children flag is enabled, all the children of the material will be deleted as well.

Arguments

  • const UGUID & guid - GUID of the material to be removed.
  • bool remove_file - Flag indicating if the material file will be deleted.
  • bool remove_children - Flag indicating if all the children of the material will be also deleted.

Return value

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

bool replaceMaterial ( const Ptr<Material> & material, const Ptr<Material> & new_material ) #

Replaces the material with the given one.

Arguments

  • const Ptr<Material> & material - A material to be replaced.
  • const Ptr<Material> & new_material - A replacing material.

Return value

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

bool saveMaterials ( ) const#

Saves changes made for all loaded materials.

Return value

true if materials are saved successfully; otherwise, false.

void compileShaders ( ) #

Compiles shaders for all loaded materials.

void setPrecompileAllShaders ( bool shaders ) #

Enables or disables shader precompilation.

Arguments

  • bool shaders - 1 to enable shader precompilation, 0 - to disable it.

bool isPrecompileAllShaders ( ) const#

Returns a value indicating if shader precompilation is enabled.

Return value

1 if shader precompilation is enabled; otherwise, 0.

void reloadMaterials ( ) #

Reloads all loaded materials.

void destroyShaders ( ) #

Deletes all shaders used for the loaded materials.

void destroyTextures ( ) #

Deletes all textures used by the loaded materials.

void createShaders ( ) #

Creates all shaders for all loaded materials.

void createRenderMaterials ( ) #

Creates render materials (internal materials required for rendering). For example, you can create all necessary render materials during initialization to avoid spikes that may occur later.
Last update: 2023-09-26
Build: ()