Skip to content

Commit

Permalink
feat: finalizing stateful meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Mar 14, 2024
1 parent 5e97ebf commit f8fe8c1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 40 deletions.
25 changes: 20 additions & 5 deletions API/oursin/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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]
)
Expand Down
34 changes: 0 additions & 34 deletions API/tests/test_schemas.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f8fe8c1

Please sign in to comment.