This repository is a Unity3D package allowing to render a SOFA simulation scene inside Unity3D.
All SOFA VisualModel components present in the loaded simulation will be rendered inside Unity3D engine as GameObject with a MeshFilter. Thus, it is possible to apply Unity3D Materials to each visual model and also to combine Unity3D assets with the SOFA simulation.
| Important: This version allows only to change the Gravity and the TimeStep of the SOFA simulation and only the VisualModel are mapped into Unity3D. A full integration of SOFA components with a two-way communication can be requested here: https://infinytech3d.com/sapapi-unity3d/ |
- Unity version > 2020.3.x (Tested with LTS: 2020.3.17 and 2021.3.19)
- SOFA version > 22.12 with SofaPhysicsAPI activated (Tested with SOFA releases 22.12 and 23.06)
- Only tested on Windows for now
- Install Unity engine version > 2020.3.x
- (optionnal) Create a new project
- Download the unity asset provided in the release page: Here for the SofaUnity-Renderer_v22.12_Win64 and here for the SofaUnity-Renderer_v23.06_Win64
- Load the unity asset inside Unity3D Editor, use
Assets -> Import Package -> Custom Packageand load the corresponding packageSofaUnity-Renderer_vXX.XX_Win64.unitypackage
- Clone this repository inside your unity project:
git clone git@github.com:InfinyTech3D/SofaUnity-Renderer.git /myUnityProject/Assets/SofaUnity - Download the SOFA release v22.12 or v23.06, either using the installer or the zip file
- Copy the SOFA .dll from the folder
/SOFA_vXX.XX.00_Win64\bin\inside:/myUnityProject/Assets/SofaUnity/Plugins/Native/x64(for windows) |/myUnityProject/Assets/SofaUnity/Plugins/Native/x86_64(for linux)
As soon as the SofaUnity-Renderer.unitypackage is loaded inside your Unity project, you will have access to a top menu panel called SofaUnity.
This pannel allows to load a SOFA scene in only 2 steps:
- Click on SofaContext to add a
GameObjectinto your unity scene graph with aSofaContext component. This component correspond to the SOFA world 3D frame and provides a simple API to load a SOFA scene, change the Time Stepping and the Gravity.
- Click on the button
Load SOFA Scene (.scn) fileto load a SOFA scene. This will create aGameObjectwith aUnity MeshFilterfor each SOFAVisualModel
SOFA simulation will be performed as soon as Unity is playing.
Three examples corresponding to SOFA Demo folder are provided inside the package: They are available in the folder /Scenes/Demos/
- Demo_01_SimpleLiver -> Integration of Demos/liver.scn
- Demo_02_Caduceus -> Integration of Demos/caduceus.scn
- Demo_03_Tissue -> Integration of Demos/TriangleSurfaceCutting.scn
Here are a some results of the integration:
Here is a set of Youtube tutorials. Whether you're just starting out or an experienced developer, our step-by-step guides offer valuable insights into leveraging SofaUnity-Renderer.
- Tutorial 01: How to Install SofaUnity-Renderer
- Tutorial 02: How to install from source code and use custom SOFA version
- Tutorial 03: Importing a SOFA scene in your Unity project
This Unity asset is under GPL license.
Other license formats can be provided for commercial use. For more information check InfinyTech3D license page.





