AsImpL 1.0
Asynchronous Importer and run-time Loader for Unity
AsImpL.LoaderObj Class Reference

Class for loading OBJ files into Unity scene at run-time and in editor mode. More...

Inheritance diagram for AsImpL.LoaderObj:
AsImpL.Loader

Public Member Functions

override string[] ParseTexturePaths (string absolutePath)
 Parse dependencies of the given OBJ file. More...
 
- Public Member Functions inherited from AsImpL.Loader
IEnumerator Load (string objName, string absolutePath, Transform parentObj)
 Load a model. More...
 

Protected Member Functions

override IEnumerator LoadModelFile (string absolutePath)
 Load the main model file More...
 
override IEnumerator LoadMaterialLibrary (string absolutePath)
 Load the material library from the given path. More...
 
IEnumerator ParseGeometryData (string objDataText)
 Parse the OBJ file to extract geometry data. More...
 
- Protected Member Functions inherited from AsImpL.Loader
IEnumerator Build (string absolutePath, string objName, Transform parentTransform)
 Build the game objects from data set, materials and textures. More...
 
string GetDirName (string absolutePath)
 Get the directory name of the given path, appending the final slash if eeded. More...
 
virtual void OnLoaded (GameObject obj, string absolutePath)
 
virtual void OnCreated (GameObject obj, string absolutePath)
 
virtual void OnLoadFailed (string absolutePath)
 

Properties

override bool HasMaterialLibrary [get]
 Check if a material library file is defined. More...
 
- Properties inherited from AsImpL.Loader
ObjectBuilder?? ObjectBuilder [getset]
 Warning! This will be removed soon to avoid confusion between the ObjectBuilder class and this property, use Builder property instead. More...
 
ObjectBuilder?? Builder [getset]
 Object used to build the game object hierarchy (it is created if not previously set). More...
 
bool? ConvertVertAxis [getset]
 Load the file assuming its vertical axis is Z instead of Y More...
 
float? Scaling [getset]
 Rescaling for the model (1 = no rescaling) More...
 
IFilesystem Filesystem [getset]
 
abstract bool HasMaterialLibrary [get]
 Check if a material library is defined for this model More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AsImpL.Loader
static GameObject GetModelByPath (string absolutePath)
 Get a previusly loaded model by its absolute path More...
 
- Public Attributes inherited from AsImpL.Loader
ImportOptions buildOptions
 Options to define how the model will be loaded and imported. More...
 
- Static Public Attributes inherited from AsImpL.Loader
static LoadingProgress totalProgress = new LoadingProgress()
 Total loading progress, for all the models currently loading. More...
 
- Protected Attributes inherited from AsImpL.Loader
DataSet dataSet = new DataSet()
 
ObjectBuilder objectBuilder = null
 
List< MaterialDatamaterialData
 
SingleLoadingProgress objLoadingProgress = new SingleLoadingProgress()
 
Stats loadStats
 
- Static Protected Attributes inherited from AsImpL.Loader
static float LOAD_PHASE_PERC = 8f
 
static float TEXTURE_PHASE_PERC = 1f
 
static float MATERIAL_PHASE_PERC = 1f
 
static float BUILD_PHASE_PERC = 90f
 
static Dictionary< string, GameObject > loadedModels = new Dictionary<string, GameObject>()
 
static Dictionary< string, int > instanceCount = new Dictionary<string, int>()
 
- Events inherited from AsImpL.Loader
Action< GameObject, string > ModelCreated
 Event triggered when an object is created. More...
 
Action< GameObject, string > ModelLoaded
 Event triggered when an object is successfully loaded. More...
 
Action< string > ModelError
 Event triggered if failed to load an object More...
 

Detailed Description

Class for loading OBJ files into Unity scene at run-time and in editor mode.

Partially derived from "Runtime OBJ Loader" (http://forum.unity3d.com/threads/free-runtime-obj-loader.365884/) and from "runtime .OBJ file loader for Unity3D" (https://github.com/hammmm/unity-obj-loader) and (https://github.com/cmdr2/unity-remote-obj-loader)

New features:

  • meshes with more than 65K vertices/indices are splitted and loaded
  • groups are loaded into game (sub) objects
  • extended material support
  • computation of normal maps and tangents
  • computation of albedo texture from diffuse and opacity textures
  • progressive loading
  • reusing data for multiple objects
  • create a loader for each model for parallel loading
  • support for asset import
See also
DataSet, MaterialData, ObjectBuilder

Member Function Documentation

◆ LoadMaterialLibrary()

override IEnumerator AsImpL.LoaderObj.LoadMaterialLibrary ( string  absolutePath)
protectedvirtual

Load the material library from the given path.

Parameters
absolutePathabsolute file path

This is called by Load() method

Implements AsImpL.Loader.

◆ LoadModelFile()

override IEnumerator AsImpL.LoaderObj.LoadModelFile ( string  absolutePath)
protectedvirtual

Load the main model file

Parameters
absolutePathabsolute file path

This is called by Load() method

Implements AsImpL.Loader.

◆ ParseGeometryData()

IEnumerator AsImpL.LoaderObj.ParseGeometryData ( string  objDataText)
protected

Parse the OBJ file to extract geometry data.

Parameters
objDataTextOBJ file text
Returns
Execution is splitted into steps to not freeze the caller method.

◆ ParseTexturePaths()

override string[] AsImpL.LoaderObj.ParseTexturePaths ( string  absolutePath)
virtual

Parse dependencies of the given OBJ file.

Parameters
absolutePathabsolute file path
Returns
The list of dependencies (textures files, if any).

Implements AsImpL.Loader.

Property Documentation

◆ HasMaterialLibrary

override bool AsImpL.LoaderObj.HasMaterialLibrary
getprotected

Check if a material library file is defined.


The documentation for this class was generated from the following file: