Class TMaterialProperties

Unit

Declaration

type TMaterialProperties = class(TObject)

Description

Store information that is naturally associated with a given material or texture in an external file. Documentation and example of such file is on https://castle-engine.io/creating_data_material_properties.php . Right now this allows to define things like:

  • footsteps,

  • toxic ground (hurts player),

  • bump mapping (normal maps and height maps for given texture),

  • texture GPU-compressed and downscaled alternatives.

In the future, it should be possible to express all these properties in pure VRML/X3D (inside Appearance / Material / ImageTexture nodes). Right now, you can do this with bump mapping, see https://castle-engine.io/x3d_extensions.php#section_ext_bump_mapping , but not footsteps or toxic ground. In the future it should also be possible to express these properties in 3D authoring software (like Blender), and easily export them to appropriate VRML/X3D nodes. For now, this TMaterialProperty allows us to easily customize materials in a way that is not possible in Blender.

Using an external file for material properties has also long-term advantages: it can be shared across many 3D models, for example you can define footsteps sound for all grounds using the grass.png textures, in all levels, at once.

You have to load an XML file by setting MaterialProperties.URL property.

Hierarchy

  • TObject
  • TMaterialProperties

Overview

Methods

Public constructor Create(const AnAutoProcessImageURLs: Boolean);
Public destructor Destroy; override;
Public function FindTextureBaseName(const TextureBaseName: String): TMaterialProperty;
Public function AutoGeneratedTextures: TCastleStringList;
Public function AutoGeneratedTextureURL(const TextureURL: String; const UseCompression: Boolean; const TextureCompression: TTextureCompression; const Scaling: Cardinal): String;
Public function AutoCompressedTextureFormats(const TextureURL: String): TTextureCompressionsToGenerate;
Public function OriginalPlatforms(const TextureURL: String): TCastlePlatforms;
Public function Scales(const TextureURL: String): TScalesArray;
Public function TrivialUncompressedConvert(const TextureURL: String): Boolean;

Properties

Public property URL: String read FURL write SetURL;
Public property FileName: String read FURL write SetURL; deprecated 'use URL';

Description

Methods

Public constructor Create(const AnAutoProcessImageURLs: Boolean);
 
Public destructor Destroy; override;
 
Public function FindTextureBaseName(const TextureBaseName: String): TMaterialProperty;

Find material properties for given texture basename. Returns Nil if no material properties are found (in particular, if URL was not set yet).

Public function AutoGeneratedTextures: TCastleStringList;

Get the URLs of all textures that should have automatically generated GPU-compressed and downscaled counterparts. Returns a list of absolute URLs. This actually searches on disk, right now, to find the texture list, applying the include/exclude rules specified in material_properties.xml file.

This is to be used by "castle-engine auto-generate-textures" tool, or similar tools.

Caller is responsible for freeing the returned TCastleStringList list.

Public function AutoGeneratedTextureURL(const TextureURL: String; const UseCompression: Boolean; const TextureCompression: TTextureCompression; const Scaling: Cardinal): String;

For given texture (absolute) URL and compression and scaling, return the proper (absolute) URL of auto-compressed and auto-downscaled counterpart. Scaling is defined just like TextureLoadingScale.

Public function AutoCompressedTextureFormats(const TextureURL: String): TTextureCompressionsToGenerate;

Automatic compression formats generated for this texture. May return Nil, if there are no compressed formats to generate for this texture. The resulting class instance cannot be modified, and it is owned by this TMaterialProperties instance, so don't free it yourself.

Parameters
TextureURL
An absolute texture URL. Usually should just be taken from AutoGeneratedTextures returned list.
Public function OriginalPlatforms(const TextureURL: String): TCastlePlatforms;

Determine the platforms for which the original texture should be packaged

Public function Scales(const TextureURL: String): TScalesArray;

Generate all scales for this TextureURL.

Parameters
TextureURL
An absolute texture URL. Usually should just be taken from AutoGeneratedTextures returned list.
Public function TrivialUncompressedConvert(const TextureURL: String): Boolean;

Perform trivial conversion (that does not compress, does not downscale) for this texture.

Parameters
TextureURL
An absolute texture URL. Usually should just be taken from AutoGeneratedTextures returned list.

Properties

Public property URL: String read FURL write SetURL;

Load material properties from given XML file. Set this to empty string to unload previously loaded properties. See Castle1 and fps_game data for examples how this looks like, in material_properties.xml.

Public property FileName: String read FURL write SetURL; deprecated 'use URL';

Warning: this symbol is deprecated: use URL

 

Generated by PasDoc 0.16.0.