Commit d950e0e6 authored by Dario Seyb's avatar Dario Seyb

drawing edges and vertices

parent 9e7cbedf
......@@ -2,13 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3acaa99c354f4c428437d5d06b2aa8ec",
"model_id": "acf4a18369ac43e4b888569f36146bdf",
"version_major": 2,
"version_minor": 0
},
......@@ -28,13 +28,25 @@
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', colorWrite=False, emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'#000000'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'red', map=None, size=3.0, sizeAttenuation=False), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
......@@ -47,7 +59,15 @@
"m = om.TriMesh()\n",
"om.read_mesh(m, \"C:\\Users\\dario\\OneDrive\\Dokumente\\ANIMVR\\Import\\Models\\Mickey_Mouse.obj\")\n",
"\n",
"meshvis.display_openmesh(m)"
"ctx = meshvis.Context()\n",
"\n",
"ctx.draw_faces(m.points(), m.face_indices(), hidden=True)\n",
"\n",
"ctx.draw_edges(m.points(), m.face_indices())\n",
"\n",
"ctx.draw_vertices(m.points(), point_size=3, colors='red')\n",
"\n",
"ctx.display()"
]
},
{
......@@ -58,7 +78,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6db548fc9bd84bb6bc5169fbdd766cdd",
"model_id": "5460164864a84b4eaa05121ba21e88ac",
"version_major": 2,
"version_minor": 0
},
......@@ -78,13 +98,10 @@
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([0, 1, 2, 3], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[0., 0., 0.],\n",
" [1., 0., 0.],\n",
" [1., 1., 0.],\n",
" [0., 1., 0.]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'#000000', polygonOffset=True, polygonOffsetFactor=0.001, polygonOffsetUnits=0.1), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
......@@ -92,8 +109,7 @@
}
],
"source": [
"\n",
"meshvis.display_file(\"C:\\Users\\dario\\OneDrive\\Dokumente\\ANIMVR\\Import\\Models\\Mickey_Mouse.obj\")"
"meshvis.display_edges([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1], [2,3]])"
]
},
{
......@@ -104,7 +120,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4d889d4c33c14eb290588bf16c10d420",
"model_id": "75b7d67e17b0427484fc4782fd2fa298",
"version_major": 2,
"version_minor": 0
},
......@@ -124,11 +140,8 @@
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Line(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([0, 1, 1, 2, 2, 3, 3, 4], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[0, 0, 0],\n",
" [1, 0, 0],\n",
" [1, 1, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 0]]), normalized=False)}), material=LineBasicMaterial(color=u'#000000'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([1., 1., 0.], dtype=float32)), 'position': BufferAttribute(array=array([[0., 0., 0.],\n",
" [1., 1., 1.]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'#dddddd', map=None, size=10.0, sizeAttenuation=False, vertexColors='VertexColors'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
......@@ -136,47 +149,15 @@
}
],
"source": [
"meshvis.display_edges([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]], [0, 1, 1, 2, 2, 3, 3, 4])"
"meshvis.display_vertices([[0,0,0],[1,1,1]], [1,1,0], point_size=10)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3cbaba1f3dd04fc78844679a28aa85d4",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Renderer</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=Geometry(colors=[u'#ffffff'], vertices=[[0, 0, 0], [1, 1, 1]]), material=PointsMaterial(color=u'#000000', map=None, sizeAttenuation=False), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"meshvis.display_vertices([[0,0,0],[1,1,1]])"
]
"outputs": [],
"source": []
}
],
"metadata": {
......
......@@ -2,13 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3acaa99c354f4c428437d5d06b2aa8ec",
"model_id": "acf4a18369ac43e4b888569f36146bdf",
"version_major": 2,
"version_minor": 0
},
......@@ -28,13 +28,25 @@
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', colorWrite=False, emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'#000000'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=BufferGeometry(attributes={'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'red', map=None, size=3.0, sizeAttenuation=False), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
......@@ -47,7 +59,15 @@
"m = om.TriMesh()\n",
"om.read_mesh(m, \"C:\\Users\\dario\\OneDrive\\Dokumente\\ANIMVR\\Import\\Models\\Mickey_Mouse.obj\")\n",
"\n",
"meshvis.display_openmesh(m)"
"ctx = meshvis.Context()\n",
"\n",
"ctx.draw_faces(m.points(), m.face_indices(), hidden=True)\n",
"\n",
"ctx.draw_edges(m.points(), m.face_indices())\n",
"\n",
"ctx.draw_vertices(m.points(), point_size=3, colors='red')\n",
"\n",
"ctx.display()"
]
},
{
......@@ -58,7 +78,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6db548fc9bd84bb6bc5169fbdd766cdd",
"model_id": "5460164864a84b4eaa05121ba21e88ac",
"version_major": 2,
"version_minor": 0
},
......@@ -78,13 +98,10 @@
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 3439, 3436, 3440], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.34671 , 2.856239, -0.160498],\n",
" ...,\n",
" [-0.675122, 1.403736, -0.094798],\n",
" [-0.700144, 1.367866, -0.036312],\n",
" [-0.708084, 1.391306, -0.0961 ]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'#dddddd', emissiveMap=None, envMap=None, lightMap=None, map=None, specularMap=None), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([0, 1, 2, 3], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[0., 0., 0.],\n",
" [1., 0., 0.],\n",
" [1., 1., 0.],\n",
" [0., 1., 0.]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'#000000', polygonOffset=True, polygonOffsetFactor=0.001, polygonOffsetUnits=0.1), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
......@@ -92,8 +109,7 @@
}
],
"source": [
"\n",
"meshvis.display_file(\"C:\\Users\\dario\\OneDrive\\Dokumente\\ANIMVR\\Import\\Models\\Mickey_Mouse.obj\")"
"meshvis.display_edges([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1], [2,3]])"
]
},
{
......@@ -104,7 +120,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4d889d4c33c14eb290588bf16c10d420",
"model_id": "75b7d67e17b0427484fc4782fd2fa298",
"version_major": 2,
"version_minor": 0
},
......@@ -124,11 +140,8 @@
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Line(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([0, 1, 1, 2, 2, 3, 3, 4], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[0, 0, 0],\n",
" [1, 0, 0],\n",
" [1, 1, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 0]]), normalized=False)}), material=LineBasicMaterial(color=u'#000000'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(background=u'#dddddd', children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([1., 1., 0.], dtype=float32)), 'position': BufferAttribute(array=array([[0., 0., 0.],\n",
" [1., 1., 1.]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'#dddddd', map=None, size=10.0, sizeAttenuation=False, vertexColors='VertexColors'), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
......@@ -136,47 +149,15 @@
}
],
"source": [
"meshvis.display_edges([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 0]], [0, 1, 1, 2, 2, 3, 3, 4])"
"meshvis.display_vertices([[0,0,0],[1,1,1]], [1,1,0], point_size=10)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e43485a399f14aca9bbc83276e26b7d7",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Renderer</code>.</p>\n",
"<p>\n",
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
" that the widgets JavaScript is still loading. If this message persists, it\n",
" likely means that the widgets JavaScript library is either not installed or\n",
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
" Widgets Documentation</a> for setup instructions.\n",
"</p>\n",
"<p>\n",
" If you're reading this message in another frontend (for example, a static\n",
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
" it may mean that your frontend doesn't currently support widgets.\n",
"</p>\n"
],
"text/plain": [
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(children=(DirectionalLight(intensity=0.5, position=(-3.0, 5.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=20.0, position=(3.0, 3.0, 3.0), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)))], scene=Scene(children=(AmbientLight(color=u'#dddddd', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Points(geometry=Geometry(colors=[u'red', u'green'], vertices=[[0, 0, 0], [1, 1, 1]]), material=PointsMaterial(color=u'#000000', map=None, size=20.0, sizeAttenuation=False), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"meshvis.display_vertices([[0,0,0],[1,1,1]], per_vertex_colors=['red','green'], point_size=20)"
]
"outputs": [],
"source": []
}
],
"metadata": {
......
......@@ -8,52 +8,85 @@ class Context(object):
children=[three.DirectionalLight(color='#ffffff', position=[-3, 5, 1], intensity=0.5)])
self.scene = three.Scene(children=[three.AmbientLight(color='#dddddd')])
self.scene.background = '#dddddd'
self.orbit_controls = three.OrbitControls(controlling=self.camera)
self.renderer = three.Renderer(camera=self.camera, background='black', background_opacity=1,
scene=self.scene, controls=[self.orbit_controls],
width=600, height=400 )
def draw_faces(self, vertices, face_indices, normals=None, per_vertex_colors=None, per_face_colors=None, shading='flat', z_offset=0):
face_indices = np.asarray(face_indices, dtype='uint16').ravel()
def draw_faces(self, vertices, face_indices, normals=None, per_vertex_colors=None, per_face_colors=None,
hidden=False, shading='flat', z_offset=0.5):
mesh_geom = three.BufferGeometry(attributes=dict(
position = three.BufferAttribute(vertices, normalized=False),
index = three.BufferAttribute(face_indices, normalized=False),
position = three.BufferAttribute(np.asarray(vertices, dtype=np.float32), normalized=False),
index = three.BufferAttribute(np.asarray(face_indices, dtype='uint16').ravel(), normalized=False),
))
mesh_obj = three.Mesh(geometry=mesh_geom, material=three.MeshLambertMaterial(color='#dddddd'))
mat = three.MeshLambertMaterial(color='#dddddd', colorWrite=not hidden)
if z_offset is not 0:
mat.polygonOffset = True
mat.polygonOffsetFactor = z_offset
mat.polygonOffsetUnits = 0.1
mesh_obj = three.Mesh(geometry=mesh_geom, material=mat)
self.scene.add(mesh_obj)
return self
def draw_edges(self, vertices, edge_indices=None, per_vertex_colors=None, per_edge_colors=None, z_offset=1e-3):
def draw_edges(self, vertices, edge_indices=None, per_vertex_colors=None, per_edge_colors=None, z_offset=0):
if edge_indices is None:
edge_indices = np.arange(0, len(vertices)-1)
edge_indices = zip(np.arange(0, len(vertices)-1), np.arange(1, len(vertices)))
attributes=dict(
position = three.BufferAttribute(np.asarray(vertices, dtype=np.float32), normalized=False),
index = three.BufferAttribute(np.asarray(edge_indices, dtype=np.uint16).ravel(), normalized=False),
)
edge_indices = np.asarray(edge_indices, dtype='uint16')
mat = three.LineBasicMaterial(color='#000000')
geom = three.BufferGeometry(attributes=dict(
position = three.BufferAttribute(vertices, normalized=False),
index = three.BufferAttribute(edge_indices, normalized=False),
))
if z_offset is not 0:
mat.polygonOffset = True
mat.polygonOffsetFactor = z_offset
mat.polygonOffsetUnits = 0.1
material = three.LineBasicMaterial(color='#000000')
geom = three.BufferGeometry(attributes = attributes)
mesh_obj = three.Line(geometry=geom, material=material)
mesh_obj = three.LineSegments(geometry=geom, material=mat)
self.scene.add(mesh_obj)
return self
def draw_vertices(self, vertices, per_vertex_colors=None, point_size=1, z_offset=0):
geometry = three.Geometry(vertices=vertices)
if per_vertex_colors is not None:
geometry.colors = per_vertex_colors
def draw_vertices(self, vertices, colors=None, point_size=1, z_offset=0, perspective=False):
material = three.PointsMaterial(color='#000000', sizeAttenuation=False, size=point_size)
matColor = colors
if colors is None:
matColor = 'black'
elif hasattr(colors, '__len__') and (not isinstance(colors, str)):
matColor = '#dddddd'
else:
colors = None
attributes = dict(
position = three.BufferAttribute(np.asarray(vertices, dtype=np.float32), normalized=False),
)
mat = three.PointsMaterial(color=matColor, sizeAttenuation=perspective, size=point_size)
if z_offset is not 0:
mat.polygonOffset = True
mat.polygonOffsetFactor = z_offset
mat.polygonOffsetUnits = 0.1
if colors is not None:
attributes['color'] = three.BufferAttribute(np.asarray(colors, dtype=np.float32))
mat.vertexColors = 'VertexColors'
mesh_obj = three.Points(geometry=geometry, material=material)
geom = three.BufferGeometry(attributes=attributes)
mesh_obj = three.Points(geometry=geom, material=mat)
self.scene.add(mesh_obj)
return self
......
......@@ -6,5 +6,5 @@ def display_faces(vertices, face_indices, normals=None, per_vertex_colors=None,
def display_edges(vertices, edge_indices=None, per_vertex_colors=None, per_edge_colors=None, z_offset=1e-3):
Context().draw_edges(vertices, edge_indices, per_vertex_colors, per_edge_colors, z_offset).display()
def display_vertices(vertices, per_vertex_colors=None, point_size=1, z_offset=0):
Context().draw_vertices(vertices, per_vertex_colors, point_size, z_offset).display()
def display_vertices(vertices, colors=None, point_size=1, z_offset=0):
Context().draw_vertices(vertices, colors, point_size, z_offset).display()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment