本文整理汇总了Python中gl_utils.trackball.Trackball.pan_to方法的典型用法代码示例。如果您正苦于以下问题:Python Trackball.pan_to方法的具体用法?Python Trackball.pan_to怎么用?Python Trackball.pan_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl_utils.trackball.Trackball
的用法示例。
在下文中一共展示了Trackball.pan_to方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Visualizer
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import pan_to [as 别名]
#.........这里部分代码省略.........
self.clear_gl_screen()
self.trackball.push()
# 2. in pixel space draw video frame
glLoadMatrixf(self.get_image_space_matrix(15))
g_pool.image_tex.draw( quad=((0,self.image_height),(self.image_width,self.image_height),(self.image_width,0),(0,0)) ,alpha=0.5)
glLoadMatrixf(self.get_adjusted_pixel_space_matrix(15))
self.draw_frustum()
glLoadMatrixf(self.get_anthropomorphic_matrix())
model_count = 0;
sphere_color = RGBA( 0,147/255.,147/255.,0.2)
initial_sphere_color = RGBA( 0,147/255.,147/255.,0.2)
alternative_sphere_color = RGBA( 1,0.5,0.5,0.05)
alternative_initial_sphere_color = RGBA( 1,0.5,0.5,0.05)
for model in sphere_models:
bin_positions = model['binPositions']
sphere = model['sphere']
initial_sphere = model['initialSphere']
if model_count == 0:
# self.draw_sphere(initial_sphere[0],initial_sphere[1], color = sphere_color )
self.draw_sphere(sphere[0],sphere[1], color = initial_sphere_color )
draw_points(bin_positions, 3 , RGBA(0.6,0.0,0.6,0.5) )
else:
#self.draw_sphere(initial_sphere[0],initial_sphere[1], color = alternative_sphere_color )
self.draw_sphere(sphere[0],sphere[1], color = alternative_initial_sphere_color )
model_count += 1
self.draw_circle( latest_circle[0], latest_circle[1], latest_circle[2], RGBA(0.0,1.0,1.0,0.4))
# self.draw_circle( predicted_circle[0], predicted_circle[1], predicted_circle[2], RGBA(1.0,0.0,0.0,0.4))
draw_points(edges, 2 , RGBA(1.0,0.0,0.6,0.5) )
glLoadMatrixf(self.get_anthropomorphic_matrix())
self.draw_coordinate_system(4)
self.trackball.pop()
self.draw_debug_info(result)
glfwSwapBuffers(self._window)
glfwPollEvents()
return True
def close_window(self):
if self._window:
glfwDestroyWindow(self._window)
self._window = None
############ window callbacks #################
def on_resize(self,window,w, h):
h = max(h,1)
w = max(w,1)
self.trackball.set_window_size(w,h)
self.window_size = (w,h)
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(window)
self.adjust_gl_view(w,h)
glfwMakeContextCurrent(active_window)
def on_char(self,window,char):
if char == ord('r'):
self.trackball.distance = [0,0,-0.1]
self.trackball.pitch = 0
self.trackball.roll = 0
def on_button(self,window,button, action, mods):
# self.gui.update_button(button,action,mods)
if action == GLFW_PRESS:
self.input['button'] = button
self.input['mouse'] = glfwGetCursorPos(window)
if action == GLFW_RELEASE:
self.input['button'] = None
def on_pos(self,window,x, y):
hdpi_factor = float(glfwGetFramebufferSize(window)[0]/glfwGetWindowSize(window)[0])
x,y = x*hdpi_factor,y*hdpi_factor
# self.gui.update_mouse(x,y)
if self.input['button']==GLFW_MOUSE_BUTTON_RIGHT:
old_x,old_y = self.input['mouse']
self.trackball.drag_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
if self.input['button']==GLFW_MOUSE_BUTTON_LEFT:
old_x,old_y = self.input['mouse']
self.trackball.pan_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
def on_iconify(self,window,iconified): pass
def on_key(self,window, key, scancode, action, mods): pass
示例2: Calibration_Visualizer
# 需要导入模块: from gl_utils.trackball import Trackball [as 别名]
# 或者: from gl_utils.trackball.Trackball import pan_to [as 别名]
#.........这里部分代码省略.........
glPushMatrix()
glLoadMatrixf( self.eye_to_world_matrix1.T )
sphere_center1 = list(sphere1['center'])
sphere_radius1 = sphere1['radius']
self.draw_sphere(sphere_center1,sphere_radius1, color = RGBA(1,1,0,1))
for p in self.cal_gaze_points1_3d:
draw_polyline( [ sphere_center1, p] , 1 , calibration_points_line_color, line_type = GL_LINES)
#calibration points
draw_points( self.cal_gaze_points1_3d , 4 , RGBA( 1, 0, 1, 1 ) )
# eye camera
self.draw_coordinate_system(60)
self.draw_frustum( self.image_width / 10.0, self.image_height / 10.0, self.focal_length /10.)
draw_points( gaze_points1 , 2 , RGBA( 1, 0, 0, 1 ) )
for p in gaze_points1:
draw_polyline( [sphere_center1, p] , 1 , RGBA(0,0,0,1), line_type = GL_LINES)
glPopMatrix()
#draw error lines form eye gaze points to world camera ref points
for(cal_gaze_point,ref_point) in zip(self.cal_gaze_points1_3d, self.cal_ref_points_3d):
point = np.zeros(4)
point[:3] = cal_gaze_point
point[3] = 1.0
point = self.eye_to_world_matrix1.dot( point )
point = np.squeeze(np.asarray(point))
draw_polyline( [ point[:3], ref_point] , 1 , error_line_color, line_type = GL_LINES)
#intersection points in world coordinate system
if len(intersection_points) > 0:
draw_points( intersection_points , 2 , RGBA( 1, 0.5, 0.5, 1 ) )
for p in intersection_points:
draw_polyline( [(0,0,0), p] , 1 , RGBA(0.3,0.3,0.9,1), line_type = GL_LINES)
self.trackball.pop()
glfwSwapBuffers(self.window)
glfwPollEvents()
glfwMakeContextCurrent(active_window)
def close_window(self):
if self.window:
active_window = glfwGetCurrentContext();
glfwDestroyWindow(self.window)
self.window = None
glfwMakeContextCurrent(active_window)
############ window callbacks #################
def on_resize(self,window,w, h):
h = max(h,1)
w = max(w,1)
self.trackball.set_window_size(w,h)
self.window_size = (w,h)
active_window = glfwGetCurrentContext()
glfwMakeContextCurrent(window)
self.adjust_gl_view(w,h)
glfwMakeContextCurrent(active_window)
def on_char(self,window,char):
if char == ord('r'):
self.trackball.distance = [0,0,-0.1]
self.trackball.pitch = 0
self.trackball.roll = 180
def on_button(self,window,button, action, mods):
# self.gui.update_button(button,action,mods)
if action == GLFW_PRESS:
self.input['button'] = button
self.input['mouse'] = glfwGetCursorPos(window)
if action == GLFW_RELEASE:
self.input['button'] = None
def on_pos(self,window,x, y):
hdpi_factor = float(glfwGetFramebufferSize(window)[0]/glfwGetWindowSize(window)[0])
x,y = x*hdpi_factor,y*hdpi_factor
# self.gui.update_mouse(x,y)
if self.input['button']==GLFW_MOUSE_BUTTON_RIGHT:
old_x,old_y = self.input['mouse']
self.trackball.drag_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
if self.input['button']==GLFW_MOUSE_BUTTON_LEFT:
old_x,old_y = self.input['mouse']
self.trackball.pan_to(x-old_x,y-old_y)
self.input['mouse'] = x,y
def on_scroll(self,window,x,y):
self.trackball.zoom_to(y)
def on_iconify(self,window,iconified): pass
def on_key(self,window, key, scancode, action, mods): pass