Commit 13bbea51 authored by Isaak Lim's avatar Isaak Lim

rename meshvis to threevis and update om mesh reading calls

parent b2cf6f9f
# MeshVis
[[#]] ThreeVis
## Setup
......@@ -14,20 +14,20 @@
## Example
```python
import meshvis
import threevis
m = om.TriMesh()
om.read_mesh(m, '/home/dseyb/git/openmesh-python/tests/TestFiles/cube-minimal-normals.ply')
meshvis.display_openmesh(m)
threevis.display_openmesh(m)
meshvis.display_file('/home/dseyb/git/openmesh-python/tests/TestFiles/square_material_texture.obj')
threevis.display_file('/home/dseyb/git/openmesh-python/tests/TestFiles/square_material_texture.obj')
```
```python
import meshvis
import threevis
import openmesh as om
import numpy as np
......@@ -36,17 +36,17 @@ m = om.TriMesh()
om.read_mesh(m, "./mouse.obj")
# Create Context
ctx = meshvis.Context(width=640, height=480)
ctx = threevis.Context(width=640, height=480)
# Get vertices and faces from the mesh
vertices = m.points()
faces = m.face_vertex_indices()
# We don't have normals, calculate them
normals = meshvis.calculateFaceNormals(m.points(), m.face_vertex_indices())
normals = threevis.calculateFaceNormals(m.points(), m.face_vertex_indices())
# Choose a random color for each face
colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))
colors = threevis.FaceAttribute(np.random.rand(len(faces), 3))
# Draw the mesh with flat shading
ctx.draw_faces(vertices, faces,
......@@ -56,11 +56,11 @@ ctx.draw_faces(vertices, faces,
# Draw edges on top with random colors
ctx.draw_edges(vertices, m.ev_indices(),
colors = meshvis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),
colors = threevis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),
linewidth=3)
# Calculate data to display normals as edges
normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(vertices, faces, normals, length=0.05)
normal_vis_verts, normal_vis_edges = threevis.calculateNormalEdges(vertices, faces, normals, length=0.05)
# Draw the normals in
ctx.draw_edges(normal_vis_verts, normal_vis_edges, colors = colors)
......@@ -72,4 +72,4 @@ ctx.draw_vertices(vertices, point_size=4, colors='red')
ctx.display()
```
![mouse](https://www.graphics.rwth-aachen.de:9000/dseyb/meshvis/raw/master/docs/images/mouse.PNG)
\ No newline at end of file
![mouse](https://www.graphics.rwth-aachen.de:9000/threevis/threevis/raw/master/docs/images/mouse.PNG)
......@@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = meshvis
SPHINXPROJ = threevis
SOURCEDIR = source
BUILDDIR = build
......@@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
......@@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=meshvis
set SPHINXPROJ=threevis
if "%1" == "" goto help
......
......@@ -14,12 +14,12 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../../meshvis/'))
sys.path.insert(0, os.path.abspath('../../threevis/'))
# -- Project information -----------------------------------------------------
project = u'meshvis'
project = u'threevis'
copyright = u'2018, Dario Seyb, Isaak Lim, Janis Born'
author = u'Dario Seyb, Isaak Lim, Janis Born'
......@@ -110,7 +110,7 @@ html_static_path = ['_static']
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'meshvisdoc'
htmlhelp_basename = 'threevisdoc'
# -- Options for LaTeX output ------------------------------------------------
......@@ -137,7 +137,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'meshvis.tex', u'meshvis Documentation',
(master_doc, 'threevis.tex', u'threevis Documentation',
u'Dario Seyb, Isaak Lim, Janis Born', 'manual'),
]
......@@ -147,7 +147,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'meshvis', u'meshvis Documentation',
(master_doc, 'threevis', u'threevis Documentation',
[author], 1)
]
......@@ -158,8 +158,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'meshvis', u'meshvis Documentation',
author, 'meshvis', 'Visualize meshes, point clouds, volumes and other geometry in a Jupyter Notebook',
(master_doc, 'threevis', u'threevis Documentation',
author, 'threevis', 'Visualize meshes, point clouds, volumes and other geometry in a Jupyter Notebook',
'Miscellaneous'),
]
......@@ -169,4 +169,4 @@ texinfo_documents = [
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
\ No newline at end of file
todo_include_todos = True
......@@ -6,27 +6,26 @@
"metadata": {},
"outputs": [],
"source": [
"import meshvis\n",
"import threevis\n",
"import openmesh as om\n",
"import numpy as np\n",
"\n",
"m = om.PolyMesh()\n",
"om.read_mesh(m, 'models/model_mixed_valence.obj')\n",
"m = om.read_polymesh('models/model_mixed_valence.obj')\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"edges = m.ev_indices()\n",
"\n",
"mesh = meshvis.Mesh(vertices, faces)\n",
"mesh.colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"mesh.normals = meshvis.calculatePointNormals(vertices, faces)\n",
"mesh = threevis.Mesh(vertices, faces)\n",
"mesh.colors = threevis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"mesh.normals = threevis.calculatePointNormals(vertices, faces)\n",
"\n",
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(vertices, faces, mesh.normals, 0.5)\n",
"normal_vis_verts, normal_vis_edges = threevis.calculateNormalEdges(vertices, faces, mesh.normals, 0.5)\n",
"\n",
"ctx = meshvis.Context()\n",
"ctx = threevis.Context()\n",
"\n",
"ctx.draw(mesh).draw(meshvis.EdgeList(vertices, edges)).draw(meshvis.PointList(vertices, colors='#aaaaaa'), point_size=3)\n",
"ctx.draw(mesh).draw(threevis.EdgeList(vertices, edges)).draw(threevis.PointList(vertices, colors='#aaaaaa'), point_size=3)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
......@@ -37,20 +36,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2"
"pygments_lexer": "ipython3",
"version": "3.5.3rc1"
}
},
"nbformat": 4,
......
......@@ -2,154 +2,25 @@
"cells": [
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bfede5fc21a145578b05f2ae795248e6",
"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=(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.45077944, 0.3677988 , 0.75951713],\n",
" [0.45077944, 0.3677988 , 0.75951713],\n",
" [0.45077944, 0.3677988 , 0.75951713],\n",
" ...,\n",
" [0.7766238 , 0.9185119 , 0.8154292 ],\n",
" [0.7766238 , 0.9185119 , 0.8154292 ],\n",
" [0.7766238 , 0.9185119 , 0.8154292 ]], 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.00803294, -0.0471043 ],\n",
" [ 0.02723481, -0.08777347]], 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.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.01003403, 0.45385548, 0.7758159 ],\n",
" [0.01003403, 0.45385548, 0.7758159 ],\n",
" [0.7655369 , 0.3169551 , 0.85059947],\n",
" ...,\n",
" [0.27643302, 0.85323256, 0.719638 ],\n",
" [0.7488284 , 0.2272273 , 0.37840167],\n",
" [0.7488284 , 0.2272273 , 0.37840167]], 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.45077944, 0.3677988 , 0.75951713],\n",
" [0.45077944, 0.3677988 , 0.75951713],\n",
" [0.45077944, 0.3677988 , 0.75951713],\n",
" ...,\n",
" [0.7766238 , 0.9185119 , 0.8154292 ],\n",
" [0.7766238 , 0.9185119 , 0.8154292 ],\n",
" [0.7766238 , 0.9185119 , 0.8154292 ]], 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.00803294, -0.0471043 ],\n",
" [ 0.02723481, -0.08777347]], 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.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.01003403, 0.45385548, 0.7758159 ],\n",
" [0.01003403, 0.45385548, 0.7758159 ],\n",
" [0.7655369 , 0.3169551 , 0.85059947],\n",
" ...,\n",
" [0.27643302, 0.85323256, 0.719638 ],\n",
" [0.7488284 , 0.2272273 , 0.37840167],\n",
" [0.7488284 , 0.2272273 , 0.37840167]], 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)), shadowMap=WebGLShadowMap())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import meshvis\n",
"import threevis\n",
"import openmesh as om\n",
"import numpy as np\n",
"m = om.TriMesh()\n",
"om.read_mesh(m, \"models/bunny.obj\")\n",
"m = om.read_trimesh(\"models/bunny.obj\")\n",
"\n",
"ctx = meshvis.Context(width=640, height=480)\n",
"ctx = threevis.Context(width=640, height=480)\n",
"\n",
"texture = meshvis.ImageTexture(imageUri='textures/checkerboard.png')\n",
"texture = threevis.ImageTexture(imageUri='textures/checkerboard.png')\n",
"\n",
"vertices = m.points()\n",
"faces = m.face_vertex_indices()\n",
"\n",
"normals = meshvis.calculatePointNormals(vertices, faces)\n",
"colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"uvs = meshvis.PointAttribute(m.vertex_texcoords2D())\n",
"normals = threevis.calculatePointNormals(vertices, faces)\n",
"colors = threevis.FaceAttribute(np.random.rand(len(faces), 3))\n",
"uvs = threevis.PointAttribute(m.vertex_texcoords2D())\n",
"\n",
"ctx.draw_faces(vertices, faces, \n",
" normals = normals,\n",
......@@ -158,10 +29,10 @@
" shading = 'flat')\n",
"\n",
"ctx.draw_edges(vertices, m.ev_indices(), \n",
" colors = meshvis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),\n",
" colors = threevis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),\n",
" linewidth=3)\n",
"\n",
"normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(vertices, faces, normals, 0.005)\n",
"normal_vis_verts, normal_vis_edges = threevis.calculateNormalEdges(vertices, faces, normals, 0.005)\n",
"\n",
"ctx.draw_edges(normal_vis_verts, normal_vis_edges)\n",
"\n",
......@@ -172,188 +43,18 @@
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5688f785b1a141d0b4d52bd30c0a66ab",
"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.5, 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.5355339059327378, 3.5355339059327378, 3.5355339059327378), 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.5, 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.5355339059327378, 3.5355339059327378, 3.5355339059327378), 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.5, 0.5, 0.0)), 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.5, 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.5355339059327378, 3.5355339059327378, 3.5355339059327378), 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([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 1.]], dtype=float32)), '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'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))), 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.5, 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.5355339059327378, 3.5355339059327378, 3.5355339059327378), 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([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 1.]], dtype=float32)), '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'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))), 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": [
"import meshvis\n",
"vcolors = [\n",
" [1, 0, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 1],\n",
" [1, 0, 1]\n",
"]\n",
"\n",
"fcolors = [\n",
" [1, 0, 0],\n",
" [0, 0, 1]\n",
"]\n",
"\n",
"meshvis.display_edges([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], \n",
" [[0, 1], [2,3]], \n",
" colors = meshvis.PointAttribute(vcolors))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0547730d134f47eeb6309c376f9bad1e",
"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.5, 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=(2.5, 2.5, 2.5), 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.5, 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=(2.5, 2.5, 2.5), 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.5, 0.0, 0.0)), 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.5, 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=(2.5, 2.5, 2.5), 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., 0., 0.],\n",
" [1., 0., 0.]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'blue', map=None, size=10.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.5, 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=(2.5, 2.5, 2.5), 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., 0., 0.],\n",
" [1., 0., 0.]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'blue', map=None, size=10.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"
}
],
"outputs": [],
"source": [
"meshvis.display_vertices([[0,0,0],[1,0, 0]], colors='blue', point_size=10)"
"threevis.display_vertices([[0,0,0],[1,0, 0]], colors='blue', point_size=10)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a3d7dfec9eb642c28b75eb86c1ed0a8f",
"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(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=(7.0710678118654755, 7.0710678118654755, 7.0710678118654755), 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(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=(7.0710678118654755, 7.0710678118654755, 7.0710678118654755), 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.0, 0.0, 1.0)), 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(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=(7.0710678118654755, 7.0710678118654755, 7.0710678118654755), 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([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([0, 1, 2, 3, 4, 5], dtype=uint16), normalized=False), 'uv': BufferAttribute(array=array([[0., 0.],\n",
" [1., 0.],\n",
" [1., 1.],\n",
" [0., 0.],\n",
" [1., 1.],\n",
" [0., 1.]], dtype=float32)), 'position': BufferAttribute(array=array([[-1., -1., 1.],\n",
" [ 1., -1., 1.],\n",
" [ 1., 1., 1.],\n",
" [-1., -1., 1.],\n",
" [ 1., 1., 1.],\n",
" [-1., 1., 1.]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=ImageTexture(imageUri=u'textures/checkerboard.png', repeat=(1.0, 1.0)), 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)), Points(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 1.]], dtype=float32)), 'position': BufferAttribute(array=array([[-1., -1., 1.],\n",
" [ 1., -1., 1.],\n",
" [ 1., 1., 1.],\n",
" [-1., 1., 1.]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'#dddddd', map=None, size=5.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)), 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(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=(7.0710678118654755, 7.0710678118654755, 7.0710678118654755), 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([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 1.]], dtype=float32)), 'index': BufferAttribute(array=array([0, 1, 2, 3, 4, 5], dtype=uint16), normalized=False), 'uv': BufferAttribute(array=array([[0., 0.],\n",
" [1., 0.],\n",
" [1., 1.],\n",
" [0., 0.],\n",
" [1., 1.],\n",
" [0., 1.]], dtype=float32)), 'position': BufferAttribute(array=array([[-1., -1., 1.],\n",
" [ 1., -1., 1.],\n",
" [ 1., 1., 1.],\n",
" [-1., -1., 1.],\n",
" [ 1., 1., 1.],\n",
" [-1., 1., 1.]], dtype=float32), normalized=False)}), material=MeshLambertMaterial(alphaMap=None, aoMap=None, color=u'white', emissiveMap=None, envMap=None, lightMap=None, map=ImageTexture(imageUri=u'textures/checkerboard.png', repeat=(1.0, 1.0)), 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)), Points(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.],\n",
" [1., 0., 1.]], dtype=float32)), 'position': BufferAttribute(array=array([[-1., -1., 1.],\n",
" [ 1., -1., 1.],\n",
" [ 1., 1., 1.],\n",
" [-1., 1., 1.]], dtype=float32), normalized=False)}), material=PointsMaterial(color=u'#dddddd', map=None, size=5.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": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"verts = [\n",
" # Front face\n",
......@@ -386,36 +87,60 @@
" [0, 1]\n",
"]\n",
"\n",
"ctx = meshvis.Context(width=300, height=300)\n",
"ctx = threevis.Context(width=300, height=300)\n",
"\n",
"ctx.draw_faces(verts, indices, \n",
" colors = meshvis.PointAttribute(vcolors),\n",
" uvs = meshvis.PointAttribute(uvs),\n",
" texture = meshvis.ImageTexture(imageUri='textures/checkerboard.png'))\n",
" colors = threevis.PointAttribute(vcolors),\n",
" uvs = threevis.PointAttribute(uvs),\n",
" texture = threevis.ImageTexture(imageUri='textures/checkerboard.png'))\n",
"\n",
"ctx.draw_vertices(verts, point_size=5, colors=vcolors)\n",
"\n",
"ctx.display()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import threevis\n",
"vcolors = [\n",
" [1, 0, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 1],\n",
" [1, 0, 1]\n",
"]\n",
"\n",
"fcolors = [\n",
" [1, 0, 0],\n",
" [0, 0, 1]\n",
"]\n",
"\n",
"threevis.display_edges([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], \n",
" [[0, 1], [2,3]], \n",
" colors = threevis.PointAttribute(vcolors))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",