Class TMaterialList
Unit
a3dge.Material
Declaration
type TMaterialList = class(TObject)
Description
A list of materials.
By default it also manages the materials: when an material is deleted or removed from the list, it is automatically freed. This behaviour can be disabled when the list is created.
See also
- TMaterialList.OwnsMaterials
- Should the list free the materials when they are removed.
Hierarchy
Overview
Methods
Properties
 |
property Name: AnsiString read fName write fName; |
 |
property Count: INTEGER READ GetCount; |
 |
property OwnsMaterials: Boolean read GetOwnsMaterials write SetOwnsMaterials; |
 |
property Materials[Ndx:INTEGER]: TMaterial READ GetMaterial WRITE SetMaterial; |
Description
Methods
 |
CONSTRUCTOR Create (aFreeMaterials: Boolean=True); |
Create an empty material list.
Parameters
- aFreeMaterials
- Should materials be freed when destroyed?
See also
- TMaterialList.OwnsMaterials
- Should the list free the materials when they are removed.
|
 |
DESTRUCTOR Destroy; OVERRIDE; |
Destructor.
Destroy clears the list, freeing all materials in the list if OwnsMaterials is True .
|
 |
PROCEDURE Clear; INLINE; |
Remove all materials from the list, freeing all them if OwnsMaterials is True .
|
 |
FUNCTION Add (aMaterial: TMaterial): INTEGER; INLINE; |
Add a new material.
Note that when OwnsMaterials is True , a material should not be added twice to the list: this will result in memory corruption when the object is freed (as it will be freed twice). The Add method does not check this, however.
Returns
The material index. See also
- TMaterialList.Delete
- Delete an element from the list.
- TMaterialList.Extract
- Extract a material from the list.
- TMaterialList.OwnsMaterials
- Should the list free the materials when they are removed.
- TMaterialList.Find
- Search material by name.
|
 |
PROCEDURE Delete (CONST Ndx: INTEGER); INLINE; |
Delete an element from the list.
Delete removes the material at index Ndx from the list. When OwnsMaterials is @ŧrue, it is also freed. An access violation may occur when OwnsMaterials is True and either the material was freed externally, or when the same material is in the same list twice.
Parameters
- Ndx
- Index of the object to delete.
See also
- TMaterialList.Extract
- Extract a material from the list.
- TMaterialList.OwnsMaterials
- Should the list free the materials when they are removed.
- TMaterialList.Add
- Add a new material.
- TMaterialList.Clear
- Remove all materials from the list, freeing all them if OwnsMaterials is
True .
|
 |
FUNCTION Extract (CONST Ndx: INTEGER): TMaterial; INLINE; |
Extract a material from the list.
Extract removes the material at index Ndx from the list. It returns the material if it was found or Nil if item was not present in the list.
Note that the object is not freed, and that only the first found object is removed from the list.
See also
- TMaterialList.Delete
- Delete an element from the list.
- TMaterialList.Clear
- Remove all materials from the list, freeing all them if OwnsMaterials is
True .
- TMaterialList.Add
- Add a new material.
|
 |
procedure Merge (aMaterialList: TMaterialList); |
Merge current list with given list.
This method will keep the material order.
Note that materials are objects, and this method only copies the objects reference. So remember to set OwnsMaterials to False to prevent double memory destruction.
See also
- TMaterialList.Assign
- Assign the materials from the given list.
- TMaterialList.OwnsMaterials
- Should the list free the materials when they are removed.
|
 |
function Find (aName: String): Integer; |
Search material by name.
The search is performed case-insensitively.
Parameters
- aName
- Name to search.
Returns
The index of the material or -1 if there's no material with that name in the list. See also
- TMaterialList.Materials
- Indexed access to the elements in the list.
- TMaterial.Name
- Material name.
|
Properties
 |
property Name: AnsiString read fName write fName; |
List name.
|
 |
property Count: INTEGER READ GetCount; |
The number of elements in the list. Note that this includes Nil elements.
See also
- TMaterialList.Materials
- Indexed access to the elements in the list.
|
 |
property OwnsMaterials: Boolean read GetOwnsMaterials write SetOwnsMaterials; |
Should the list free the materials when they are removed.
OwnsMaterials determines whether the materials in the list should be freed when they are removed (not extracted) from the list, or when the list is cleared. If the property is True then they are freed. If the property is False the elements are not freed.
The value is usually set in the constructor, and is seldom changed during the lifetime of the list. It defaults to True .
See also
- TMaterialList.Create
- Create an empty material list.
- TMaterialList.Destroy
- Destructor.
- TMaterialList.Delete
- Delete an element from the list.
- TMaterialList.Extract
- Extract a material from the list.
- TMaterialList.Clear
- Remove all materials from the list, freeing all them if OwnsMaterials is
True .
|
 |
property Materials[Ndx:INTEGER]: TMaterial READ GetMaterial WRITE SetMaterial; |
Indexed access to the elements in the list.
Materials is the default property of the list. It provides indexed access to the elements in the list. The index Ndx is zero based, i.e., runs from 0 (zero) to Count-1 .
See also
- TMaterialList.Add
- Add a new material.
- TMaterialList.Count
- The number of elements in the list.
- TMaterialList.Find
- Search material by name.
|
Generated by PasDoc 0.15.0. Generated on 2025-07-31 11:41:01.
|