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:
Run CMake in the root folder, open the solution in Visual Studio and build the target
__libigl-interfaceOr setup the CMake project in CLion and build, (ensure that the architecture is correct, e.g.
x64oramd64, in the Toolchain settings or you may have errors that the dll was not found).
Open the project in Unity.
Open the
Mainscene from the Project window.Reimport the
Assets/Models/EditableMeshesfolder using the Right-Click menu.You may also have to reimport the
Mainscene andModels/Environment Variantprefab, if you are getting errors.
(Optional) Go to the lighting window
Window>Rendering>Lighting Settingand pressGenerate Lightingat the bottom.
Press play in Unity and it should work.
2.1.2. Building¶
2.1.2.1. CMake Targets¶
__libigl-interface- this is the main C++ dllstubLluiPlugin- a tiny C++ dll used by the UnityNativeTool (you can leave this alone)Doxygenoptional - builds doxygen html and xml output into<cmake-build-dir>/docs/doxygenSphinxoptional - builds entire documentation (incl. doxygen)ZERO_CHECKVisual Studio only - re-runs CMakeALL_BUILDVisual Studio only - builds all targets
2.1.2.2. Producing an Executable¶
Compile the C++
__libigl-interfacedll in release mode.Crl+Shift+Bin Unity to open the build settings.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.
Install the IL2CPP module from the Unity Hub (for this version of Unity).
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
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
Install Doxygen
Install Sphinx, run
pip install -r docs/requirements.txtfrom the root directory in a terminal (cmd on windows)You might have to restart for Sphinx to be found
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.htmlSphinx: Creates the documentation as hosted on ReadTheDocs, using parts from the Doxygen xml output. View locally at
<cmake build folder>/docs/sphinx/index.htmlor push to the master branch and then view online.
2.1.4. Project Structure¶
Important folders:
Assets- Unity related filesScripts- C# code for things like: UI, Input, Unity mesh interface, Threading, Importing modelsPrefabs- Pre-made components, mostly UIModels/EditableMeshes- The meshes that can be modified with libiglMaterials- Textures, icons and shaders
Interface- C++ project that interfaces with libigl: deformations, modifying meshes via Eigen matricessource- the C++ source code which calls libiglexternal- the C++ libraries
Packages- Local Unity packagesdocs- non-inline documentation and generation
Generated Folders: Library Temp by Unity, obj by VS