Functions for dealing with hierarchies.
Takes an object using a multi/SO material, and removes any unused sub-materials.
NOTE: the original object and material are not touched. Use RemapMeshMaterials
to update the originals.
An array, where:
Array[1] == A new, reduced, multi/SO material.
Array[2] == An array of integers. The array size is equal to the size of the original multi-material's materialList array.
Each array item specifies which sub-material in the NEW multi-material corresponds to the indexed sub-material. So, if:
array[2][5] == 3
then the fifth sub-material in the original material maps to the third sub-material in the new material.
<obj>
Get all the submaterials of the passed material.
An array of all the sub-materials of the passed material.
<mat>
[MaterialFilter:DefaultMaterialFilter]
fn FooMat mat = (
(ClassOf mat == standardMaterial) AND
(findString mat.name "Foo" != undefined)
)
MyMats = GetSubMaterials aMat MaterialFilter:FooMat
...MyMats would contain an array of Standard materials that have the word "Foo" in their name.
Get all the standard submaterials of the passed material. This is just a shortcut to calling GetSubMaterials with a custom MaterialFilter function that gets only Standard materials.
An array of all the standard sub-materials of the passed material.
<mat>
Get all the materials and submaterials applied to the passed object.
An array of all the sub-materials applied to the passed object.
<object>
[MaterialFilter:DefaultMaterialFilter]
fn FooStdMat mat = (
(ClassOf mat == standardMaterial) AND
(findString mat.name "Foo" != undefined)
)
MyMats = GetObjectMaterials anObj MaterialFilter:FooStdMat
...MyMats would contain an array of Standard materials that have the word "Foo" in their name.
Get all the standard materials and submaterials applied to the passed object.
An array of all the standard sub-materials applied to the passed object.
<object>
Get all the subtextures of the passed material or texture.
An array of all the sub-textures of the passed material or texture.
<mat>
[TextureFilter:DefaultTextureFilter]
fn FooBitmapTex tex = (
(ClassOf tex == Bitmaptexture) AND
(findString tex.name "Foo" != undefined)
)
MyTexs = GetSubTextures aTex TextureFilter:FooBitmapTex
...MyTexs would contain an array of bitmap textures that have the word "Foo" in their name.
Get all the bitmap subtextures of the passed material or texture. This is just a shortcut to calling GetSubTextures with a custom MaterialFilter function that gets only Bitmap textures.
An array of all the bitmap sub-textures of the passed material or texture.
<mat>
Get which material IDs are used in an object.
A sorted array of integers corresponding to which material IDs are used in the mesh.
<obj>
Takes a multi/SO material, and remove any duplicate sub-materials.
NOTE: the original object and material are not touched. Use RemapMeshMaterials
to update the originals.
An array, where:
Array[1] == A new, reduced, multi/SO material.
Array[2] == An array of integers. The array size is equal to the size of the original multi-material's materialList array.
Each array item specifies which sub-material in the NEW multi-material corresponds to the indexed sub-material. So, if:
array[2][5] == 3
then the fifth sub-material in the original material maps to the third sub-material in the new material.
<mat>
[compareFunc:undefined]
fn HasSameDiffuseTexture matA matB = (
if (ClassOf matA == StandardMaterial) AND
(ClassOf matB == StandardMaterial) AND
(matA.diffuseMap != undefined) AND
(matA.diffuseMap != undefined) then (
return (matA.diffuseMap == matB.diffuseMap)
)
false
)
And would be used like:
ReduceSubMaterials myMaterial compareFunc:HasSameDiffuseTexture
Switches an object's matID's around based on the passed remapArray (from ReduceSubMaterials
or ReduceSubMaterials
).
ie: the following will take an object's multi-material, remove duplicates, and re-order the object's face material ID's to use the new multi-material:
retArray = ReduceSubMaterials meshObj.material
meshObj.material = retArray[1]
RemapMeshMaterials meshObj retArray[2]
OK.
<obj>
<remapArray>