MaterialManager
MaterialManager
Local manager for Material lifecycle and tag assignment.
The manager is intentionally not a singleton. Each :class:Model
instance owns one MaterialManager with an independent tag space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh_maker
|
Model
|
The :class: |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If mesh_maker is not a :class: |
Attributes
Methods:
add
Add an existing material and assign a tag if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
material
|
Material
|
Unmanaged or already-managed :class: |
required |
Returns:
| Type | Description |
|---|---|
Material
|
The same |
Raises:
| Type | Description |
|---|---|
TypeError
|
If material is not a :class: |
ValueError
|
If its preassigned tag conflicts with a different object already managed here, or if it already belongs to another manager. |
get_by_name
Return the material with user_name == name, or None.
get_all
Return a shallow copy of all managed materials keyed by tag.
remove
Remove a managed material and compact the remaining tags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
int
|
Tag of the material to remove. Missing tags are ignored. |
required |
set_tag_start
Set the first tag used by this manager and retag existing objects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_tag
|
int
|
Positive integer for the first assigned tag. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If start_tag is less than |