Poly Few | Mesh Simplifier and Auto LOD Generator
A complete optimization solution for unity
Classes | Public Types | Static Public Member Functions | List of all members
BrainFailProductions.PolyFewRuntime.PolyfewRuntime Class Reference
Inheritance diagram for BrainFailProductions.PolyFewRuntime.PolyfewRuntime:

Classes

class  CustomMeshActionStructure
 This class represents a custom data structure that holds reference to a MeshRendererPair, the GameObject from which the MeshRendererPair was constructed and an Action object used to execute some code. More...
 
class  MaterialProperties
 This class represents a merged material properties. A merged material is a material that is combined by the Batch Few material combiner. More...
 
class  MeshRendererPair
 This class represents a simple data structure that holds reference to a mesh and whether that mesh is part of a MeshRenderer (Attached to MeshFilter) or SkinnedMeshRenderer. This structure is used thoroughly in various mesh simplification operations. More...
 
class  ObjectMeshPairs
 A Dictionary that holds a GameObject as key and the associated MeshRendererPair as value More...
 
class  OBJExportOptions
 Options that define how the a GameObject will be exported to wavefront OBJ. More...
 
class  OBJImportOptions
 Options that define how the model will be loaded and imported. More...
 
class  PreservationSphere
 This class is used to represent a preservation sphere. A preservation sphere retains the original quality of the mesh area enclosed within it while simplifying all other areas of the mesh. Please note that mesh simplification with preservation spheres might get slow. More...
 
class  ReferencedNumeric
 A wrapper class that holds a primitive numeric type and fakes them to act as reference types. More...
 
class  SimplificationOptions
 This class holds all the available options for mesh simplification. An object of this class is needed by many of the Mesh Simplification methods for controlling the mesh simplification process. More...
 

Public Types

enum  MeshCombineTarget { SkinnedAndStatic, StaticOnly, SkinnedOnly }
 An enum that is used to specify what kind of meshes to combine More...
 

Static Public Member Functions

static int SimplifyObjectDeep (GameObject toSimplify, SimplificationOptions simplificationOptions, Action< GameObject, MeshRendererPair > OnEachMeshSimplified)
 Simplifies the provided gameobject include the full nested children hierarchy with the settings provided. Any errors are thrown as exceptions with relevant information. Please note that the method won't simplify the object if the simplification strength provided in the SimplificationOptions is close to 0. More...
 
static ObjectMeshPairs SimplifyObjectDeep (GameObject toSimplify, SimplificationOptions simplificationOptions)
 Simplifies the meshes nested under the given gameobject(including itself) including the full nested children hierarchy with the settings provided. Retuns back a specialized data structure with the simplified meshes. Any errors are thrown as exceptions with relevant information. Please note that the method won't simplify the object if the simplification strength provided in the SimplificationOptions is close to 0. More...
 
static int SimplifyObjectDeep (ObjectMeshPairs objectMeshPairs, SimplificationOptions simplificationOptions, Action< GameObject, MeshRendererPair > OnEachMeshSimplified)
 Simplifies the meshes provided in the "objectMeshPairs" argument and assigns the simplified meshes to the corresponding objects. Any errors are thrown as exceptions with relevant information. Please note that the method won't simplify the object if the simplification strength provided in the SimplificationOptions is close to 0. More...
 
static List< Mesh > SimplifyMeshes (List< Mesh > meshesToSimplify, SimplificationOptions simplificationOptions, Action< Mesh > OnEachMeshSimplified)
 Simplifies the meshes provided in the "meshesToSimplify" argument and returns the simplified meshes in a new list. Any errors are thrown as exceptions with relevant information.Please note that the returned list of simplified meshes doesn't guarantee the same order of meshes as supplied in the "meshesToSimplify" list. Please note that preservation spheres don't work with this method. More...
 
static ObjectMeshPairs GetObjectMeshPairs (GameObject forObject, bool includeInactive)
 This method returns a specialized DataStructure for the provided object. The key is a reference to a GameObject and the value is a MeshRendererPair which contains a reference to the mesh attached to the GameObject (key) and the type of mesh (Skinned or static). More...
 
static void CombineMeshesInGameObject (GameObject forObject, bool skipInactiveRenderers, Action< string, string > OnError, MeshCombineTarget combineTarget=MeshCombineTarget.SkinnedAndStatic)
 Tries to combine meshes nested under the provided GameObject. Please note that the method modifies the provided gameobject and it's children hierarchy. More...
 
static GameObject CombineMeshesFromRenderers (Transform rootTransform, MeshRenderer[] originalMeshRenderers, SkinnedMeshRenderer[] originalSkinnedMeshRenderers, Action< string, string > OnError)
 Tries to combine the static and skinned meshes provided in the arguments. More...
 
static void ConvertSkinnedMeshesInGameObject (GameObject forObject, bool skipInactiveRenderers, Action< string, string > OnError)
 Converts all skinned meshes in the provided GameObject to non skinned/static meshes and also changes the corresponding renderer components. Please note that this method modifies the original GameObject and it's child hierarchy. More...
 
static Tuple< SkinnedMeshRenderer, MeshRenderer, Mesh >[] ConvertSkinnedMeshesFromRenderers (SkinnedMeshRenderer[] renderersToConvert, Action< string, string > OnError)
 Converts all Skinned Mesh Renderers in the provided list to non simple Mesh Renderers and also changes the corresponding meshes. Pleaes note that this method doesn't modify the actualy GameObject(s) from which the provided SkinnedMeshRenderes are extracted. More...
 
static async void ImportOBJFromFileSystem (string objAbsolutePath, string texturesFolderPath, string materialsFolderPath, Action< GameObject > OnSuccess, Action< Exception > OnError, OBJImportOptions importOptions=null)
 Imports a wavefront obj file provided by the absolute path. Please note that this method doesn't work on WebGL builds and will safely return. More...
 
static async void ImportOBJFromNetwork (string objURL, string objName, string diffuseTexURL, string bumpTexURL, string specularTexURL, string opacityTexURL, string materialURL, ReferencedNumeric< float > downloadProgress, Action< GameObject > OnSuccess, Action< Exception > OnError, OBJImportOptions importOptions=null)
 Downloads a wavefront obj file from the direct URl passed and imports it. You can also specify the URL for different textures associated with the model and also the URL to the linked material file. This function also works on WebGL builds. More...
 
static async void ExportGameObjectToOBJ (GameObject toExport, string exportPath, Action OnSuccess, Action< Exception > OnError, OBJExportOptions exportOptions=null)
 Exports the provided GameObject to wavefront OBJ format with support for saving textures and materials. Please note that the method won't work on WebGL builds and will safely return. More...
 
static int CountTriangles (bool countDeep, GameObject forObject)
 Counts the number of triangles in the provided GameObject. If "countDeep" is true then the method counts all the triangles considering all the nested meshes in the children hierarchies of the given GameObject. More...
 
static int CountTriangles (List< Mesh > toCount)
 Counts the number of triangles in the provided meshes list. More...
 
static List< MaterialPropertiesGetMaterialsProperties (GameObject forObject)
 Get a list of MaterialProperties objects associated with this GameObject. These objects can be used to change the properties of individual materials on this GameObject that were combined with Batch Few More...
 
static void ChangeMaterialProperties (MaterialProperties changeTo, GameObject forObject)
 Change the properties of a merged material associated with this GameObject More...
 

Member Enumeration Documentation

◆ MeshCombineTarget

An enum that is used to specify what kind of meshes to combine

Member Function Documentation

◆ ChangeMaterialProperties()

static void BrainFailProductions.PolyFewRuntime.PolyfewRuntime.ChangeMaterialProperties ( MaterialProperties  changeTo,
GameObject  forObject 
)
static

Change the properties of a merged material associated with this GameObject

Parameters
changeToThe new material properties
forObjectThe GameObject whose merged material to change properties for

◆ CombineMeshesFromRenderers()

static GameObject BrainFailProductions.PolyFewRuntime.PolyfewRuntime.CombineMeshesFromRenderers ( Transform  rootTransform,
MeshRenderer[]  originalMeshRenderers,
SkinnedMeshRenderer[]  originalSkinnedMeshRenderers,
Action< string, string >  OnError 
)
static

Tries to combine the static and skinned meshes provided in the arguments.

Parameters
rootTransformThe root transform to create the combined meshes based from, essentially the origin of the new mesh.
originalMeshRenderersThe list of MeshRenderer components whose corresponding meshes to combine.
OnErrorThe method to invoke when an error occurs. The method is passed the error title and the description of the error.
originalSkinnedMeshRenderersThe list of SkinnedMeshRenderer components whose corresponding meshes to combine.
Returns
A new GameObject with the combined meshes, or returns null in case of any problem.

◆ CombineMeshesInGameObject()

static void BrainFailProductions.PolyFewRuntime.PolyfewRuntime.CombineMeshesInGameObject ( GameObject  forObject,
bool  skipInactiveRenderers,
Action< string, string >  OnError,
MeshCombineTarget  combineTarget = MeshCombineTarget.SkinnedAndStatic 
)
static

Tries to combine meshes nested under the provided GameObject. Please note that the method modifies the provided gameobject and it's children hierarchy.

Parameters
forObjectThe object under which all the Static and Skinned meshes will be merged.
skipInactiveRenderersWhether the child renderers of the provided objects be skipped if they are inactive.
OnErrorThe method to invoke when an error occurs. The method is passed the error title and the description of the error.
combineTargetIndicates what kind of meshes to combine.

◆ ConvertSkinnedMeshesFromRenderers()

static Tuple<SkinnedMeshRenderer, MeshRenderer, Mesh> [] BrainFailProductions.PolyFewRuntime.PolyfewRuntime.ConvertSkinnedMeshesFromRenderers ( SkinnedMeshRenderer[]  renderersToConvert,
Action< string, string >  OnError 
)
static

Converts all Skinned Mesh Renderers in the provided list to non simple Mesh Renderers and also changes the corresponding meshes. Pleaes note that this method doesn't modify the actualy GameObject(s) from which the provided SkinnedMeshRenderes are extracted.

Parameters
renderersToConvertThe list of SkinnedMeshRenderers to convert.
OnErrorThe method to invoke when an error occurs. The method is passed the error title and the description of the error.
Returns
An array of tuples that contain the original SkinnedMeshRenderer, the corresponding converted MeshRenderer and the Mesh. Returns null if the operation failed.

◆ ConvertSkinnedMeshesInGameObject()

static void BrainFailProductions.PolyFewRuntime.PolyfewRuntime.ConvertSkinnedMeshesInGameObject ( GameObject  forObject,
bool  skipInactiveRenderers,
Action< string, string >  OnError 
)
static

Converts all skinned meshes in the provided GameObject to non skinned/static meshes and also changes the corresponding renderer components. Please note that this method modifies the original GameObject and it's child hierarchy.

Parameters
forObjectThe game object under which all SkinnedMeshRenderers will be converted.
skipInactiveRenderersWhether the child renderers of the provided objects be skipped if they are inactive.
OnErrorThe method to invoke when an error occurs. The method is passed the error title and the description of the error.

◆ CountTriangles() [1/2]

static int BrainFailProductions.PolyFewRuntime.PolyfewRuntime.CountTriangles ( bool  countDeep,
GameObject  forObject 
)
static

Counts the number of triangles in the provided GameObject. If "countDeep" is true then the method counts all the triangles considering all the nested meshes in the children hierarchies of the given GameObject.

Parameters
countDeepIf true the method also counts and considers the triangles of the nested children hierarchies for the given GameObject.
forObjectThe GameObject for which to count the triangles.
Returns
The total traingles summing the triangles count of all the meshes nested under the provided GameObject.

◆ CountTriangles() [2/2]

static int BrainFailProductions.PolyFewRuntime.PolyfewRuntime.CountTriangles ( List< Mesh >  toCount)
static

Counts the number of triangles in the provided meshes list.

Parameters
toCountThe list of meshes whose triangles will be counted.
Returns
The total triangles summing the triangles count of all the meshes in the provided list. WIll return 0 if there are no meshes in the list

◆ ExportGameObjectToOBJ()

static async void BrainFailProductions.PolyFewRuntime.PolyfewRuntime.ExportGameObjectToOBJ ( GameObject  toExport,
string  exportPath,
Action  OnSuccess,
Action< Exception >  OnError,
OBJExportOptions  exportOptions = null 
)
static

Exports the provided GameObject to wavefront OBJ format with support for saving textures and materials. Please note that the method won't work on WebGL builds and will safely return.

Parameters
toExportThe GameObject that will be exported.
exportPathThe path to the folder where the file will be written.
exportOptionsSome additional export options for customizing the export.
OnSuccessThe callback to be invoked on successful export.
OnErrorThe callback method that will be invoked when the import was not successful. The method is passed in an exception that made the task unsuccessful.

◆ GetMaterialsProperties()

static List<MaterialProperties> BrainFailProductions.PolyFewRuntime.PolyfewRuntime.GetMaterialsProperties ( GameObject  forObject)
static

Get a list of MaterialProperties objects associated with this GameObject. These objects can be used to change the properties of individual materials on this GameObject that were combined with Batch Few

Parameters
forObjectThe GameObject whose material properties objects to fetch
Returns
A list of MaterialProperties objects associated with this GameObject

◆ GetObjectMeshPairs()

static ObjectMeshPairs BrainFailProductions.PolyFewRuntime.PolyfewRuntime.GetObjectMeshPairs ( GameObject  forObject,
bool  includeInactive 
)
static

This method returns a specialized DataStructure for the provided object. The key is a reference to a GameObject and the value is a MeshRendererPair which contains a reference to the mesh attached to the GameObject (key) and the type of mesh (Skinned or static).

Parameters
forObjectThe object for which the ObjectMeshPairs is constructed.
includeInactiveIf this is true then the method also considers the nested inactive children of the GameObject provided, otherwise it only considers the active nested children.
Returns
A specialized data structure that contains information about all the meshes nested under the provided GameObject.

◆ ImportOBJFromFileSystem()

static async void BrainFailProductions.PolyFewRuntime.PolyfewRuntime.ImportOBJFromFileSystem ( string  objAbsolutePath,
string  texturesFolderPath,
string  materialsFolderPath,
Action< GameObject >  OnSuccess,
Action< Exception >  OnError,
OBJImportOptions  importOptions = null 
)
static

Imports a wavefront obj file provided by the absolute path. Please note that this method doesn't work on WebGL builds and will safely return.

Parameters
objAbsolutePathThe absolute path to the obj file.
texturesFolderPathThe absolute path to the folder containing the texture files associated with the model to load. If you don't want to load the associated textures or there are none then you can pass an empty or null to this argument.
materialsFolderPathThe absolute path to the folder containing the material files assoicated with the model to load. If you don't want to load the associated material or there is none then you can pass an empty or null to this argument.
OnSuccessThe callback method that will be invoked when the import was successful. The method is passed in the imported GameObject as the argument.
OnErrorThe callback method that will be invoked when the import was not successful. The method is passed in an exception that made the task unsuccessful.
importOptionsSpecify additional import options for custom importing.

◆ ImportOBJFromNetwork()

static async void BrainFailProductions.PolyFewRuntime.PolyfewRuntime.ImportOBJFromNetwork ( string  objURL,
string  objName,
string  diffuseTexURL,
string  bumpTexURL,
string  specularTexURL,
string  opacityTexURL,
string  materialURL,
ReferencedNumeric< float >  downloadProgress,
Action< GameObject >  OnSuccess,
Action< Exception >  OnError,
OBJImportOptions  importOptions = null 
)
static

Downloads a wavefront obj file from the direct URl passed and imports it. You can also specify the URL for different textures associated with the model and also the URL to the linked material file. This function also works on WebGL builds.

Parameters
objURLThe direct URL to the obj file.
objNameThe name for the GameObject that will represent the imported obj.
diffuseTexURLThe absolute URL to the associated Diffuse texture (Main texture). If the model has no diffuse texture on the material then you can pass in null or empty string to this parameter.
bumpTexURLThe absolute URL to the associated Bump texture (Bump map). If the model has no bump map then you can pass in null or empty string to this parameter.
specularTexURLThe absolute URL to the associated Specular texture (Reflection map). If the model has no reflection map then you can pass in null or empty string to this parameter.
opacityTexURLThe absolute URL to the associated Opacity texture (Transparency map). If the model has no transparency map then you can pass in null or empty string to this parameter.
materialURLIf the model has an associated material file (.mtl) then pass in the absolute URL to that otherwise pass a null or empty string.
downloadProgressThe object of type ReferencedNumeric of type float that is updated with the download progress percentage.
OnSuccessThe callback method that will be invoked when the import was successful. The method is passed in the imported GameObject as the argument..
OnErrorThe callback method that will be invoked when the import was not successful. The method is passed in an exception that made the task unsuccessful.
importOptionsSpecify additional import options for custom importing.

◆ SimplifyMeshes()

static List<Mesh> BrainFailProductions.PolyFewRuntime.PolyfewRuntime.SimplifyMeshes ( List< Mesh >  meshesToSimplify,
SimplificationOptions  simplificationOptions,
Action< Mesh >  OnEachMeshSimplified 
)
static

Simplifies the meshes provided in the "meshesToSimplify" argument and returns the simplified meshes in a new list. Any errors are thrown as exceptions with relevant information.Please note that the returned list of simplified meshes doesn't guarantee the same order of meshes as supplied in the "meshesToSimplify" list. Please note that preservation spheres don't work with this method.

Parameters
meshesToSimplifyThe list of meshes to simplify.
simplificationOptionsProvide a SimplificationOptions object which contains different parameters and rules for simplifying the meshes. Please note that preservationSphere won't work for this method.
OnEachMeshSimplifiedThis method will be called when a mesh is simplified. The method will be passed the original mesh that was simplified.
Returns
The list of simplified meshes.

◆ SimplifyObjectDeep() [1/3]

static ObjectMeshPairs BrainFailProductions.PolyFewRuntime.PolyfewRuntime.SimplifyObjectDeep ( GameObject  toSimplify,
SimplificationOptions  simplificationOptions 
)
static

Simplifies the meshes nested under the given gameobject(including itself) including the full nested children hierarchy with the settings provided. Retuns back a specialized data structure with the simplified meshes. Any errors are thrown as exceptions with relevant information. Please note that the method won't simplify the object if the simplification strength provided in the SimplificationOptions is close to 0.

Parameters
toSimplifyThe gameobject to simplify.
simplificationOptionsProvide a SimplificationOptions object which contains different parameters and rules for simplifying the meshes.
OnEachMeshSimplifiedThis method will be called when a mesh is simplified. The method will be passed a gameobject whose mesh is simplified and some information about the original unsimplified mesh.
Returns
A specialized data structure that holds information about all the simplified meshes and their information and the GameObjects with which they are associated. Please note that in case the simplificationStrength was near 0 the method doesn't simplify any meshes and returns null.

◆ SimplifyObjectDeep() [2/3]

static int BrainFailProductions.PolyFewRuntime.PolyfewRuntime.SimplifyObjectDeep ( GameObject  toSimplify,
SimplificationOptions  simplificationOptions,
Action< GameObject, MeshRendererPair OnEachMeshSimplified 
)
static

Simplifies the provided gameobject include the full nested children hierarchy with the settings provided. Any errors are thrown as exceptions with relevant information. Please note that the method won't simplify the object if the simplification strength provided in the SimplificationOptions is close to 0.

Parameters
toSimplifyThe gameobject to simplify.
simplificationOptionsProvide a SimplificationOptions object which contains different parameters and rules for simplifying the meshes.
OnEachMeshSimplifiedThis method will be called when a mesh is simplified. The method will be passed a gameobject whose mesh is simplified and some information about the original unsimplified mesh. If you donot want to receive this callback then you can pass null as an argument here.
Returns
The total number of triangles after simplifying the provided gameobject inlcuding the nested children hierarchies. Please note that the method returns -1 if the method doesn't simplify the object.

◆ SimplifyObjectDeep() [3/3]

static int BrainFailProductions.PolyFewRuntime.PolyfewRuntime.SimplifyObjectDeep ( ObjectMeshPairs  objectMeshPairs,
SimplificationOptions  simplificationOptions,
Action< GameObject, MeshRendererPair OnEachMeshSimplified 
)
static

Simplifies the meshes provided in the "objectMeshPairs" argument and assigns the simplified meshes to the corresponding objects. Any errors are thrown as exceptions with relevant information. Please note that the method won't simplify the object if the simplification strength provided in the SimplificationOptions is close to 0.

Parameters
objectMeshPairsThe ObjectMeshPairs data structure which holds relationship between objects and the corresponding meshes which will be simplified. You can get this structure by calling "GetObjectMeshPairs(GameObject forObject, bool includeInactive)" method.
simplificationOptionsProvide a SimplificationOptions object which contains different parameters and rules for simplifying the meshes.
OnEachMeshSimplifiedThis method will be called when a mesh is simplified. The method will be passed a gameobject whose mesh is simplified and some information about the original unsimplified mesh. If you donot want to receive this callback then you can pass null as an argument here.
Returns
The total number of triangles after simplifying the provided gameobject inlcuding the nested children hierarchies. Please note that the method returns -1 is the method doesn't simplify the object.

The documentation for this class was generated from the following file:
www.000webhost.com