def translate(self, trans): # translate the object self.makeCurrent() glMatrixMode(GL_MODELVIEW) glLoadIdentity() glTranslated(trans[0], trans[1], trans[2]) glMultMatrixd(self._modelview_matrix) # update _modelview_matrix self._modelview_matrix = glGetDoublev(GL_MODELVIEW_MATRIX)
def rotate(self, axis, angle): # rotate the object self.makeCurrent() glMatrixMode(GL_MODELVIEW) glLoadIdentity() t = [self._modelview_matrix[3][0], self._modelview_matrix[3][1], self._modelview_matrix[3][2]] glTranslatef(t[0], t[1], t[2]) glRotated(angle, axis[0], axis[1], axis[2]) glTranslatef(-t[0], -t[1], -t[2]) glMultMatrixd(self._modelview_matrix) # update _modelview_matrix self._modelview_matrix = glGetDoublev(GL_MODELVIEW_MATRIX)
def multiply_hardware(self) : ''' multiply the current matrix instance with the, display, MODELVIEW matrix. ''' glMatrixMode(GL_MODELVIEW) glMultMatrixd(self.main_matrix)