Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
threevis
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
threevis
threevis
Commits
3aabfb0f
Commit
3aabfb0f
authored
Feb 02, 2018
by
Dario Seyb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added texture argument to faces API
parent
5456f285
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
2731 additions
and
51 deletions
+2731
-51
examples/.ipynb_checkpoints/Untitled-checkpoint.ipynb
examples/.ipynb_checkpoints/Untitled-checkpoint.ipynb
+106
-18
examples/Untitled.ipynb
examples/Untitled.ipynb
+76
-30
examples/models/uv_sphere.mtl
examples/models/uv_sphere.mtl
+10
-0
examples/models/uv_sphere.obj
examples/models/uv_sphere.obj
+2534
-0
examples/textures/checkerboard.png
examples/textures/checkerboard.png
+0
-0
meshvis/__init__.py
meshvis/__init__.py
+1
-0
meshvis/context.py
meshvis/context.py
+2
-1
meshvis/immediate.py
meshvis/immediate.py
+2
-2
No files found.
examples/.ipynb_checkpoints/Untitled-checkpoint.ipynb
View file @
3aabfb0f
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
18
,
"metadata": {
"scrolled": false
},
...
...
@@ -10,7 +10,36 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f00a5235179a4f5c8c71d99c795979ef",
"model_id": "cb7a80ba6f35401e9e25250af0ba1f11",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</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": [
"Preview(child=ImageTexture(imageUri=u'textures/checkerboard.png', repeat=(1.0, 1.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "07a4763e3e814270a7b66e93e0be51e5",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -30,13 +59,67 @@
"</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=(0.13295613955334604, 0.13295613955334604, 0.13295613955334604), 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=(0.13295613955334604, 0.13295613955334604, 0.13295613955334604), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016805611188265124, 0.10981325821101032, -0.0013969168554233066))], 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=(0.13295613955334604, 0.13295613955334604, 0.13295613955334604), 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.10657822, 0.1982002 , 0.21706074],\n",
" [0.10657822, 0.1982002 , 0.21706074],\n",
" [0.10657822, 0.1982002 , 0.21706074],\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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016805611188265124, 0.10981325821101032, -0.0013969168554233066)), Picker(controlling=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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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.29060814, 0.0531738 , 0.73882395],\n",
" [0.29060814, 0.0531738 , 0.73882395],\n",
" [0.29060814, 0.0531738 , 0.73882395],\n",
" ...,\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False), 'uv': BufferAttribute(array=array([[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]], dtype=float32)), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [-0.8924592 , -0.02002691, -0.45068336],\n",
" [-0.8525913 , -0.13340487, -0.50526357],\n",
" ...,\n",
" [0.1028768 , 0.68745416, 0.3252007 ],\n",
" [0.1028768 , 0.68745416, 0.3252007 ],\n",
" [0.1028768 , 0.68745416, 0.3252007 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [-0.69263035, -0.7083079 , 0.13624643],\n",
" [-0.2737271 , -0.8989508 , 0.34199542],\n",
" [-0.35207012, -0.91879463, 0.17850235]], dtype=float32)), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" [-0.08949102, 0.14392582, 0.01248849],\n",
" ...,\n",
" [-0.05290982, 0.05704307, 0.02098841],\n",
" [-0.05816759, 0.05998519, 0.02260606],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.41804713, 0.3630384 , 0.55066955],\n",
" [0.41804713, 0.3630384 , 0.55066955],\n",
" [0.3918132 , 0.5544737 , 0.18690161],\n",
" ...,\n",
" [0.78927505, 0.7185339 , 0.9068611 ],\n",
" [0.71406925, 0.7876062 , 0.39225307],\n",
" [0.71406925, 0.7876062 , 0.39225307]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" ...,\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ],\n",
" [-0.05290982, 0.05704307, 0.02098841],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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, ..., 29805, 29806, 29807], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [-0.09086571, 0.14312649, 0.00596796],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" ...,\n",
" [-0.05953623, 0.05549044, 0.02431604],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ],\n",
" [-0.05680015, 0.05271573, 0.01788341]], 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.00341018, 0.13031957, 0.02175437],\n",
" [-0.08171916, 0.15250145, 0.02965609],\n",
" [-0.03054348, 0.12477885, 0.00109834],\n",
" ...,\n",
" [-0.01389549, 0.16787168, -0.02189723],\n",
" [-0.069413 , 0.15121847, -0.04453854],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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)), event=u'dblclick', object=None)], 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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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.29060814, 0.0531738 , 0.73882395],\n",
" [0.29060814, 0.0531738 , 0.73882395],\n",
" [0.29060814, 0.0531738 , 0.73882395],\n",
" ...,\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False), 'uv': BufferAttribute(array=array([[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]], dtype=float32)), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [-0.8924592 , -0.02002691, -0.45068336],\n",
" [-0.8525913 , -0.13340487, -0.50526357],\n",
" ...,\n",
...
...
@@ -48,13 +131,13 @@
" ...,\n",
" [-0.05290982, 0.05704307, 0.02098841],\n",
" [-0.05816759, 0.05998519, 0.02260606],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.
6257505 , 0.2116082 , 0.8848519
],\n",
" [0.
6257505 , 0.2116082 , 0.8848519
],\n",
" [0.
5772543 , 0.00963263, 0.21164967
],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.
41804713, 0.3630384 , 0.55066955
],\n",
" [0.
41804713, 0.3630384 , 0.55066955
],\n",
" [0.
3918132 , 0.5544737 , 0.18690161
],\n",
" ...,\n",
" [0.
68013966, 0.58714706, 0.7767872
],\n",
" [0.
59187627, 0.8779615 , 0.06428586
],\n",
" [0.
59187627, 0.8779615 , 0.06428586
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [0.
78927505, 0.7185339 , 0.9068611
],\n",
" [0.
71406925, 0.7876062 , 0.39225307
],\n",
" [0.
71406925, 0.7876062 , 0.39225307
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" ...,\n",
...
...
@@ -88,25 +171,30 @@
"\n",
"ctx = meshvis.Context(width=640, height=480)\n",
"\n",
"texture = meshvis.ImageTexture(imageUri='textures/checkerboard.png')\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculatePointNormals(
m.points(), m.face_vertex_indices()
)\n",
"normals = meshvis.calculatePointNormals(
vertices, faces
)\n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"uvs = meshvis.PointAttribute(m.vertex_texcoords2D())\n",
"\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
" colors = colors,\n",
" uvs = uvs,\n",
" shading = 'flat')\n",
"\n",
"ctx.draw_edges(
m.points()
, m.ev_indices(), \n",
"ctx.draw_edges(
vertices
, 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.005)\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(
vertices, faces
, normals, 0.005)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"ctx.draw_vertices(
m.points()
, point_size=4, colors='red')\n",
"ctx.draw_vertices(
vertices
, point_size=4, colors='red')\n",
"\n",
"ctx.display()"
]
...
...
examples/Untitled.ipynb
View file @
3aabfb0f
...
...
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 1
8
,
"metadata": {
"scrolled": false
},
...
...
@@ -10,7 +10,36 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "337ba11c9c9f401993a7bb178c6078a4",
"model_id": "cb7a80ba6f35401e9e25250af0ba1f11",
"version_major": 2,
"version_minor": 0
},
"text/html": [
"<p>Failed to display Jupyter Widget of type <code>Preview</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": [
"Preview(child=ImageTexture(imageUri=u'textures/checkerboard.png', repeat=(1.0, 1.0)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "07a4763e3e814270a7b66e93e0be51e5",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -30,13 +59,19 @@
"</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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016805611188265124, 0.10981325821101032, -0.0013969168554233066)), Picker(controlling=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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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.43404183, 0.0136816 , 0.8130607 ],\n",
" [0.43404183, 0.0136816 , 0.8130607 ],\n",
" [0.43404183, 0.0136816 , 0.8130607 ],\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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), quaternion=(0.0, 0.0, 0.0, 1.0), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(-0.016805611188265124, 0.10981325821101032, -0.0013969168554233066)), Picker(controlling=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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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.29060814, 0.0531738 , 0.73882395],\n",
" [0.29060814, 0.0531738 , 0.73882395],\n",
" [0.29060814, 0.0531738 , 0.73882395],\n",
" ...,\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False), 'uv': BufferAttribute(array=array([[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0.
7165939 , 0.10731844, 0.02947531
],\n",
" [0.
7165939 , 0.10731844, 0.02947531
],\n",
" [0.
7165939 , 0.10731844, 0.02947531]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False
), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [0.
, 0.
],\n",
" [0.
, 0.
],\n",
" [0.
, 0.]], dtype=float32)
), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [-0.8924592 , -0.02002691, -0.45068336],\n",
" [-0.8525913 , -0.13340487, -0.50526357],\n",
" ...,\n",
...
...
@@ -48,13 +83,13 @@
" ...,\n",
" [-0.05290982, 0.05704307, 0.02098841],\n",
" [-0.05816759, 0.05998519, 0.02260606],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.
9276281 , 0.68196 , 0.25753966
],\n",
" [0.
9276281 , 0.68196 , 0.25753966
],\n",
" [0.
85570014, 0.8259304 , 0.57208616
],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.
41804713, 0.3630384 , 0.55066955
],\n",
" [0.
41804713, 0.3630384 , 0.55066955
],\n",
" [0.
3918132 , 0.5544737 , 0.18690161
],\n",
" ...,\n",
" [0.
14575003, 0.9981117 , 0.8627156
],\n",
" [0.
601416 , 0.23257364, 0.60186046
],\n",
" [0.
601416 , 0.23257364, 0.60186046
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [0.
78927505, 0.7185339 , 0.9068611
],\n",
" [0.
71406925, 0.7876062 , 0.39225307
],\n",
" [0.
71406925, 0.7876062 , 0.39225307
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" ...,\n",
...
...
@@ -72,13 +107,19 @@
" ...,\n",
" [-0.01389549, 0.16787168, -0.02189723],\n",
" [-0.069413 , 0.15121847, -0.04453854],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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)), event=u'dblclick', object=None)], 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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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.
43404183, 0.0136816 , 0.8130607
],\n",
" [0.
43404183, 0.0136816 , 0.8130607
],\n",
" [0.
43404183, 0.0136816 , 0.8130607
],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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)), event=u'dblclick', object=None)], 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=(0.6647806977667302, 0.6647806977667302, 0.6647806977667302), 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.
29060814, 0.0531738 , 0.73882395
],\n",
" [0.
29060814, 0.0531738 , 0.73882395
],\n",
" [0.
29060814, 0.0531738 , 0.73882395
],\n",
" ...,\n",
" [0.7165939 , 0.10731844, 0.02947531],\n",
" [0.7165939 , 0.10731844, 0.02947531],\n",
" [0.7165939 , 0.10731844, 0.02947531]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ],\n",
" [0.11056597, 0.5459648 , 0.3199318 ]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14901, 14902, 14903], dtype=uint16), normalized=False), 'uv': BufferAttribute(array=array([[0., 0.],\n",
" [0., 0.],\n",
" [0., 0.],\n",
" ...,\n",
" [0., 0.],\n",
" [0., 0.],\n",
" [0., 0.]], dtype=float32)), 'normal': BufferAttribute(array=array([[-0.8607535 , 0.1269212 , -0.4929447 ],\n",
" [-0.8924592 , -0.02002691, -0.45068336],\n",
" [-0.8525913 , -0.13340487, -0.50526357],\n",
" ...,\n",
...
...
@@ -90,13 +131,13 @@
" ...,\n",
" [-0.05290982, 0.05704307, 0.02098841],\n",
" [-0.05816759, 0.05998519, 0.02260606],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.
9276281 , 0.68196 , 0.25753966
],\n",
" [0.
9276281 , 0.68196 , 0.25753966
],\n",
" [0.
85570014, 0.8259304 , 0.57208616
],\n",
" [-0.0550398 , 0.0573097 , 0.0169909 ]], 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.
41804713, 0.3630384 , 0.55066955
],\n",
" [0.
41804713, 0.3630384 , 0.55066955
],\n",
" [0.
3918132 , 0.5544737 , 0.18690161
],\n",
" ...,\n",
" [0.
14575003, 0.9981117 , 0.8627156
],\n",
" [0.
601416 , 0.23257364, 0.60186046
],\n",
" [0.
601416 , 0.23257364, 0.60186046
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [0.
78927505, 0.7185339 , 0.9068611
],\n",
" [0.
71406925, 0.7876062 , 0.39225307
],\n",
" [0.
71406925, 0.7876062 , 0.39225307
]], dtype=float32)), 'index': BufferAttribute(array=array([ 0, 1, 2, ..., 14943, 14944, 14945], dtype=uint16), normalized=False), 'position': BufferAttribute(array=array([[-0.08656194, 0.14249188, 0.00843268],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" [-0.08969839, 0.13971257, 0.01377476],\n",
" ...,\n",
...
...
@@ -130,25 +171,30 @@
"\n",
"ctx = meshvis.Context(width=640, height=480)\n",
"\n",
"texture = meshvis.ImageTexture(imageUri='textures/checkerboard.png')\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculatePointNormals(
m.points(), m.face_vertex_indices()
)\n",
"normals = meshvis.calculatePointNormals(
vertices, faces
)\n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"uvs = meshvis.PointAttribute(m.vertex_texcoords2D())\n",
"\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
" colors = colors,\n",
" uvs = uvs,\n",
" shading = 'flat')\n",
"\n",
"ctx.draw_edges(
m.points()
, m.ev_indices(), \n",
"ctx.draw_edges(
vertices
, 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.005)\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(
vertices, faces
, normals, 0.005)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
"ctx.draw_vertices(
m.points()
, point_size=4, colors='red')\n",
"ctx.draw_vertices(
vertices
, point_size=4, colors='red')\n",
"\n",
"ctx.display()"
]
...
...
examples/models/uv_sphere.mtl
0 → 100644
View file @
3aabfb0f
# Blender MTL File: 'None'
# Material Count: 1
newmtl None
Ns 0
Ka 0.000000 0.000000 0.000000
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
examples/models/uv_sphere.obj
0 → 100644
View file @
3aabfb0f
This diff is collapsed.
Click to expand it.
examples/textures/checkerboard.png
0 → 100644
View file @
3aabfb0f
2.5 KB
meshvis/__init__.py
View file @
3aabfb0f
...
...
@@ -10,3 +10,4 @@ from .context import *
from
.immediate
import
*
from
.indexed_attribute
import
UniformAttribute
,
PointAttribute
,
FaceAttribute
,
HalfEdgeAttribute
from
.mesh_helper
import
*
from
pythreejs
import
ImageTexture
,
DataTexture
meshvis/context.py
View file @
3aabfb0f
...
...
@@ -40,7 +40,7 @@ class Context(object):
self
.
scene
.
add
(
mesh_obj
)
def
draw_faces
(
self
,
vertices
,
face_indices
,
normals
=
None
,
colors
=
None
,
uvs
=
None
,
shading
=
'flat'
,
z_offset
=
0.5
):
shading
=
'flat'
,
z_offset
=
0.5
,
texture
=
None
):
assert
(
len
(
face_indices
)
>
0
and
len
(
vertices
)
>
0
)
...
...
@@ -55,6 +55,7 @@ class Context(object):
mat
=
three
.
MeshPhongMaterial
(
color
=
'#dddddd'
)
mat
.
wireframe
=
shading
is
'wireframe'
mat
.
map
=
texture
if
z_offset
is
not
0
:
mat
.
polygonOffset
=
True
...
...
meshvis/immediate.py
View file @
3aabfb0f
from
.context
import
*
def
display_faces
(
vertices
,
face_indices
,
normals
=
None
,
colors
=
None
,
uvs
=
None
,
shading
=
'flat'
,
z_offset
=
0.5
,
width
=
600
,
height
=
400
,
shading
=
'flat'
,
z_offset
=
0.5
,
texture
=
None
,
width
=
600
,
height
=
400
,
background_color
=
'#dddddd'
):
Context
(
width
,
height
,
background_color
).
draw_faces
(
vertices
,
face_indices
,
normals
,
colors
,
uvs
,
shading
,
z_offset
).
display
()
Context
(
width
,
height
,
background_color
).
draw_faces
(
vertices
,
face_indices
,
normals
,
colors
,
uvs
,
shading
,
z_offset
,
texture
).
display
()
def
display_edges
(
vertices
,
edge_indices
=
None
,
colors
=
None
,
uvs
=
None
,
z_offset
=
0
,
linewidth
=
1
,
width
=
600
,
height
=
400
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment