2.1. Setup

Required Tools: Unity 2019.3.2f1+, CMake, Visual Studio, ‘Desktop development with C++’ workload in the Visual Studio installer.

Recommended Tools (Optional): JetBrains CLion (preferably 2020.1+ so you can debug) and Rider for C++ and C# development respectively. This has the benefit that you can debug C# and C++ simultaneously, which is not currently possible with Visual Studio.

2.1.1. After Cloning

Checkout submodules: git submodule update --init

Setup the C++ interface to libigl with CMake:

  1. Run CMake in the root folder, open the solution in Visual Studio and build the target __libigl-interface

  2. Or setup the CMake project in CLion and build, (ensure that the architecture is correct, e.g. x64 or amd64, in the Toolchain settings or you may have errors that the dll was not found).

Open the project in Unity.

  1. Open the Main scene from the Project window.

  2. Reimport the Assets/Models/EditableMeshes folder using the Right-Click menu.

    1. You may also have to reimport the Main scene and Models/Environment Variant prefab, if you are getting errors.

  3. (Optional) Go to the lighting window Window > Rendering > Lighting Setting and press Generate Lighting at the bottom.

Press play in Unity and it should work.

2.1.2. Building

2.1.2.1. CMake Targets

  1. __libigl-interface - this is the main C++ dll

  2. stubLluiPlugin - a tiny C++ dll used by the UnityNativeTool (you can leave this alone)

  3. Doxygen optional - builds doxygen html and xml output into <cmake-build-dir>/docs/doxygen

  4. Sphinx optional - builds entire documentation (incl. doxygen)

  5. ZERO_CHECK Visual Studio only - re-runs CMake

  6. ALL_BUILD Visual Studio only - builds all targets

2.1.2.2. Producing an Executable

  1. Compile the C++ __libigl-interface dll in release mode.

  2. Crl + Shift + B in Unity to open the build settings.

  3. Ensure you are on the platform you want (Windows standalone 64-bit) and set Development mode accordingly, press build.

IL2CPP

This project also works with IL2CPP, which converts C# to C++ upon compile for potential performance gains. These builds are slower.

  1. Install the IL2CPP module from the Unity Hub (for this version of Unity).

  2. Go to the player settings (either from project settings or from the build window). Find the ‘Scripting Backend’ and set it to IL2CPP from Mono

  3. Build as usual

2.1.3. Generating Documentation

To regenerate this documentation as well as the Doxygen documentation follow these steps. Sphinx is not required for the Doxygen documentation. Optional

  1. Install Doxygen

  2. Install Sphinx, run pip install -r docs/requirements.txt from the root directory in a terminal (cmd on windows)

    • You might have to restart for Sphinx to be found

  3. Re-run CMake, this will create two new targets, build these like the library

    • Doxygen: Creates standard Doxygen html/xml files. View this at <cmake build folder>/docs/doxygen/index.html

    • Sphinx: Creates the documentation as hosted on ReadTheDocs, using parts from the Doxygen xml output. View locally at <cmake build folder>/docs/sphinx/index.html or push to the master branch and then view online.

2.1.4. Project Structure

Important folders:

  • Assets - Unity related files

  • Scripts - C# code for things like: UI, Input, Unity mesh interface, Threading, Importing models

    • Prefabs - Pre-made components, mostly UI

    • Models/EditableMeshes - The meshes that can be modified with libigl

    • Materials - Textures, icons and shaders

  • Interface - C++ project that interfaces with libigl: deformations, modifying meshes via Eigen matrices

    • source - the C++ source code which calls libigl

    • external - the C++ libraries

  • Packages - Local Unity packages

  • docs - non-inline documentation and generation

Generated Folders: Library Temp by Unity, obj by VS