def update(self): """ Update the camera position, focal point and yup vector """ vsml.loadIdentity(vsml.MatrixTypes.MODELVIEW) x, y, z = self.location a, b, c = self.focal u, v, w = self.get_yup() vsml.lookAt(x, y, z, a, b, c, u, v, w)
def ortho_zoom(self, zoom_level = 1.0): if not self.ortho: print('Not on orthogonal projection mode') return vsml.loadIdentity(vsml.MatrixTypes.PROJECTION) ratio = abs(self.width * 1.0 / self.height) self.width_ortho = self.width * zoom_level * ratio self.height_ortho = self.width * zoom_level vsml.ortho(-(self.width_ortho)/2.,(self.width_ortho)/2., (self.height_ortho)/2.,(self.height_ortho)/-2.,-500,8000) glMatrixMode(GL_PROJECTION) glLoadMatrixf(vsml.get_projection()) glMatrixMode(GL_MODELVIEW)
def update_projection(self, factor = 1.0): vsml.loadIdentity(vsml.MatrixTypes.PROJECTION) ratio = abs(self.width * 1.0 / self.height) if self.ortho: self.width_ortho += -factor * ratio self.height_ortho += -factor vsml.ortho(-(self.width_ortho)/2.,(self.width_ortho)/2., (self.height_ortho)/2.,(self.height_ortho)/-2.,-500,8000) else: vsml.perspective(60., ratio, .1, 8000) glMatrixMode(GL_PROJECTION) glLoadMatrixf(vsml.get_projection()) glMatrixMode(GL_MODELVIEW)
def reset(self): # load identity for modelview when initializing vsml.loadIdentity(vsml.MatrixTypes.MODELVIEW)