diff --git a/API/oursin/meshes.py b/API/oursin/meshes.py index e36f0f81..4fc86396 100644 --- a/API/oursin/meshes.py +++ b/API/oursin/meshes.py @@ -18,7 +18,7 @@ class Mesh: """Mesh Object in Unity """ - def __init__(self,position= [0.0,0.0,0.0], scale= [1,1,1], color=[1,1,1], + def __init__(self, position= [0.0,0.0,0.0], scale= [1,1,1], color=[1,1,1], material = 'default', interactive = False): """Create a mesh object @@ -47,6 +47,8 @@ def __init__(self,position= [0.0,0.0,0.0], scale= [1,1,1], color=[1,1,1], interactive = interactive ) + counter += 1 + self._update() self.in_unity = True @@ -159,20 +161,33 @@ def set_material(self, material): #actually initializes each object(s), doesn't use any parameters other than how many to initialize (uses all defaults) -def create(num_objects): +def create(num_objects, position= [0.0,0.0,0.0], scale= [1,1,1], color=[1,1,1], + material = 'default', interactive = False): """Create multiple meshes Parameters ---------- num_objects : int - number of mesh objects to be created + number of mesh objects to be created + position : list, optional + default position nullspace (ap, ml, dv), by default [0.0,0.0,0.0] + scale : list, optional + default scale, by default [1,1,1] + color : list, optional + default color, by default [1,1,1] + material : str, optional + default material, by default 'default' + interactive : bool, optional + default interactive state, by default False + Examples -------- >>> meshes = urchin.meshes.create(2) """ mesh_objects = [] for i in range(num_objects): - mesh_objects.append(Mesh()) + mesh_objects.append(Mesh(position=position, color=color, scale=scale, + material=material, interactive=interactive)) return(mesh_objects) def delete(meshes_list): @@ -261,7 +276,7 @@ def set_colors(meshes_list, colors_list): meshes_list = utils.sanitize_list(meshes_list) colors_list = utils.sanitize_list(colors_list) - data = vbl_aquarium.generic.IDListVector3List( + data = vbl_aquarium.generic.IDListColorList( ids = [x.data.id for x in meshes_list], values = [utils.formatted_color(utils.sanitize_vector3(x)) for x in colors_list] ) diff --git a/API/tests/test_schemas.py b/API/tests/test_schemas.py deleted file mode 100644 index e60092b6..00000000 --- a/API/tests/test_schemas.py +++ /dev/null @@ -1,34 +0,0 @@ -import oursin as urchin -import pytest -import jsonschema -import json -import requests - -from unittest.mock import patch - -classes = ['AreaGroupData','CameraModel','CustomAtlasModel', - 'CustomMeshData','CustomMeshModel','MeshModel','ParticleGroupModel'] -raw_url = 'https://github.com/VirtualBrainLab/vbl-json-schema/raw/main/src/vbl_json_schema/schemas/urchin/' - -def load_schema(idx): - url = f'{raw_url}{classes[idx]}.json' - response = requests.get(url) - return json.loads(response.text) - -def test_mesh(): - schema = load_schema(5) - with patch.object(urchin.client.sio, 'emit') as mock_emit: - mesh = urchin.meshes.Mesh() - - mesh.set_scale([1,1,1]) - - call = mock_emit.call_args - - msg = call.args[0] - data = call.args[1] - print(data) - - try: - jsonschema.validate(data, schema) - except jsonschema.exceptions.ValidationError as e: - pytest.fail() \ No newline at end of file diff --git a/UnityClient/Packages/vbl.urchin/Scripts/Behaviors/MeshBehavior.cs b/UnityClient/Packages/vbl.urchin/Scripts/Behaviors/MeshBehavior.cs index 9a81a00b..c0f7d5c5 100644 --- a/UnityClient/Packages/vbl.urchin/Scripts/Behaviors/MeshBehavior.cs +++ b/UnityClient/Packages/vbl.urchin/Scripts/Behaviors/MeshBehavior.cs @@ -61,7 +61,8 @@ public void SetPosition(Vector3 coordAtlasU) private void _SetPosition() { - transform.localPosition = BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(Data.position); + // Set position expects coordinates in raw AP/ML/DV coordinates, not reference + transform.localPosition = BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(Data.position, false); } public void SetScale(Vector3 scale) diff --git a/UnityClient/Packages/vbl.urchin/Scripts/Managers/AtlasManager.cs b/UnityClient/Packages/vbl.urchin/Scripts/Managers/AtlasManager.cs index faf2142a..82bda45d 100644 --- a/UnityClient/Packages/vbl.urchin/Scripts/Managers/AtlasManager.cs +++ b/UnityClient/Packages/vbl.urchin/Scripts/Managers/AtlasManager.cs @@ -95,6 +95,9 @@ public async void LoadAtlas(string atlasName) await atlasTask; BrainAtlasManager.SetReferenceCoord(Utils.Utils.BregmaDefaults[BrainAtlasManager.ActiveReferenceAtlas.Name]); +#if UNITY_EDITOR + Debug.Log($"Reference coordinate set to {Utils.Utils.BregmaDefaults[BrainAtlasManager.ActiveReferenceAtlas.Name]}"); +#endif } //public void CustomAtlas(CustomAtlasData data)