peng3d/model.py
def setRotate(self,data):
        """
        Sets the OpenGL state required for proper drawing of the model.
        
        Mostly rotates and translates the camera.
        
        It is important to call :py:meth:`unsetRotate()` after calling this method to properly unset state and avoid OpenGL errors.
        """
        self.parent.setRotate(data)
        glPushMatrix()
        x,y = self.getRot(data)
        pivot = self.getPivotPoint(data)
        px,py,pz = pivot

        #ppx,ppy,ppz = self.parent.getPivotPoint(data)
        #rot_vec = px-ppx,py-ppy,pz-ppz
        #print([px,py,pz],[ppx,ppy,ppz],rot_vec,[x,y],self.getLength(data))
        #norm = v_normalize(rot_vec,self.name) if v_magnitude(rot_vec)==0 else [0,1,0] # prevents a zero divison error
        normx = [0,1,0] # currently fixed to the up vector, should be changed in the future for proper rotation that is not along the y or z axis
        normy = [0,0,1]
        
        #offset = -px,-py,-pz
        
        glTranslatef(px,py,pz)#-offset[0],-offset[1],-offset[2])
        glRotatef(x-self.start_rot[0], normx[0],normx[1],normx[2])
        glRotatef(y-self.start_rot[1], normy[0],normy[1],normy[2])
        glTranslatef(-px,-py,-pz)#offset[0],offset[1],offset[2])
def setRotate(self,data):
        """
        Sets the OpenGL state required for proper drawing of the model.
        
        Mostly rotates and translates the camera.
        
        It is important to call :py:meth:`unsetRotate()` after calling this method to properly unset state and avoid OpenGL errors.
        """
        self.parent.setRotate(data)
        glPushMatrix()
        x,y = self.getRot(data)
        pivot = self.getPivotPoint(data)
        px,py,pz = pivot

        #ppx,ppy,ppz = self.parent.getPivotPoint(data)
        #rot_vec = px-ppx,py-ppy,pz-ppz
        #print([px,py,pz],[ppx,ppy,ppz],rot_vec,[x,y],self.getLength(data))
        #norm = v_normalize(rot_vec,self.name) if v_magnitude(rot_vec)==0 else [0,1,0] # prevents a zero divison error
        normx = [0,1,0] # currently fixed to the up vector, should be changed in the future for proper rotation that is not along the y or z axis
        normy = [0,0,1]
        
        #offset = -px,-py,-pz
        
        glTranslatef(px,py,pz)#-offset[0],-offset[1],-offset[2])
        glRotatef(x-self.start_rot[0], normx[0],normx[1],normx[2])
        glRotatef(y-self.start_rot[1], normy[0],normy[1],normy[2])
        glTranslatef(-px,-py,-pz)#offset[0],offset[1],offset[2])
Sets the OpenGL state required for proper drawing of the model.
        
        Mostly rotates and translates the camera.
        
        It is important to call :py:meth:`unsetRotate()` after calling this method to properly unset state and avoid OpenGL errors.