Category Archives: Uncategorized

TriLib – Known Issues/Limitations

  • All platforms:
    • Exporting will be enabled on a future release (.dae, .obj. stl, .ply formats).
    • Cameras and lights will be enabled on a future release.
    • We highly recommend you to download our test application to test your models before adquiring the package.
    • Old FBX-DOM formats are not supported.
    • Some newer FBX formats will lack the embedded materials, please use our test application with your models to check if your embedded materials are acessible.
    • Vertex animation is not supported .
    • Blend shapes are not supported at the moment.
  • Android:
    • IFC importer is inactive on this release.
    • Android device with API 9 is required.

Note: TriLib is based on Assimp (http://www.assimp.org), an open-source project. We are always updating TriLib with the latest Assimp branch, to guarantee the most recent bug-fixes. We cannot guarantee your model to partially or fully load with TriLib.  (*) not supported on Android platform at the moment.

TriLib – Post Processor Options

Description of the Asset Loader post processor options:

  • Nothing: No post-processor steps will be applied, we don´t recommend enabling this item as it can decrease performance and leave model issues unfixed.
  • Everything: All post-processor steps will be applied, we don´t recommend enabling this item as it´s almost always unecessary to enable all post processor steps.
  • Calc Tangent Space: Calculates the tangents and bitangents for the imported meshes.
  • Join Identical Vertices: Identifies and joins identical vertex data sets within all imported meshes.
  • Make Left Handed: Converts all the imported data to a left-handed coordinate space.
  • Remove Component: Not implemented on this version.
  • Gen Normals: Generates normals for all faces of all meshes.
  • Gen Smooth Normals: Generates smooth normals for all vertices in the mesh.
  • Split Large Meshes: Splits large meshes into smaller sub-meshes.
  • Pre Transform Vertices: Removes the node graph and pre-transforms all vertices with the local transformation matrices of their node.
  • Limit Bone Weights: Limits the number of bones simultaneously affecting a single vertex to a maximum value.
  • Validate Data Structure: Validates the imported scene data structure. This makes sure that all indices are valid, all animations and bones are linked correctly, all material references are correct…etc.
  • Improve Cache Locability: Reorders triangles for better vertex cache locality.
  • Remove Redundant Materials: Searches for redundant/unreferenced materials and removes them
  • Fix Infancing Normals: This step tries to determine which meshes have normal vectors that are facing inwards and inverts them.
  • Sort By P Type: This step splits meshes with more than one primitive type in homogeneous sub-meshes.
  • Find Degenerates: This step searches all meshes for degenerate primitives and converts them to proper lines or points.
  • Find Invalid Data: This step searches all meshes for invalid data, such as zeroed normal vectors or invalid UV coords and removes/fixes them. This is intended to get rid of some common exporter errors.
  • Gen Uv Coords: This step converts non-UV mappings (such as spherical or cylindrical mapping) to proper texture coordinate channels.
  • Transform Uv Coords: This step applies per-texture UV transformations and bakes them into stand-alone vtexture coordinate channels.
  • Find Instances: This step searches for duplicate meshes and replaces them with references to the first mesh.
  • Optmize Mesh: A postprocessing step to reduce the number of meshes.
  • Optimize Graph: A postprocessing step to optimize the scene hierarchy.
  • Flip UVs: This step flips all UV coordinates along the y-axis and adjusts material settings and bitangents accordingly.
  • Flip Winding Order: This step adjusts the output face winding order to be CW.
  • Split By Bone Count: This step splits meshes with many bones into sub-meshes so that each sub-mesh has fewer or as many bones as a given limit.
  • Debone: This step removes bones losslessly or according to some threshold.

TriLib – Tutorial : Enabling DevIL image library

Newest TriLib version includes DevIL image library (only for Windows, at the moment).

What is DevIL image library?

Developer’s Image Library (DevIL) is a programmer’s library to develop applications with very powerful image loading capabilities, yet is easy for a developer to learn and use. Ultimate control of images is left to the developer, so unnecessary conversions, etc. are not performed. DevIL utilizes a simple, yet powerful, syntax. DevIL can load, save, convert, manipulate, filter and display a wide variety of image formats.

Currently, DevIL can load .bmp, .cut, .dds, .doom, .exr, .hdr, .gif, .ico, .jp2, .jpg,.lbm, .mdl, .mng, .pal, .pbm, .pcd, .pcx, .pgm, .pic, .png, .ppm, .psd, .psp, .raw, .sgi, .tga and .tif files.
Formats supported for saving include .bmp, .dds, .h, .jpg, .pal, .pbm, .pcx, .pgm, .png, .ppm, .raw, .sgi, .tga and .tif.

To enable DevIL on your project, first, ensure you have checked these files when importing your TriLib package:

A menu item called “TriLib” will appear on your Unity menu bar.

To enable DevIL, check the “Devil Enabled  (Experimental – Windows Only”)

That´s it.
Now your TriLib models textures will be loaded using DevIL image library instead Unity internal image loader.

TriLib – Tutorial : Importing a model from within your game runtime

Let´s learn how to import an external model from our game code:

First, import TriLib package from the Asset Store.

For this simple model loading purpose, you can check only the “TriLib/TriLib” folder in the import dialog.

The first time you import TriLib to your project, Unity will ask you to restart the editor. If you choose “Ask to save changes and restart”, you will be prompted to save your changes before the editor restarts.

When Unity restart:

Create a new GameObject and add a new CSharp script to it.
We can name it “MyLoader” for the demonstration.

Add the following code to the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TriLib;
using System.IO;

public class MyLoader : MonoBehaviour {
    protected void Start() {
        using (var assetLoader = new AssetLoader()) { //Initializes our Asset Loader.
            var assetLoaderOptions = ScriptableObject.CreateInstance<AssetLoaderOptions>(); //Creates an Asset Loader Options object.
            assetLoaderOptions.AutoPlayAnimations = true; //Indicates that our model will automatically play its first animation, if any.
            var filename = Path.Combine(Path.GetFullPath("."), "turtle1.b3d"); //Combines our current directory with our model filename "turtle1.b3d" and generates the full model path.
            assetLoader.LoadFromFile(filename, assetLoaderOptions); //Loads our model.
        }
    }
}

You have to replace the “turtle1.b3d” string with your model filename. The model will be loaded from within your application folder , so, remember to copy it to your final executable’s path when building it.

Ready!
Your model is already being loaded from an external source.

TriLib – Tutorial: Importing a model from within Unity editor

In this tutorial, we will cover the steps to load your model using TriLib within Unity Editor.

First, import TriLib package to your project,  you can check only the “TriLib” folder for this tutorial, as shown in the following image:

Important: After that, you have to save your changes and restart Unity editor before proceeding with the tutorial, as TriLib native plugins needs to be loaded.

To do so, click on “Ask to save changes and restart”. Otherwise, you will have to restart Unity editor manually.

After the restart, TriLib will scan your “Assets” folder looking for files it can import, everytime a file is found, a prefab with the same name is created.

Note: For files that both Unity editor and TriLib can load (FBX files, for example), Unity native importer will be used.

To configure importing options, click on the original file under the Assets explorer.

Your asset inspector will look like this:

Here you can setup your model with various options, we will cover them here:

  • General Tab
    • Post Processor Options: Please refer to this link.
  • Meshes Tab
    • Scale: Use this field to override object scale.
    • Rotation Angles: Use this field to override object rotation angles.
    • Generate Mesh Colliders: Turn on this field to enable mesh collider generation (only valid for skinned meshes).
    • Convex Mesh Colliders: Turn on this field to indicate that generated mesh colliders will be convex.
  • Materials Tab
    • Dont Load Materials: Turn on this field to disable animations loading.
    • Textures Path Override: Use this field to override the object textures searching path.
    • Materials Override: Use this field to override materials with your own. If this array is not empty, each mesh material will be replaced by the material with the same index from this array.
  • Animations Tab
    • Dont Load Animations: Turn on this field to disable animations loading.
    • Auto Play Animations: Turn on this field to automatically play the first loaded animation (only for legacy animations).
    • Animation Wrap Mode: Use this field to change default animations wrap mode.
    • Use Legacy Animations: Turn on this field to use legacy Unity Animation component.
    • Animator Controller: If you don´t wish to use legacy animations, use this field to specify a Unity Animation Controller.

If your options are okay, you can simply drag your created prefab to the scene, or instantiate it via code later.

TriLib – Accepted File Formats

Here are the formats TriLib currently accepts:

Format Support ParTial Support
3D
3DS
3MF
AC
AMF  
ASE
ASSBIN
ASSXML
B3D
BLEND
BSP (Q3D)
BVH
COB
CSM
DAE
DXF
FBX
GLTF
HMP
IFC (*)
IRR
IRRMESH
LWO
LWS
MD2
MD3
MD5
MDC
MDL
MS3D
NDO
NFF
OBJ
OFF
OGEX
PLY
Q3D
Q3S
RAW
SCN
SIB
SMD
STL
TER
VTA
X
X3D
XGL
XML
ZGL

Note: TriLib is based on Assimp (http://www.assimp.org), an open-source project. We are always updating TriLib with the latest Assimp branch, to guarantee the most recent bug-fixes. We cannot guarantee your model to partially or fully load with TriLib.  (*) not supported on Android platform at the moment.