Search Unity

TriLib - Model Loading Package

Discussion in 'Assets and Asset Store' started by rickomax, Jun 21, 2017.

  1. Johetan

    Johetan

    Joined:
    Mar 10, 2022
    Posts:
    9
    Hi, I don't know if something similar was asked before - dont know the exact search cues.
    I am currently trying to get an image tracker to display the loaded object.
    Iam fairly new to C# and Unity.
    Do you guys know how to do that?
     
  2. unity_5F3233DDF34AF1474DBC

    unity_5F3233DDF34AF1474DBC

    Joined:
    Dec 11, 2021
    Posts:
    18
    Hi, I'm trying to load animation using trilib. here is the situation, I downloaded a fbx file with animation from mixamo then I tried to import it into my sample game using trilib. do note that I added the assetloaderoption.automaticallyplaylegacyanimations. The problem is its not animating. What is the proper way of importing fbx files with animation using trilib
     
  3. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    The behavior was fixed when I switched the application's colorspace from linear to gamma. I will stay there >:)
     
  4. Johetan

    Johetan

    Joined:
    Mar 10, 2022
    Posts:
    9
    I solved this.
    I used:
    Code (CSharp):
    1.  
    2. loaded_Object = assetLoaderContext.RootGameObject;
    3. loaded_Object.SetActive(false);
    4.  
    My second script called the loading script:
    Code (CSharp):
    1. public class ModelLoaderOBJ : MonoBehaviour
    as:
    Code (CSharp):
    1. public ModelLoaderOBJ modelLoaderOBJ;
    and then i used:
    Code (CSharp):
    1. spawned_Object = model_LoaderOBJ.loaded_Object;
    2. spawned_Object.SetActive(true);
    This all seems to do the trick.
     
  5. Kavithagamer

    Kavithagamer

    Joined:
    Feb 18, 2022
    Posts:
    8
    Hi. Currently i am developing VR multiplayer project using PUN. I would like to use Trilib to load my avatars dynamically, but i do have a trouble in understanding how to send avatar datas to other avatars in the network. once the avatar is loaded how do i send the data to other avatars in the network.... please help me
     
  6. sharramon

    sharramon

    Joined:
    Nov 11, 2018
    Posts:
    5
    Hey,

    I've been digging around for ages, and reading through the API. But I have a relatively simple question of 'how do I just load a model in with its textures (.jpeg file in the same folder) during runtime?', and I can't find the answer to this.

    Does anyone have a straightforward answer, or any resources that just shows me how to do this step-by-step?
     
    felbit likes this.
  7. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Does anyone know if the Standalone File Browser DLLs run on Apple Silicon Macs? I'm trying to get it running on my M1 Macbook Air and I'm getting this error when trying to open a file browser panel.

    It works fine on my PC:
    Code (CSharp):
    1.  DllNotFoundException: StandaloneFileBrowser assembly:<unknown assembly> type:<unknown type> member:(null)
    2. Stack Trace:  TriLibCore.SFB.StandaloneFileBrowserMac.OpenFilePanel (System.String title, System.String directory, TriLibCore.SFB.ExtensionFilter[] extensions, System.Boolean multiselect)
    It works in the editor, but not in builds.
    Any help would be appreciated.
    Thanks!

    EDIT:
    I set the StandaloneFileBrowser.Bundle to work on Apple Silicon CPUs and still no luck.
    Here's the info from a Logfile of a development build:


    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/StandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.so
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.bundle
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/StandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.so
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.bundle
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/StandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.so
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.bundle
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/StandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.dylib
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.so
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser.bundle
    Fallback handler could not load library /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Builds/SceneForge Studio Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libStandaloneFileBrowser
    Uploading Crash Report
    DllNotFoundException: StandaloneFileBrowser assembly:<unknown assembly> type:<unknown type> member:(null)
    at (wrapper managed-to-native) TriLibCore.SFB.StandaloneFileBrowserMac.DialogOpenFilePanel(string,string,string,bool)
    at TriLibCore.SFB.StandaloneFileBrowserMac.OpenFilePanel (System.String title, System.String directory, TriLibCore.SFB.ExtensionFilter[] extensions, System.Boolean multiselect) [0x00001] in /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Assets/TriLib/TriLibStandaloneFileBrowser/StandaloneFileBrowser/StandaloneFileBrowserMac.cs:52
    at TriLibCore.SFB.StandaloneFileBrowser.OpenFilePanel (System.String title, System.String directory, TriLibCore.SFB.ExtensionFilter[] extensions, System.Boolean multiselect) [0x00001] in /Users/judahmantell/Documents/GitHub/SceneForge Master/SceneForge Master/Assets/TriLib/TriLibStandaloneFileBrowser/StandaloneFileBrowser/StandaloneFileBrowser.cs:53

    EDIT 2:
    In the warnings section of the console, I get warnings saying:
    Code (CSharp):
    1.  
    2. Plugins:  Couldn't open <path to mac bundle>
    3. Assets/TriLib/TriLibStandaloneFileBrowser/StandaloneFileBrowser/Plugins/StandaloneFileBrowser.bundle/Contents/MacOS/StandaloneFileBrowser'
    4. (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/StandaloneFileBrowser' (no such file), '/usr/lib/StandaloneFileBrowser' (no such file)
    5.  
    Is there an Arm64 bundle available somewhere?
     
    Last edited: May 28, 2022
  8. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    The wiki is very helpful and has many examples:
    https://ricardoreis.net/trilibwiki/index.php/Basic_Usage
    Note that unless you add some custom functionality for binding textures within your Unity project, the jpeg textures need to be associated with the 3D model from within your modeling package, or wherever the model is from.

    Hope that helps!
     
  9. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    We cannot compile the newest version of TriLib for windows via IL2CPP (unity 2020.3.34f1 and 2021.3.3f1). We are using just the example scene with the filebrowser. Using the c++ configuration for Debug will work, Release or Master does not. The cl.exe hangs on "TriLibCore.cpp". Does anybody else have this problem or can provide a fix?
     
  10. nedhaljalali

    nedhaljalali

    Joined:
    Sep 14, 2017
    Posts:
    13
    hello ..
    Is it ok to download the mesh under the same bones root ?
    for example the (avatar Hair) it must be attached to head node
    i trayed but i am facing some problems .
    any Special thing to do ?
     
  11. felbit

    felbit

    Joined:
    Apr 23, 2020
    Posts:
    1
    Would anyone have a simple example on how to use the Trilib to LoadModelFromFile() when the 3D Object has textures? I am being able to Load the 3D Object, but it doesn't show the textures.
    I am not sure if the problem is my 3D object file or if it is they code that I am using from https://ricardoreis.net/trilibwiki/index.php/Basic_Usage

    Or maybe if someone could send me a fbx, obj or gltf file with the correct textures, so i can test from my side, it would be great too.
     
  12. nedhaljalali

    nedhaljalali

    Joined:
    Sep 14, 2017
    Posts:
    13
    i think you need to change the image to png before you save it as fbx in 3dmax
     
  13. deanlupini

    deanlupini

    Joined:
    Nov 11, 2016
    Posts:
    1
    Is loading .dxf supported? It's listed in the supported file lists, but returns a null object when trying to load.
     
  14. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    111
    Any news on support for blender importing? And also i noticed submeshes are merged into on mesh, is there an option to split submeshes into multiple objects? Thank you!
     
  15. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    Hi Ricardo,

    I sent an email to you regarding the issue I'm seeing but maybe you did not receive it?

    Have a strange issue with Trilib 2 and wondering if you could provide any help on how to debug.

    We have a single function to load our models:



    What we've found is that depending on where this function is called from we get different results.



    If you could check the attached video you'll see when we go through the 'Import Model' option the material loads fine. When we use our 'Load Scene' option the material doesn't load. What's interesting is they both use the same AssetLoader.LoadModelFromStream() call with the exact same parameter...

    Any idea on how we could debug this? It seems the LoadScene just skips right to progress of 1 without loading materials.
     
  16. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I guess I have answered your email
    Your OBJ file is misinterpreted by many 3D loaders, including TriLib.
    I could not find a fix for it yet. I'm trying to find a way to fix the loading without breaking compatibility with existing models.
     
    theolagendijk likes this.
  17. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Hey Ricardo,
    I saw on your Twitter that you put out a poll for export functionality. I'm actually in need of scene exporting for my app and have been looking at various ways of doing it.
    At the moment I'm working on gltFast's runtime export API, but that's only in GLTF/GLB Format.

    Is this a feature you're seriously considering? If so, do you have a rough timeline and what formats you want to support?

    Thanks!
     
    look001 likes this.
  18. Johetan

    Johetan

    Joined:
    Mar 10, 2022
    Posts:
    9
    I solved all my previous issues. Although synchronous and asynchronous loading of very large models will freeze my entire application.
    Is there a way to circumvent that?
    I use a zip file, then iterate through all .obj Inside that zip file. (+100 .obj) or use one very large .obj (140Mb)
     
  19. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    Hi,

    I am in 2.1.6 version, but this problem still persists.

    On Android I can not use the same AssetLoaderOptions as on WebGL or in Unity Editor, because it suddenly breaks the Android app, just after importing the meshes.
    I had to set TextureCompressionQuality to NoCompression and switch GenerateMipmaps off to fix this.
     
  20. Johetan

    Johetan

    Joined:
    Mar 10, 2022
    Posts:
    9
    Is it possible to use the Job System for the AssetLoader?
    Make the Function Containing the Loader a Task does not seem to work.
     
  21. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Sorry for not catching up with the forum. I will be answering the previous questions.
    The upcoming TriLib update has some great news:
    -Improved memory usage and performance (50% of improvement while loading OBJ files)
    -Fixed StandaloneFileBrowser issues on Apple Silicon platforms
    -Fixed TriLib compilation issues on IL2CPP platforms
    -Added point clouds loading support (PLY and OBJ files)
     
    JudahMantell and Johetan like this.
  22. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    @rickomax would really appreciate any input into my issue which is a few posts up. Still dealing with this issue. Thanks.
     
  23. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    We might have to debug deeper to find out the issue source.
    Do you have Skype or Discord?
     
  24. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
  25. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
  26. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    In my app I allow the users to "Import" models, then I save the associated AssetloaderOptions + file path to Json.
    Then when they load back in their save, I go through and reimport all previously imported models. This is frustratingly slow at times, and I was wondering if there was any way to improve loading speeds when loading them one by one?

    I'm basically just looping through a list and calling AssetLoader.LoadModelFromFile for each one.
    I know that's Async by default, but do you think that switching to the NoThread version would be more straightforward?

    How do Unity and other apps not require a total reimport of models every time a project is loaded? Is that something that can be done with Trilib?

    Thanks!
     
  27. Johetan

    Johetan

    Joined:
    Mar 10, 2022
    Posts:
    9
    I just updated to 2.17, for my Scripts I get the Error:


    Assets\Scripts\ModelCreator\ModelLoaderSTL.cs(36,46): error CS0117: 'AssetLoader' does not contain a definition for 'CreateDefaultLoaderOptions'



    Assets\Scripts\ModelCreator\ModelLoaderSTL.cs(39,21): error CS0117: 'AssetLoader' does not contain a definition for 'LoadModelFromFile'


    The Samples do not show this error.
    I did rebuild the Library, uninstalled and installed the Package, rebuild CSProjFiles

    EDIT:
    Revert to a Backup and then re-update trilib solved the Problem.

    But, is there a way, to make the loading faster?
     
    Last edited: Jul 18, 2022
  28. whitegreenstudios88

    whitegreenstudios88

    Joined:
    Dec 12, 2021
    Posts:
    10
    Hi Rick,
    I have a question on webgl runtime loading avatar freezing for few seconds. I know webgl not running multithread cause the freeze, is it possible to eliminate the freeze with Unitask? Tq
     
  29. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    EDITED POST:
    Alright so just a PSA of some usage info I was unaware of! Maybe @rickomax can confirm/correct me.
    OnError loading callback will be called if there is an error in your OnLoad or OnMaterial load code!
    I thought it was just if there was an issue with the model itself, but no, I had an indexOutOfRange exception in my OnMaterialsLoad block and that triggered the OnError.

    That will also make the Dispatcher script throw the error for you which can be a bit misleading.

    Hope that helps someone else!
     
    Last edited: Jul 22, 2022
  30. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Follow Up question:
    What's the best way to manage memory when dealing with runtime models?

    For example, in my app I import models, which are then inactive in my scene. Then the user can instantiate copies of that model from a UI element. I do this with multiple models.
    Then I destroy the copies as the user wants, always keeping the original import disabled in my scene.

    I realize this is probably not the most memory-conscious way of dealing with it though.

    Is there a better way of "Unloading" models while still keeping them 'instantiate-able'?
    Or at least any suggestions for managing imported models more effectively?
    Addressables come to mind, but I don't think you can use them at runtime...

    Thanks!
     
  31. Lupeni

    Lupeni

    Joined:
    Aug 13, 2017
    Posts:
    5
    Hi, when is .DAE import gonna be released?
    Thanks!
     
  32. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    @rickomax Hi Ricardo, haven't seen anything back from you on the multiple channels I've tried to reach out via.
     
  33. Arctous

    Arctous

    Joined:
    Aug 25, 2014
    Posts:
    26
    I am unable to load any of my assets. An exception is being thrown. How can I get more information in order to fix this? Also, does this have to be a fatal error? Unity3D has absolutely zero issues with any of my files.

    Here is the output of the load.

    Merged vertices from mesh [4]. Before: 15960. After: 15960
    Merged vertices from mesh [3]. Before: 6. After: 6
    Merged vertices from mesh [1]. Before: 33708. After: 33708
    Merged vertices from mesh [2]. Before: 21321. After: 21321
    TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.​

    Here are the exception details

    TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <eae584ce26bc40229c1b1aa476bfa589>:0
    at TriLibCore.AssetLoader.ParseAnimation (TriLibCore.AssetLoaderContext assetLoaderContext, TriLibCore.Interfaces.IAnimation animation) [0x00063] in /Users/cfebbert/proj/Software/Develop/MOTI/TriLibSamples/Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:853
    at TriLibCore.AssetLoader.SetupAnimationComponents (TriLibCore.AssetLoaderContext assetLoaderContext, System.Collections.Generic.IList`1[T] animations, UnityEngine.AnimationClip[]& animationClips, UnityEngine.Animator& animator, UnityEngine.Animation& unityAnimation) [0x0009f] in /Users/cfebbert/proj/Software/Develop/MOTI/TriLibSamples/Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:563
    at TriLibCore.AssetLoader.SetupRig (TriLibCore.AssetLoaderContext assetLoaderContext) [0x0005b] in /Users/cfebbert/proj/Software/Develop/MOTI/TriLibSamples/Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:479
    at TriLibCore.AssetLoader.ProcessModel (TriLibCore.AssetLoaderContext assetLoaderContext) [0x000bf] in /Users/cfebbert/proj/Software/Develop/MOTI/TriLibSamples/Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:398
    at TriLibCore.AssetLoader.ProcessRootModel (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00001] in /Users/cfebbert/proj/Software/Develop/MOTI/TriLibSamples/Assets/TriLib/TriLibCore/Scripts/AssetLoader.cs:1103
    at TriLibCore.General.ContextualizedAction`1[T].Invoke () [0x00000] in <801b7a91f96342f487ccd93b888b5a47>:0
    at TriLibCore.Utils.Dispatcher.Update () [0x0001d] in <801b7a91f96342f487ccd93b888b5a47>:0
    --- End of inner exception stack trace --- (at ?)
    UnityEngine.Debug:LogError (object) (at ?)
    TriLibCore.Samples.AssetViewerBase:OnError (TriLibCore.IContextualizedError) (at Assets/TriLib/TriLibSamples/Common/Scripts/AssetViewerBase.cs:256)
    TriLibCore.Samples.AssetViewer:OnError (TriLibCore.IContextualizedError) (at Assets/TriLib/TriLibSamples/AssetViewer/Scripts/AssetViewer.cs:611) (at ?)
    TriLibCore.General.ContextualizedAction`1<TriLibCore.IContextualizedError>:Invoke () (at ?) (at ?)
    TriLibCore.Utils.Dispatcher:Update () (at ?)​
     
    Last edited: Aug 5, 2022
  34. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    293
    I have a quick question.
    I just downloaded the plugin, and I want to use it to import a FBX file. However, all samples and the documentation use the AssetLoader.LoadModelFromX functions, which automatically create a GameObject in the scene and I don't want that. I only want the mesh. I have a different kind of object that needs a mesh. How can I import the model in the background and only get the mesh?
     
  35. fra3point

    fra3point

    Joined:
    Aug 20, 2012
    Posts:
    269
    Why don't you simply disable the generated GameObject right after loading, retrieve the mesh in its MeshFilter and assign it to your object?
     
  36. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    293
    I can delete the GameObject after retrieving the mesh, but I find it inelegant. And I can't fathom why a package that calls itself a Mesh Importer is not able to import a mesh without creating a gameobject.
     
    fra3point likes this.
  37. fra3point

    fra3point

    Joined:
    Aug 20, 2012
    Posts:
    269
    If a FBX file happens to contain a single mesh, the function you're looking for makes sense. But in general, FBX files can contain multiple (even nested) nodes, each with its own mesh. Therefore, the better way to import a FBX file is creating a full hierarchy. GameObjects are the best choice to import a full, generic FBX files in my opinion, because of their hierarchical structure.
     
  38. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    293
    That hierarchy can also be represented in some internal datastructure. There is no need to create objects in the scene. I'd also challenge the idea that GameObjects are the best choice. They might be an easier choice, because they already exist and implicitly have a transform component that supports parenting.
     
    fra3point likes this.
  39. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    I think that is just not what this library is for - it is about making a scene object.
    If you change to gltf/glb format (open format, more optimized for game-use) then you can use the open source glTFast library which lets you customize every step of the process.
     
  40. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    111
    The TriLib asset is pretty good and the only asset i have found to import on so many plattforms. I would like to request importing of multiple texture layers. Thank you for sharing your work!
     
  41. g4ma

    g4ma

    Joined:
    Dec 18, 2018
    Posts:
    32
    Hi! When loading a relatively large FBX (~500k vertices) I end up with the following error:

    TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> System.Exception: Float count is too high to build a suitable Flexible Geometry Group


    Problem is, this same file could be loaded with 2.1.6, I only have the issue since 2.1.8 (I skipped 2.1.7 so the issue could be there).

    So what caused that regression? Can we please have a fix?

    Another bug - although tiny - I found was that the assembly def for Trilib.Core.Editor was set for "all platforms" rather than "Editor" only, resulting in builds failing.
    The workaround is easy (enabling only Editor platform for this assembly def) but as I might not be the only one building with Trilib it might be worth fixing it.
     
  42. Nsdpds

    Nsdpds

    Joined:
    Jun 13, 2021
    Posts:
    1
    An error occurred while loading your Model: System.NullReferenceException: Object reference not set to an instance of an object

    This error occurs when the model is running, but sometimes it fails to load the model.
    May I know a solution to this?



    upload_2022-10-3_21-24-52.png
     
  43. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    [SOLVED]
    Solution is at the end



    Hello developers,
    I'm trying to use TriLib2 version 0.0.0 with WebGL by downloading the file from a server and then loading it in the web.

    What happens:
    When I try to download the file by this code in the unity editor with version 2019.4.16f1 open with the webGL platform

    Code (CSharp):
    1. try
    2.         {
    3.             lastWriteTime = CheckLastFileWriteTime(url, lastWriteTime);
    4.  
    5.  
    6.             HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
    7.  
    8.             myHttpWebRequest.IfModifiedSince = lastWriteTime;
    9.             if (myHttpWebRequest != null)
    10.             {
    11.                 // Send the request to the server and retrieve the
    12.                 // WebResponse object
    13.                 response = await myHttpWebRequest.GetResponseAsync();
    14.  
    15.                 if (response != null)
    16.                 {
    17.                     // Once the WebResponse object has been retrieved,
    18.                     // get the stream object associated with the response's data
    19.                     remoteStream = response.GetResponseStream();
    20.  
    21. #if UNITY_WEBGL && !UNITY_EDITOR
    22.                     localStream = File.Create(Application.persistentDataPath + "\\car.fbx");
    23. #else
    24.                     localStream = File.Create(Application.persistentDataPath + "\\car.fbx");
    25. #endif
    26.  
    27.  
    28.                     await remoteStream.CopyToAsync(localStream);
    29.  
    30.                     DynamicObjectLoader.LoadModelFromStream(remoteStream);
    31.                
    32.  
    33.                     return 1;
    34.                 }
    35.                 else return -1;
    36.             }
    37.             else
    38.                 return -1;
    39.         }
    40.         catch (WebException e)
    41.         {
    42.             using (WebResponse responseEx = e.Response)
    43.             {
    44.                 HttpWebResponse httpResponse = (HttpWebResponse)responseEx;
    45.                 if (httpResponse.StatusCode == HttpStatusCode.NotModified)
    46.                     return 0;
    47.                 else
    48.                     return -1;
    49.  
    50.  
    51.             }
    52.         }
    53.         catch (Exception e)
    54.         {
    55.             Debug.LogException(e);
    56.  
    57.             return -1;
    58.         }
    59.         finally
    60.         {
    61.  
    62.      
    63.             // Close the response and streams objects here
    64.             // to make sure they're closed even if an exception
    65.             // is thrown at some point
    66.             if (response != null) response.Close();
    67.             if (remoteStream != null) remoteStream.Close();
    68.             if (localStream != null) localStream.Close();
    69.  
    70.  
    71.         }

    and to load the model downloaded with this method inside the class DynamicObjectLoader
    public static void LoadModelFromStream(Stream modelStream)
    {
    Debug.Log(" loading stream ....");
    var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    assetLoaderOptions.Timeout = 180;
    assetLoaderOptions.ShowLoadingWarnings = true;
    assetLoaderOptions.UseUnityNativeTextureLoader = true;
    assetLoaderOptions.AlphaMaterialMode = AlphaMaterialMode.Cutout;
    GameObject wreapperGO = new GameObject("remoteLoadedGO");
    wreapperGO.transform.position = Vector3.zero;

    AssetLoader.LoadModelFromStream(modelStream, "car.fbx", ".fbx", OnLoad, OnMaterialsLoad, OnProgress, OnError, wreapperGO, assetLoaderOptions);
    }

    It gives me this error:

    An error ocurred while loading your Model: System.NotSupportedException: Specified method is not supported.
    at System.Net.WebConnectionStream.Seek (System.Int64 a, System.IO.SeekOrigin b) [0x00000] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0
    at TriLibCore.Fbx.Reader.FbxReader.IsBinary (System.IO.Stream stream) [0x0002e] in <945e63fa264a4141a231289f0c993b30>:0
    at TriLibCore.Fbx.Reader.FbxReader.ReadStream (System.IO.Stream stream, TriLibCore.AssetLoaderContext assetLoaderContext, System.String filename, System.Action`2[T1,T2] onProgress) [0x0000c] in <945e63fa264a4141a231289f0c993b30>:0
    at TriLibCore.AssetLoader.SetupModelLoading (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00150] in C:\Users\s.gurzi\Desktop\Progetti\WebGLScouting\Assets\TriLib\TriLibCore\Scripts\AssetLoader.cs:1158
    at TriLibCore.AssetLoader.LoadModel (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00001] in C:\Users\s.gurzi\Desktop\Progetti\WebGLScouting\Assets\TriLib\TriLibCore\Scripts\AssetLoader.cs:1056
    at TriLibCore.Utils.ThreadUtils.RequestNewThreadFor[T] (T context, System.Threading.CancellationToken& cancellationToken, System.Action`1[T] onStart, System.Action`1[T] onComplete, System.Action`1[T] onError, System.Int32 timeout, System.String name, System.Boolean startImmediately, System.Action`1[T] onCompleteSameThread) [0x000d6] in <2016f0bb4864467baa3d282ad3b52d51>:0
    UnityEngine.Debug:LogError(Object)
    DynamicObjectLoader:OnError(IContextualizedError) (at Assets/Scripts/DynamicObjectLoader.cs:38)
    TriLibCore.General.ContextualizedAction`1:Invoke()
    TriLibCore.Utils.Dispatcher:Update()

    What I did already try:

    There is a sample scene called "SimpleCustomAssetLoader" that get delivered with the package which works also in the editor and in the browser for loading model but only if you select a model from your file browser.
    The option with the url download doesn't work which is why I tryed to use the trilib method to load the file from a stream and not directly the one that exploits its URL.

    I hope that in the future the sample scene "SimpleCustomAssetLoader" will get fixed so that I will be able to understand how to use TriLib with WebGL.
    In the meanwhile I would really appreciate any suggestion on how to load the model after downloading it from a remote server


    Thank you all :)

    [SOLUTION]
    I was downloading the model in a wrong way. I used this class to download the model and then the metod provided from triLib worked
     
    Last edited: Oct 24, 2022
  44. FrancoRet

    FrancoRet

    Joined:
    Feb 4, 2020
    Posts:
    3
    Hi,

    We've been using Trilib2 for a while, and in general, it works great, however, we've noticed 2 major issues with it.

    1. When your import an FBX that has multiple meshes, and say 2 meshes have different materials, but both materials have some textures in common, Trilib seems to be repeating the texture in memory, by creating two different texture instances. Whereas Unity import or any FBX reader would use the same texture references.

    2. Trilib doesn't read blendshapes with multiple frames on them properly, it always creates blendshapes with just 1 frame, and ignores some of the other frames.

    Hopefully these problems can be addressed in a future update!
     
  45. moritz_jaeger

    moritz_jaeger

    Joined:
    Jun 15, 2015
    Posts:
    7
    Hi rickomax, since we switched our project to URP we are also experiencing the same problem as Chopium, that all materials generated by Trilib have a very metallic look on mobile devices (IOS + Android). In the editor they look fine.

    We are using Gamma color space already, so the fix that helped Chopium doesn't help us.

    EDIT: Some additional infos: We are importing fbx files, are using Unity 2021.3 and Trilib 2.1.8.

    The models look fine when imported into your web viewer.
     
    Last edited: Oct 20, 2022
  46. appiloper

    appiloper

    Joined:
    May 27, 2021
    Posts:
    1
    @rickomax Hi Ricardo,

    How can I prevent activation of the makeNoLongerReadable property when importing a texture? I want to save the texture as a file, unfortunately I get this warning from the storage component Easy Save:
    Easy Save cannot save the pixels or properties of this Texture because it is not read/write enabled, so Easy Save will store it by reference instead. To save the pixel data, check the 'Read/Write Enabled' checkbox in the Texture's import settings. Clicking this warning will take you to the Texture, assuming it is not generated at runtime.

    I also tried this:
    Code (CSharp):
    1. var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();          
    2.             assetLoaderOptions.MarkTexturesNoLongerReadable = false;
    3.             var assetLoaderFilePicker = AssetLoaderFilePicker.Create();
    4.             assetLoaderFilePicker.LoadModelFromFilePickerAsync("Select a Model file", OnLoad, OnMaterialsLoad, OnProgress, OnBeginLoad, OnError, null, assetLoaderOptions);
    But this gives me only an obsolete warning and does not make the texture readable. I still get the above „Easy Save cannot save…“ warning.

    Any chance to fix this problem from your side.
    I would appreciate that very much!
     
  47. oudon

    oudon

    Joined:
    Aug 14, 2015
    Posts:
    1
    @rickomax Hi Ricardo,

    Please excuse my poor English.

    I have a problem when loading FBX with NormalMap.
    TextureFormat of NormalMap is loaded as "R8G8B8A8_SRGB".

    I tracked down the source code.

    FBXMaterial.cs:
    Code (CSharp):
    1. public void AddProperty(string propertyName, object propertyValue, bool isTexture)
    2. {
    3.   if (propertyValue is ITexture texture && ((IEnumerable<string>) FBXMaterial.NormalMapPropertyNames).Contains<string>(propertyName))
    4.     texture.TextureFormat = TriLibCore.General.TextureFormat.UNorm;
    5.   this._properties[propertyName] = propertyValue;
    6. }
    7.  
    8. // NormalMapPropertyNames define
    9. private static readonly string[] NormalMapPropertyNames = new string[5]
    10. {
    11.   "NormalMap",
    12.   "Bump",
    13.   "normal_map",
    14.   "bump_map",
    15.   "norm_map"
    16. };
    It looks like the NormalMap is not well judged here.

    The determination seems to be failing due to the "Tex" string appended to the propertyName.

    FBXProcessor.cs:
    Code (CSharp):
    1. string propertyName = str + "Tex";
    2. if (!fbxMaterial1.HasProperty(propertyName))
    3. {
    4.   fbxMaterial1.AddProperty(propertyName, (object) propertyValue1, true);
    5.   continue;
    6. }
    7.  
    However, since it is a code in the dll, I cannot fix it myself.
    I hope this problem is solved.
    Or if there is any other better solution please let me know.

    TriLib version:2.1.8
    Unity version: 2021.3.0f1
    Color Space:Linear

    Thanks.
     
    NRBTATA likes this.
  48. sbkim_morph

    sbkim_morph

    Joined:
    Apr 21, 2022
    Posts:
    8
    @rickomax Hello, I am contacting you because an error occurred while using the TriLib2 Library.

    [Environment in use]
    Editor: Unity2020.3.32f1 (LTS)
    Platform: PC, Mac & Linux Standalone
    OS: Windows10
    TriLib version:2.1.8

    While loading fbx at runtime with standalone build, the following error occurs. It only occurs in a specific fbx and other fbx seems to be fine.

    May I know the cause of this error or how to fix it?

    Code (CSharp):
    1. TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> System.Exception: Float count is too high to build a suitable Flexible Geometry Group
    2.   at TriLibCore.Geometries.FlexibleVertexDataUtils.BuildFlexibleGeometryGroup (System.Collections.Generic.Dictionary`2[TKey,TValue] vertexAttributes, System.Int32 floatCount) [0x002c5] in <2016f0bb4864467baa3d282ad3b52d51>:0
    3.   at TriLibCore.Fbx.FBXGeometryGroupFactory.Get (TriLibCore.AssetLoaderContext assetLoaderContext, System.Boolean hasNormal, System.Boolean hasMaterial, System.Boolean hasColor, System.Boolean hasUv0, System.Boolean hasUv1, System.Boolean hasUv2, System.Boolean hasUv3, System.Boolean hasSkin, TriLibCore.Fbx.FBXDocument document, System.String name, System.Int64 objectId, System.String objectClass, System.Boolean cloned) [0x00016] in <945e63fa264a4141a231289f0c993b30>:0
    4.   at TriLibCore.Fbx.FBXProcessor.ProcessGeometryGroup (TriLibCore.Fbx.FBXNode node, System.Int64 objectId, System.String name, System.String objectClass) [0x00200] in <945e63fa264a4141a231289f0c993b30>:0
    5.   at TriLibCore.Fbx.FBXProcessor.ProcessObjects (TriLibCore.Fbx.FBXNode node) [0x00538] in <945e63fa264a4141a231289f0c993b30>:0
    6.   at TriLibCore.Fbx.FBXProcessor.Process (TriLibCore.Fbx.FBXNode rootNode, System.Boolean isBinary) [0x00064] in <945e63fa264a4141a231289f0c993b30>:0
    7.   at TriLibCore.Fbx.Reader.FbxReader.ParseBinary (System.IO.Stream stream) [0x00056] in <945e63fa264a4141a231289f0c993b30>:0
    8.   at TriLibCore.Fbx.Reader.FbxReader.ReadStream (System.IO.Stream stream, TriLibCore.AssetLoaderContext assetLoaderContext, System.String filename, System.Action`2[T1,T2] onProgress) [0x00014] in <945e63fa264a4141a231289f0c993b30>:0
    9.   at TriLibCore.AssetLoader.SetupModelLoading (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00150] in C:\morph\ACOP\acop_studio\Assets\Treal\OpenFrameworkStudio\Plugins\TriLib\TriLibCore\Scripts\AssetLoader.cs:1158
    10.   at TriLibCore.AssetLoader.LoadModel (TriLibCore.AssetLoaderContext assetLoaderContext) [0x00001] in C:\morph\ACOP\acop_studio\Assets\Treal\OpenFrameworkStudio\Plugins\TriLib\TriLibCore\Scripts\AssetLoader.cs:1056
    11.   at TriLibCore.General.ContextualizedAction`1[T].Invoke () [0x00000] in <2016f0bb4864467baa3d282ad3b52d51>:0
    12.   at TriLibCore.Utils.ThreadUtils+<>c__DisplayClass0_0`1[T].<RequestNewThreadFor>b__0 () [0x0002f] in <2016f0bb4864467baa3d282ad3b52d51>:0
    13.    --- End of inner exception stack trace ---
    14. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    15. UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
    16. UnityEngine.Logger:Log (UnityEngine.LogType,object)
    17. UnityEngine.Debug:LogError (object)
    18. TriLibCore.Samples.AssetViewerBase:OnError (TriLibCore.IContextualizedError) (at C:/morph/ACOP/acop_studio/Assets/Treal/OpenFrameworkStudio/Plugins/TriLib/TriLibSamples/Common/Scripts/AssetViewerBase.cs:257)
    19. FbxLoader:OnError (TriLibCore.IContextualizedError) (at C:/morph/ACOP/acop_studio/Assets/Treal/OpenFrameworkStudio/Scripts/CostumeSetting/FbxLoader.cs:78)
    20. TriLibCore.General.ContextualizedAction`1<TriLibCore.IContextualizedError>:Invoke ()
    21. TriLibCore.Utils.Dispatcher:Update ()
     
    Last edited: Nov 15, 2022
    g4ma and ychangmin94 like this.
  49. g4ma

    g4ma

    Joined:
    Dec 18, 2018
    Posts:
    32
    Similar to my post here although I have not had any answer yet.

    How many vertices are they in that failing FBX? You can import it in Blender to get an idea.
     
  50. sbkim_morph

    sbkim_morph

    Joined:
    Apr 21, 2022
    Posts:
    8
    hello. Currently, the number of vertices of the model that has problems loading FBX is "8877". The FBX models with the above errors seem to occur when more than 4 UV mappings (UV0 ~ UV3) are present. (If you make two UVs (UV0 ~ UV1) with the same model, check that they are loaded)