Update python tutorials to reflect the viewer refactor

Former-commit-id: 8edf097dcf
This commit is contained in:
Zhongshi Jiang
2018-03-16 20:58:19 -04:00
parent 54ac027e5a
commit f8f3f1b48e
10 changed files with 66 additions and 66 deletions
+7 -7
View File
@@ -10,7 +10,7 @@ import sys, os
# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import pyigl as igl
import numpy as np
from shared import TUTORIAL_SHARED_PATH, check_dependencies, print_usage
@@ -22,14 +22,14 @@ def mouse_down(viewer, a, b):
bc = igl.eigen.MatrixXd()
# Cast a ray in the view direction starting from the mouse position
fid = igl.eigen.MatrixXi([-1])
fid = igl.eigen.MatrixXi(np.array([-1]))
coord = igl.eigen.MatrixXd([viewer.current_mouse_x, viewer.core.viewport[3] - viewer.current_mouse_y])
hit = igl.unproject_onto_mesh(coord, viewer.core.view * viewer.core.model,
viewer.core.proj, viewer.core.viewport, V, F, fid, bc)
if hit:
# paint hit red
C.setRow(fid[0, 0], igl.eigen.MatrixXd([[1, 0, 0]]))
viewer.data.set_colors(C)
viewer.data().set_colors(C)
return True
return False
@@ -51,9 +51,9 @@ if __name__ == "__main__":
C.setConstant(F.rows(), 3, 1.0)
# Show mesh
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.data.set_colors(C)
viewer.core.show_lines = False
viewer = igl.glfw.Viewer()
viewer.data().set_mesh(V, F)
viewer.data().set_colors(C)
viewer.data().show_lines = False
viewer.callback_mouse_down = mouse_down
viewer.launch()