def on_timer(self, event): model = np.eye(4, dtype=np.float32) #scale(model, 1, 1, 1) self.cube['model'] = model self.view = np.eye(4) xrotate(self.view, self.rotate[0]) yrotate(self.view, self.rotate[1]) zrotate(self.view, self.rotate[2]) translate(self.view, *self.translate) self.listener.waitForTransform("/robot", "/wrist_joint", rospy.Time(), rospy.Duration(4)) pos, rot = self.listener.lookupTransform("/robot", "/wrist_joint", rospy.Time(0)) print list(pos) self.translate[0] = -list(pos)[0] * 10 self.translate[1] = -list(pos)[1] * 10 self.translate[2] = -5 self.cube['view'] = self.view self.update()
def on_key_press(self, event): """Controls - a(A) - move left d(D) - move right w(W) - move up s(S) - move down x/X - rotate about x-axis cw/anti-cw y/Y - rotate about y-axis cw/anti-cw z/Z - rotate about z-axis cw/anti-cw space - reset view p(P) - print current view i(I) - zoom in o(O) - zoom out """ self.translate = [0, 0, 0] self.rotate = [0, 0, 0] if(event.text == 'p' or event.text == 'P'): print(self.view) elif(event.text == 'd' or event.text == 'D'): self.translate[0] = 0.3 elif(event.text == 'a' or event.text == 'A'): self.translate[0] = -0.3 elif(event.text == 'w' or event.text == 'W'): self.translate[1] = 0.3 elif(event.text == 's' or event.text == 'S'): self.translate[1] = -0.3 elif(event.text == 'o' or event.text == 'O'): self.translate[2] = 0.3 elif(event.text == 'i' or event.text == 'I'): self.translate[2] = -0.3 elif(event.text == 'x'): self.rotate = [1, 0, 0] elif(event.text == 'X'): self.rotate = [-1, 0, 0] elif(event.text == 'y'): self.rotate = [0, 1, 0] elif(event.text == 'Y'): self.rotate = [0, -1, 0] elif(event.text == 'z'): self.rotate = [0, 0, 1] elif(event.text == 'Z'): self.rotate = [0, 0, -1] elif(event.text == ' '): self.view = self.default_view translate(self.view, -self.translate[0], -self.translate[1], -self.translate[2]) xrotate(self.view, self.rotate[0]) yrotate(self.view, self.rotate[1]) zrotate(self.view, self.rotate[2]) self.program['u_view'] = self.view self.update()
def on_key_press(self, event): """Controls - a(A) - move left d(D) - move right w(W) - move up s(S) - move down x/X - rotate about x-axis cw/anti-cw y/Y - rotate about y-axis cw/anti-cw z/Z - rotate about z-axis cw/anti-cw space - reset view p(P) - print current view i(I) - zoom in o(O) - zoom out """ self.translate = [0, 0, 0] self.rotate = [0, 0, 0] if (event.text == 'p' or event.text == 'P'): print(self.view) elif (event.text == 'd' or event.text == 'D'): self.translate[0] = 0.3 elif (event.text == 'a' or event.text == 'A'): self.translate[0] = -0.3 elif (event.text == 'w' or event.text == 'W'): self.translate[1] = 0.3 elif (event.text == 's' or event.text == 'S'): self.translate[1] = -0.3 elif (event.text == 'o' or event.text == 'O'): self.translate[2] = 0.3 elif (event.text == 'i' or event.text == 'I'): self.translate[2] = -0.3 elif (event.text == 'x'): self.rotate = [1, 0, 0] elif (event.text == 'X'): self.rotate = [-1, 0, 0] elif (event.text == 'y'): self.rotate = [0, 1, 0] elif (event.text == 'Y'): self.rotate = [0, -1, 0] elif (event.text == 'z'): self.rotate = [0, 0, 1] elif (event.text == 'Z'): self.rotate = [0, 0, -1] elif (event.text == ' '): self.view = self.default_view translate(self.view, -self.translate[0], -self.translate[1], -self.translate[2]) xrotate(self.view, self.rotate[0]) yrotate(self.view, self.rotate[1]) zrotate(self.view, self.rotate[2]) self.program['u_view'] = self.view self.update()
def on_timer(self, event): # self.phi += .5 model = np.eye(4, dtype=np.float32) scale(model, 1, 1, 1) # rotate(model, self.phi, 0, 0, 1) self.cube['model'] = model self.view = np.eye(4) xrotate(self.view, self.rotate[0]) yrotate(self.view, self.rotate[1]) zrotate(self.view, self.rotate[2]) translate(self.view, *self.translate) self.cube['view'] = self.view self.update()
def __init__(self): app.Canvas.__init__(self, keys='interactive') self.program = gloo.Program(vertex, fragment) self.default_view = np.eye(4, dtype=np.float32) self.view = self.default_view self.model = np.eye(4, dtype=np.float32) self.projection = np.eye(4, dtype=np.float32) self.translate = [0, 0, 0] self.rotate = [0, 0, 0] self.program[ "u_light_position"] = self.lightx, self.lighty, self.lightz self.program["u_light_intensity"] = 1, 1, 1 self.program['u_model'] = scale(self.model, cellsize, cellsize, 1.0) translate(self.view, -1250, -1250, -2000) zrotate(self.view, 90) self.program['u_view'] = self.view self.program['u_normal'] = np.array( np.matrix(np.dot(self.view, self.model)).I.T) self.update() self.program['a_position'] = gloo.VertexBuffer(triangles) self.program['a_scale'] = np.array([cellsize, cellsize, 1.0, 1.0])
def rotate_ctm(self, radian_angle): degree_angle = -180 * radian_angle / np.pi self._state.ctm = zrotate(self._state.ctm, degree_angle)
def on_key_press(self, event): """Controls - a(A) - move left d(D) - move right w(W) - move up s(S) - move down x/X - rotate about x-axis cw/anti-cw y/Y - rotate about y-axis cw/anti-cw z/Z - rotate about z-axis cw/anti-cw space - reset view p(P) - print current view i(I) - zoom in o(O) - zoom out 6 - Move light right 4 - Move light left 8 - Move light up 5 - Move light down 7 - Move light up (depthwise) 1 - Move light down (depthwise) """ self.translate = [0, 0, 0] self.rotate = [0, 0, 0] if (event.text == 'p' or event.text == 'P'): print(self.view) elif (event.text == 'd' or event.text == 'D'): self.translate[0] = 30. elif (event.text == 'a' or event.text == 'A'): self.translate[0] = -30. elif (event.text == 'w' or event.text == 'W'): self.translate[1] = 30. elif (event.text == 's' or event.text == 'S'): self.translate[1] = -30. elif (event.text == 'o' or event.text == 'O'): self.translate[2] = 30. elif (event.text == 'i' or event.text == 'I'): self.translate[2] = -30. elif (event.text == 'x'): self.rotate = [1, 0, 0] elif (event.text == 'X'): self.rotate = [-1, 0, 0] elif (event.text == 'y'): self.rotate = [0, 1, 0] elif (event.text == 'Y'): self.rotate = [0, -1, 0] elif (event.text == 'z'): self.rotate = [0, 0, 1] elif (event.text == 'Z'): self.rotate = [0, 0, -1] elif (event.text == 'h'): self.rotate = [0, 0, 0] elif (event.text == 'j'): self.rotate = [90, 0, 0] elif (event.text == 'k'): self.rotate = [180, 0, 0] elif (event.text == 'l'): self.rotate = [270, 0, 0] elif (event.text == ' '): self.view = self.default_view elif (event.text == '6'): self.lightx += 100. elif (event.text == '4'): self.lightx += -100. elif (event.text == '8'): self.lighty += 100. elif (event.text == '5'): self.lighty += -100. elif (event.text == '7'): self.lightz += 100. elif (event.text == '1'): self.lightz += -100. translate(self.view, -self.translate[0], -self.translate[1], -self.translate[2]) xrotate(self.view, self.rotate[0]) yrotate(self.view, self.rotate[1]) zrotate(self.view, self.rotate[2]) self.program[ "u_light_position"] = self.lightx, self.lighty, self.lightz self.program['u_view'] = self.view self.update()