Пример #1
0
 def OnTranslate(self, event):
     model = gltbx.util.get_gl_modelview_matrix()
     proj = gltbx.util.get_gl_projection_matrix()
     view = gltbx.util.get_gl_viewport()
     winx = []
     winy = []
     winz = []
     rc = self.rotation_center
     rc_eye = gltbx.util.object_as_eye_coordinates(rc)
     assert glu.gluProject(rc[0], rc[1], rc[2], model, proj, view, winx,
                           winy, winz)
     objx = []
     objy = []
     objz = []
     win_height = max(1, self.w)
     assert glu.gluUnProject(
         winx[0],
         winy[0] + 0.5 * win_height,
         winz[0],
         model,
         proj,
         view,
         objx,
         objy,
         objz,
     )
     dist = v3distsq((objx[0], objy[0], objz[0]), rc)**0.5
     scale = abs(dist / (0.5 * win_height))
     x, y = event.GetX(), event.GetY()
     gltbx.util.translate_object(scale, x, y, self.xmouse, self.ymouse)
     self.rotation_center = tuple(
         gltbx.util.modelview_matrix_as_rt().inverse() * matrix.col(rc_eye))
     self.OnRedraw()
     self.OnRecordMouse(event)
Пример #2
0
 def get_pick_points(self, mouse_xy):
     model = gltbx.util.get_gl_modelview_matrix()
     proj = gltbx.util.get_gl_projection_matrix()
     view = gltbx.util.get_gl_viewport()
     self.pick_points = []
     for winz in [0.0, 1.0]:
         objx = []
         objy = []
         objz = []
         ok = glu.gluUnProject(
             mouse_xy[0],
             self.h - mouse_xy[1],
             winz,
             model,
             proj,
             view,
             objx,
             objy,
             objz,
         )
         if not ok:
             self.pick_points = None
             break
         self.pick_points.append((objx[0], objy[0], objz[0]))