Skip to content

Commit f971e23

Browse files
authored
[src] Add simple binding, methods and unity scene to test connexion with SofaVerseAPI without creating SofaContext (#256)
* backup work on connexion test * Update names and add test scene
1 parent 25c6647 commit f971e23

5 files changed

Lines changed: 485 additions & 0 deletions

File tree

Core/Plugins/SofaUnityAPI/SofaContextAPI.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66

77
namespace SofaUnityAPI
88
{
9+
public class SofaVerseAPI_ConnexionTest
10+
{
11+
public int testSofaVerseAPI_connexion()
12+
{
13+
int res = test_getAPI_ID();
14+
Debug.Log("SofaContextAPI::testConnection method returns: " + res);
15+
return res;
16+
}
17+
18+
[DllImport("SofaVerseAPI", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
19+
public static extern int test_getAPI_ID();
20+
}
21+
22+
23+
24+
925
/// <summary>
1026
/// Main class of the Sofa plugin. This class handle all bindings to manage the Sofa simulation scene.
1127
/// It will connect to the SofaPhysicsAPI. Get the list of object or start/stop the simulation.
@@ -577,6 +593,9 @@ public void SofaKeyReleaseEvent(int keyId)
577593
/////////////////////////////////////////////////////////////////////////////////////////
578594
////////// API to Communication with SofaAdvancePhysicsAPI /////////////
579595
/////////////////////////////////////////////////////////////////////////////////////////
596+
[DllImport("SofaVerseAPI", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
597+
public static extern int test_getAPI_ID();
598+
580599

581600
/// Bindings to the SofaAdvancePhysicsAPI creation/destruction methods
582601
[DllImport("SofaVerseAPI")]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using UnityEngine;
2+
using SofaUnityAPI;
3+
4+
public class SofaLibConnexionCheck : MonoBehaviour
5+
{
6+
// Start is called once before the first execution of Update after the MonoBehaviour is created
7+
void Start()
8+
{
9+
SofaVerseAPI_ConnexionTest test = new SofaVerseAPI_ConnexionTest();
10+
int res = test.testSofaVerseAPI_connexion();
11+
12+
if (res == 666)
13+
{
14+
Debug.Log("SofaVerse API connexion test: SUCCESS");
15+
}
16+
else
17+
{
18+
Debug.LogError("SofaVerse API connexion test: FAILED");
19+
}
20+
}
21+
22+
// Update is called once per frame
23+
void Update()
24+
{
25+
26+
}
27+
}

Core/Scripts/Utils/SofaLibConnexionCheck.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)