SOFA Object creation
The SOFA object creation API is still under development. It allows you to add objects from Unity to a loaded SOFA scene. The first step in this process is to create a SofaContext
GameObject, which serves as the root of the simulation.
Once the SofaContext
is set up, you can create various SOFA objects through the Unity UI Hierarchy panel. This approach provides a higher-level API that automates the creation of SOFA DAGNodes and components necessary for the objects.
The types of objects you can create include:
- Primitive Objects: Simple shapes like cubes, cylinders, and planes that can be added to the simulation.
- Specific SOFA Objects: These are specialized objects used in SOFA, such as collision objects, which are essential for simulating physical interactions within the scene.
Primitive Object
It is possible to create several types of geometry directly as GameObjects in Unity3D using the interface.
Here is the list of primitive Object:
- SofaSphere / SofaRigidSphere :
- SofaSphere / SofaRigidSphere:
- SofaSphere / SofaRigidSphere:
- SofaSphere / SofaRigidSphere:
- 3D Sphere, available in Rigid or Deformable mode.
- 3D Box, available in Rigid or Deformable mode.
- 3D Cylinder, available in Rigid or Deformable mode.
- 2D Plane, available only in Rigid or Deformable mode.
Rigid mode means the object will be simulated in the scene and will collide but won’t move or deform.
Whereas the deformable objects will collide and are modelized using Tetrahedral Finite Element Method. It is thus possible to set their mass, resolution and FEM parameters.
They can be placed and transformed in 3D using internal parameters and not the unity Transform values.
The creation of a SofaPrimitiveObject will result into the creation of SofaDAGNode owning all the SOFA components needed for the simulation of such 3D object. Like the mesh, the mass, FEM and Collision models. But it will also add a Solver to that node. Finally a second SofaDAGNode will be created to add a SofaVisualModel to render the 3D object.
SofaObject Creation
In addition to the SofaPrimitiveObject, some specific objects will be provided. For the moment this section is very limited.
The first noticeable object is the possibility to create a sphere collision model on top of Unity3D objects.
The SofaSphereCollisionModel will create spheres that can be seen as gizmos on the Unity side which are mapped to collision sphere inside the Sofa simulation scene.
The demo scene Tissue_fall is an example of that feature.
Several parameters can be set:
- Interpolation factor: a factor to compute the number of sphere to create on the given geometry.
- Sphere radius: radius of the collision spheres.
- Activate collision: collide or not with the other objects.
- Contact stiffness: the force of the repulsion used by the collision sphere.