def init_gl_and_model(): global n_vertices, positions, colors, normals, uvs, centroid, bbox global trackball glClearColor(0.01, 0.01, 0.2, 0) glEnable(GL_DEPTH_TEST) glShadeModel(GL_SMOOTH) trackball = trackball.Trackball(0, 0, 2, 3) df = pd.read_csv("models/bunny_uv.tri", delim_whitespace=True, comment='#', header=None, dtype=np.float32) centroid = df.values[:, 0:3].mean(axis=0) bbox = df.values[:, 0:3].max(axis=0) - df.values[:, 0:3].min(axis=0) positions = df.values[:, 0:3] colors = df.values[:, 3:6] normals = df.values[:, 6:9] uvs = df.values[:, 9:11] n_vertices = len(positions) print("no. of vertices: %d, no. of triangles: %d" % (n_vertices, n_vertices // 3)) print("Centroid:", centroid) print("BBox:", bbox)
def __init__(self): self.pressed = None self.translation = [0, 0, 0, 0] self.trackball = trackball.Trackball(theta=-25, distance=15) self.mouse_loc = None self.callbacks = defaultdict(list) self.register()
def __init__(self): self.pressed = None self.translation = [0, 0, 0, 0] self.trackball = trackball.Trackball(theta=-25, distance=15) self.mouseLocation = None glutMouseFunc(self.mouseButtonEvent) glutMotionFunc(self.mouseMoveEvent)
def __init__(self): """ Initializes self. """ self.pressed = None # current pressed mouse button self.translation = [0, 0, 0, 0] # current location of camera self.trackball = trackball.Trackball(theta=-25, distance=15) # trackball to calculate rotation self.mouse_loc = None # current mouse location self.callbacks = defaultdict(list) # our callback mechanism # defaultdict is a normal dict, but if a key that isn't in there is called # instead of an error, it will create a new entry with default value [] given the argument list self.register()
def __init__(self): """ 处理用户接口 """ #被按下的键 self.pressed = None #轨迹球,会在之后进行说明 self.trackball = trackball.Trackball(theta=-25, distance=15) #当前鼠标位置 self.mouse_loc = None #回调函数词典 self.callbacks = defaultdict(list) self.register()
def run(title='GLUT Window', simulation=None, trans=None, step_callback=None, keyboard_callback=None, render_callback=None): global sim sim = simulation print("\n") print("space bar: simulation on/off") print("'p': playback/stop") print("'[' and ']': play one frame backward and forward") # Init glut global window glutInit(()) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH) glutInitWindowSize(800, 600) glutInitWindowPosition(0, 0) window = glutCreateWindow(title) # Init trackball global tb if trans is None: trans = [0.0, 0.2, -0.9] tb = trackball.Trackball(theta=-10.5, trans=trans) # Init callback global step_callback_func global keyboard_callback_func global render_callback_func step_callback_func = step_callback keyboard_callback_func = keyboard_callback render_callback_func = render_callback # Init functions # glutFullScreen() glutDisplayFunc(drawGL) glutIdleFunc(idle) glutReshapeFunc(resizeGL) glutKeyboardFunc(keyPressed) glutMouseFunc(mouseFunc) glutMotionFunc(motionFunc) glutTimerFunc(25, renderTimer, 1) initGL(800, 600) # Run glutMainLoop() # Print message to console, and kick off the main to get it rolling. print "Hit ESC key to quit." main()
def __init__(self): """ deal wiyh user's jiekou""" # the button user press self.pressed = None #track ball self.trackball = trackball.Trackball(theta=-25, distance=15) #current mouse position self.mouse_loc = None #callback functon dict self.callbacks = defaultdict(list) self.register()
def __init__(self): """ Handles user interaction """ # currently pressed mouse button self.pressed = None # the current location of the camera self.translation = [0, 0, 0, 0] # the trackball to calculate rotation self.trackball = trackball.Trackball(theta=-25, distance=15) # the current mouse location self.mouse_loc = None # Unsophisticated callback mechanism self.callbacks = defaultdict(list) self.register()
def __init__(self, parent=None): super(GLWidget, self).__init__(parent) self.width = 1280 self.height = 720 fmt = QGLFormat() fmt.setSampleBuffers(True) fmt.setSamples(4) self.setFormat(fmt) # Anti-aliasing self.tb = trackball.Trackball() self.lastPos = None self.zoom = -1.2 self.sim = None self.captureIndex = 0
def __init__(self): """ 处理用户接口 """ # 被按下的键 self.pressed = None # the current location of the camera self.translation = [0, 0, 0, 0] # 轨迹球 self.trackball = trackball.Trackball(theta=-25, distance=15) # 当前鼠标位置 self.mouse_loc = None # 回调函数词典 self.callbacks = defaultdict(list) self.register()
def __init__(self, title="SfM Browser"): self.title = title self.point_manager = None self.camera_manager = None self.verts = None self.bar = None self.space_key = False self.fig_size = (1280, 960) self.fig_pos = (0, 10) self.fig = glumpy.figure(self.fig_size, self.fig_pos) self.trackball = trackball.Trackball(0.0, 0.0, 1.0, 10.0) self.eye = eye.Eye(center=[0.0, 0.0, -10.0], focus=[0.0, 0.0, 0.0], up=[0.0, 1.0, 0.0]) self.tb_show = c_bool(1) self.eye_show = c_bool(0) self.points_show = c_bool(1) self.full = c_bool(0) self.color = (c_float * 4)(0., 0., 0., 1.0)