U = igl.eigen.MatrixXd(V) igl.readTGF(TUTORIAL_SHARED_PATH + "arm.tgf", C, BE) # retrieve parents for forward kinematics igl.directed_edge_parents(BE, P) rest_pose = igl.RotationList() igl.directed_edge_orientations(C, BE, rest_pose) poses = [[igl.eigen.Quaterniond.Identity() for i in range(4)] for j in range(4)] twist = igl.eigen.Quaterniond(pi, igl.eigen.MatrixXd([1, 0, 0])) poses[1][2] = rest_pose[2] * twist * rest_pose[2].conjugate() bend = igl.eigen.Quaterniond(-pi * 0.7, igl.eigen.MatrixXd([0, 0, 1])) poses[3][2] = rest_pose[2] * bend * rest_pose[2].conjugate() igl.readDMAT(TUTORIAL_SHARED_PATH + "arm-weights.dmat", W) igl.lbs_matrix(V, W, M) # Plot the mesh with pseudocolors viewer = igl.viewer.Viewer() viewer.data.set_mesh(U, F) viewer.data.set_edges(C, BE, sea_green) viewer.core.show_lines = False viewer.core.show_overlay_depth = False viewer.core.line_width = 1 viewer.core.trackball_angle.normalize() viewer.callback_pre_draw = pre_draw viewer.callback_key_down = key_down viewer.core.is_animating = False viewer.core.camera_zoom = 2.5 viewer.core.animation_max_fps = 30.0 viewer.launch()
bc = igl.eigen.MatrixXd() igl.boundary_conditions(V, T, C, igl.eigen.MatrixXi(), BE, igl.eigen.MatrixXi(), b, bc) # compute BBW weights matrix bbw_data = igl.BBWData() # only a few iterations for sake of demo bbw_data.active_set_params.max_iter = 8 bbw_data.verbosity = 2 if not igl.bbw(V, T, b, bc, bbw_data, W): exit(-1) # Normalize weights to sum to one igl.normalize_row_sums(W, W) # precompute linear blend skinning matrix igl.lbs_matrix(V, W, M) # Plot the mesh with pseudocolors viewer = igl.viewer.Viewer() viewer.data.set_mesh(U, F) set_color(viewer) viewer.data.set_edges(C, BE, sea_green) viewer.core.show_lines = False viewer.core.show_overlay_depth = False viewer.core.line_width = 1 viewer.core.trackball_angle.normalize() viewer.callback_pre_draw = pre_draw viewer.callback_key_down = key_down viewer.core.is_animating = False viewer.core.animation_max_fps = 30.0 viewer.launch()