-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
233 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Custom 3D Objects""" | ||
|
||
from . import client | ||
from . import utils | ||
import json | ||
|
||
count = 0 | ||
|
||
class CustomMesh: | ||
"""Custom 3D object | ||
""" | ||
|
||
def __init__(self, vertices, triangles, normals = None): | ||
"""Create a Custom 3D object based on a set of vertices and triangle faces | ||
Parameters | ||
---------- | ||
vertices : list of vector3 | ||
Vertex coordinates | ||
triangles : list of vector3 | ||
Triangle vertices | ||
normals : list of vector3, optional | ||
Normal directions, by default None | ||
""" | ||
global count | ||
|
||
self.id = str(count) | ||
count += 1 | ||
|
||
data = {} | ||
data['ID'] = self.id | ||
data['vertices'] = vertices | ||
data['triangles'] = triangles | ||
|
||
if not normals is None: | ||
data['normals'] = normals | ||
|
||
client.sio.emit('CustomMeshCreate', json.dumps(data)) | ||
|
||
self.in_unity = True | ||
|
||
def delete(self): | ||
"""Destroy this object in the renderer scene | ||
""" | ||
client.sio.emit('CustomMeshDelete', self.id) | ||
self.in_unity = False | ||
|
||
def set_position(self, position = [0,0,0], use_reference = True): | ||
"""Set the position relative to the reference coordinate | ||
Parameters | ||
---------- | ||
position : vector3 | ||
AP/ML/DV coordinate relative to the reference (defaults to [0,0,0] when unset) | ||
use_reference : bool, optional | ||
whether to use the reference coordinate, by default True | ||
""" | ||
position = utils.sanitize_vector3(position) | ||
|
||
data = {} | ||
data['ID'] = self.id | ||
data['Position'] = position | ||
data['UseReference'] = use_reference | ||
|
||
client.sio.emit('CustomMeshPosition', json.dumps(data)) | ||
|
||
def clear(): | ||
"""Clear all custom meshes | ||
""" | ||
client.sio.emit('Clear','custommesh') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
UnityClient/Packages/vbl.urchin/Scripts/JSON/CustomMesh/CustomMeshData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using UnityEngine; | ||
|
||
public struct CustomMeshData | ||
{ | ||
public string ID; | ||
public Vector3[] vertices; | ||
public Vector3Int[] triangles; | ||
public Vector3[] normals; | ||
} |
11 changes: 11 additions & 0 deletions
11
UnityClient/Packages/vbl.urchin/Scripts/JSON/CustomMesh/CustomMeshData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
UnityClient/Packages/vbl.urchin/Scripts/JSON/CustomMesh/CustomMeshDestroy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
public struct CustomMeshDestroy | ||
{ | ||
public string ID; | ||
} |
11 changes: 11 additions & 0 deletions
11
UnityClient/Packages/vbl.urchin/Scripts/JSON/CustomMesh/CustomMeshDestroy.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
UnityClient/Packages/vbl.urchin/Scripts/JSON/CustomMesh/CustomMeshPosition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using UnityEngine; | ||
|
||
public struct CustomMeshPosition | ||
{ | ||
public string ID; | ||
public Vector3 Position; | ||
public bool UseReference; | ||
} |
11 changes: 11 additions & 0 deletions
11
UnityClient/Packages/vbl.urchin/Scripts/JSON/CustomMesh/CustomMeshPosition.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 72 additions & 4 deletions
76
UnityClient/Packages/vbl.urchin/Scripts/Managers/CustomMeshManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters