Commit 53ca907d authored by Dario Seyb's avatar Dario Seyb

added example image

parent 9c3d736b
......@@ -2,25 +2,87 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {
"scrolled": false
},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-1-76bf9396fe4c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[0mnormals\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'vertex'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mcolors\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmeshvis\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mUniformAttribute\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 12\u001b[1;33m shading = 'flat')\n\u001b[0m\u001b[0;32m 13\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 14\u001b[0m ctx.draw_edges(m.points(), m.ev_indices(), \n",
"\u001b[1;32mc:\\dev\\meshvis\\meshvis\\context.pyc\u001b[0m in \u001b[0;36mdraw_faces\u001b[1;34m(self, vertices, face_indices, normals, colors, uvs, shading, z_offset)\u001b[0m\n\u001b[0;32m 54\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 55\u001b[0m \u001b[1;31m# Resolve the given attributes, it's ok if they are None\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 56\u001b[1;33m \u001b[0mresolved_attribs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresolve_attributes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mface_indices\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mnormals\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcolors\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0muvs\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 57\u001b[0m \u001b[0mresolved_normals\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresolved_attribs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 58\u001b[0m \u001b[0mresolved_colors\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mresolved_attribs\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\dev\\meshvis\\meshvis\\indexed_attribute.pyc\u001b[0m in \u001b[0;36mresolve_attributes\u001b[1;34m(face_indices, attribs)\u001b[0m\n\u001b[0;32m 19\u001b[0m \u001b[1;32mcontinue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 21\u001b[1;33m \u001b[0mresolved_attrib\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mattrib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mresolve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mface_indices\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 22\u001b[0m \u001b[0mfinal_attributes\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstretch_attribute\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mface_indices\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mresolved_attrib\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 23\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\dev\\meshvis\\meshvis\\indexed_attribute.pyc\u001b[0m in \u001b[0;36mresolve\u001b[1;34m(self, face_indices)\u001b[0m\n\u001b[0;32m 70\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mf_idx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mface\u001b[0m \u001b[1;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mface_indices\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 71\u001b[0m \u001b[1;31m# check if vertex is in face\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 72\u001b[1;33m \u001b[0midx_in_face\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfind\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0midx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mface\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 73\u001b[0m \u001b[1;31m# if yes, add value for vertex in that face\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 74\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0midx_in_face\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mc:\\dev\\meshvis\\meshvis\\indexed_attribute.pyc\u001b[0m in \u001b[0;36mfind\u001b[1;34m(element, list_element)\u001b[0m\n\u001b[0;32m 35\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mfind\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0melement\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlist_element\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 36\u001b[0m \u001b[0mindex_element\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwhere\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlist_element\u001b[0m\u001b[1;33m==\u001b[0m\u001b[0melement\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 37\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindex_element\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mindex_element\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 38\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 39\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "91d57b1f16a144659c45e17cc4163f4a",
"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(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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)), Mesh(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.11732402, 0.6847934 , 0.6164344 ],\n",
" [0.11732402, 0.6847934 , 0.6164344 ],\n",
" [0.11732402, 0.6847934 , 0.6164344 ],\n",
" ...,\n",
" [0.9562925 , 0.08487827, 0.7201913 ],\n",
" [0.9562925 , 0.08487827, 0.7201913 ],\n",
" [0.9562925 , 0.08487827, 0.7201913 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.20979331, 0.07998422, -0.9744687 ],\n",
" [ 0.20979331, 0.07998422, -0.9744687 ],\n",
" [ 0.20979331, 0.07998422, -0.9744687 ],\n",
" ...,\n",
" [-0.13065 , 0.8949016 , -0.4267104 ],\n",
" [-0.13065 , 0.8949016 , -0.4267104 ],\n",
" [-0.13065 , 0.8949016 , -0.4267104 ]], dtype=float32)), '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.280426, 0.4863 , -0.003152],\n",
" [ 0.332014, 0.467158, -0.059092],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None, 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)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.41086063, 0.10705473, 0.8429296 ],\n",
" [0.41086063, 0.10705473, 0.8429296 ],\n",
" [0.25787306, 0.22192806, 0.9668249 ],\n",
" ...,\n",
" [0.19065575, 0.32614255, 0.4982505 ],\n",
" [0.67401946, 0.3399039 , 0.20301984],\n",
" [0.67401946, 0.3399039 , 0.20301984]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" ...,\n",
" [ 0.157628, 0.430178, -0.130118],\n",
" [ 0.216602, 0.471758, -0.014108],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.11732402, 0.6847934 , 0.6164344 ],\n",
" [0.11732402, 0.6847934 , 0.6164344 ],\n",
" [0.534379 , 0.6637605 , 0.7090333 ],\n",
" ...,\n",
" [0.3699593 , 0.6580512 , 0.21494888],\n",
" [0.9562925 , 0.08487827, 0.7201913 ],\n",
" [0.9562925 , 0.08487827, 0.7201913 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 13637, 13638, 13639], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.286356 , 2.8809676 , -0.14547466],\n",
" [-0.26537666, 2.888966 , -0.24292153],\n",
" [-0.295662 , 2.8398848 , -0.15085067],\n",
" ...,\n",
" [ 0.2812651 , 0.5552246 , -0.09855373],\n",
" [ 0.27634734, 0.475072 , -0.02545067],\n",
" [ 0.26328233, 0.56456214, -0.06812171]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', 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)), 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=4.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": [
......@@ -32,21 +94,23 @@
"\n",
"ctx = meshvis.Context(width=640, height=480)\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculateFaceNormals(m.points(), m.face_vertex_indices())\n",
"ctx.draw_faces(m.points(), m.face_vertex_indices(), \n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
" colors = meshvis.UniformAttribute([0, 0, 1]),\n",
" colors = colors,\n",
" shading = 'flat')\n",
"\n",
"ctx.draw_edges(m.points(), m.ev_indices(), \n",
" colors = meshvis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),\n",
" linewidth=3)\n",
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(m.points(), m.face_vertex_indices(), normals, 0.1)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(m.points(), m.face_vertex_indices(), normals, 0.05)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges, colors = colors)\n",
"\n",
"ctx.draw_vertices(m.points(), point_size=4, colors='red')\n",
"\n",
......
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {
"scrolled": false
},
......@@ -10,7 +10,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "40e1183488374653b59b2f649157dc05",
"model_id": "1558a7bf2c4f471cac251088180c3b17",
"version_major": 2,
"version_minor": 0
},
......@@ -30,13 +30,13 @@
"</p>\n"
],
"text/plain": [
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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)), Mesh(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0., 0., 1.],\n",
" [0., 0., 1.],\n",
" [0., 0., 1.],\n",
"Renderer(background='#dddddd', camera=PerspectiveCamera(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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'#aaaaaa', quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), PerspectiveCamera(aspect=1.3333333333333333, children=(DirectionalLight(position=(-30.0, 50.0, 10.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)), Mesh(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.4963839 , 0.88896775, 0.7816435 ],\n",
" [0.4963839 , 0.88896775, 0.7816435 ],\n",
" [0.4963839 , 0.88896775, 0.7816435 ],\n",
" ...,\n",
" [0., 0., 1.],\n",
" [0., 0., 1.],\n",
" [0., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.20979331, 0.07998422, -0.9744687 ],\n",
" [0.5360408 , 0.36832646, 0.44506806],\n",
" [0.5360408 , 0.36832646, 0.44506806],\n",
" [0.5360408 , 0.36832646, 0.44506806]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20457, 20458, 20459], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[ 0.20979331, 0.07998422, -0.9744687 ],\n",
" [ 0.20979331, 0.07998422, -0.9744687 ],\n",
" [ 0.20979331, 0.07998422, -0.9744687 ],\n",
" ...,\n",
......@@ -48,25 +48,31 @@
" ...,\n",
" [ 0.280426, 0.4863 , -0.003152],\n",
" [ 0.332014, 0.467158, -0.059092],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None, 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)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.9325565 , 0.16986644, 0.6348343 ],\n",
" [0.9325565 , 0.16986644, 0.6348343 ],\n",
" [0.03978208, 0.81539804, 0.52545714],\n",
" [ 0.216602, 0.471758, -0.014108]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=None, polygonOffset=True, polygonOffsetFactor=0.5, polygonOffsetUnits=0.1, specularMap=None, 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)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.5837198 , 0.72584784, 0.22937745],\n",
" [0.5837198 , 0.72584784, 0.22937745],\n",
" [0.11128911, 0.5174707 , 0.7444728 ],\n",
" ...,\n",
" [0.5830377 , 0.16484123, 0.0814902 ],\n",
" [0.19853802, 0.6814414 , 0.01031223],\n",
" [0.19853802, 0.6814414 , 0.01031223]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [0.9277531 , 0.6908932 , 0.48642585],\n",
" [0.07398918, 0.08555599, 0.94079673],\n",
" [0.07398918, 0.08555599, 0.94079673]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 20569, 20570, 20571], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.283628, 2.931106, -0.140772],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" [-0.22873 , 2.855558, -0.135154],\n",
" ...,\n",
" [ 0.157628, 0.430178, -0.130118],\n",
" [ 0.216602, 0.471758, -0.014108],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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)), LineSegments(geometry=BufferGeometry(attributes={'index': BufferAttribute(array=array([ 0, 1, 2, ..., 13637, 13638, 13639], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.286356 , 2.8809676 , -0.14547466],\n",
" [-0.26537666, 2.888966 , -0.24292153],\n",
" [ 0.332014, 0.467158, -0.059092]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', linewidth=3.0, 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)), LineSegments(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.4963839 , 0.88896775, 0.7816435 ],\n",
" [0.4963839 , 0.88896775, 0.7816435 ],\n",
" [0.78466433, 0.00725824, 0.5387747 ],\n",
" ...,\n",
" [0.01393902, 0.95735204, 0.3766971 ],\n",
" [0.5360408 , 0.36832646, 0.44506806],\n",
" [0.5360408 , 0.36832646, 0.44506806]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 13637, 13638, 13639], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.286356 , 2.8809676 , -0.14547466],\n",
" [-0.27586633, 2.8849669 , -0.1941981 ],\n",
" [-0.295662 , 2.8398848 , -0.15085067],\n",
" ...,\n",
" [ 0.2812651 , 0.5552246 , -0.09855373],\n",
" [ 0.2855232 , 0.50796396, -0.0827962 ],\n",
" [ 0.27634734, 0.475072 , -0.02545067],\n",
" [ 0.26328233, 0.56456214, -0.06812171]], 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.26981482, 0.51981705, -0.04678619]], dtype=float32), normalized=False)}), material=LineBasicMaterial(color=u'white', 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)), 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",
......@@ -88,21 +94,23 @@
"\n",
"ctx = meshvis.Context(width=640, height=480)\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculateFaceNormals(m.points(), m.face_vertex_indices())\n",
"ctx.draw_faces(m.points(), m.face_vertex_indices(), \n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
" colors = meshvis.UniformAttribute([0, 0, 1]),\n",
" colors = colors,\n",
" shading = 'flat')\n",
"\n",
"ctx.draw_edges(m.points(), m.ev_indices(), \n",
" colors = meshvis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),\n",
" linewidth=3)\n",
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(m.points(), m.face_vertex_indices(), normals, 0.1)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(m.points(), m.face_vertex_indices(), normals, 0.05)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges, colors = colors)\n",
"\n",
"ctx.draw_vertices(m.points(), point_size=4, colors='red')\n",
"\n",
......
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