Exemple #1
0
 def update(self, px, py, uq = None):
     """
     This should be called in a mouseDrag binding, with window coordinates of the mouse;
     return value is an incremental quat, to be used in conjunction with uq as explained below.
        For trackballing the entire model space (whose orientation is stored in (for example) glpane.quat),
     caller should not pass uq, and should increment glpane.quat by the return value (i.e. glpane.quat += retval).
        For trackballing an object with orientation obj.quat, drawn subject to (for example) glpane.quat,
     caller should pass uq = glpane.quat, and should increment obj.quat by the return value.
     (If caller didn't pass uq in that case, our retval would be suitable for incrementing obj.quat + glpane.quat,
      or glpane.quat alone, but this is not the same as a retval suitable for incrementing obj.quat alone.)
     """
     #bruce 060514 revised this code (should be equivalent to the prior code), added docstring
     #ninad 060906 added 'rotation sensitivity to this formula. the rotation sensitivity will be used
     #while middle drag rotating the model. By default a lower value is set for this and can be adjusted
     #via a user preference. This helps mitigate bug 1856
     newmouse = proj2sphere((px - self.w2) * self.scale * self.mouseSpeedDuringRotation,
                            (self.h2 - py) * self.scale * self.mouseSpeedDuringRotation)
     if self.oldmouse is not None:
         quat = Q(self.oldmouse, newmouse)
         if uq is not None:
             quat = uq + quat - uq
     else:
         print "warning: trackball.update sees oldmouse is None (should not happen)" #bruce 060514
         quat = Q(1,0,0,0)
     self.oldmouse = newmouse
     return quat
Exemple #2
0
    def start(self, px, py):
        """
        This should be called in a mouseDown binding, with window coordinates of the mouse.
        """
        # ninad060906 initializing the factor 'mouse speed during rotation'
        # here instead of init so that it will come into effect immediately
        self.mouseSpeedDuringRotation = \
            env.prefs[ mouseSpeedDuringRotation_prefs_key]

        self.oldmouse = proj2sphere( (px - self.w2) * self.scale * self.mouseSpeedDuringRotation,
                                     (self.h2 - py) * self.scale * self.mouseSpeedDuringRotation )