def editToolTask(self, task, transX, transY, rotX, rotY, scaleX, scaleY):
        ''' task in which the edittool is active and modifying the model
    '''
        if task.frame:  # dont run on first frame (mouse is not centered yet)
            #print "editToolTask", transX, transY, rotX, rotY, scaleX, scaleY
            mx, my = mouseHandler.getMousePos()
            dt = 0.1  #globalClock.getDt() * 10
            dPosX = transX * mx * dt * 250
            dPosY = transY * my * dt * 250
            dRotX = rotX * mx * dt * 250
            dRotY = rotY * my * dt * 250
            dScaleX = scaleX * mx * dt
            dScaleY = scaleY * my * dt

            self.__modificationNode.setPos(self.__modificationNode, dPosX)
            self.__modificationNode.setPos(self.__modificationNode, dPosY)
            self.__modificationNode.setHpr(self.__modificationNode, dRotX)
            self.__modificationNode.setHpr(self.__modificationNode, dRotY)
            self.__modificationNode.setScale(
                self.__modificationNode.getScale() + dScaleX)
            self.__modificationNode.setScale(
                self.__modificationNode.getScale() + dScaleY)

            # send event that the object has been modified
            messenger.send(EVENT_MODELCONTROLLER_FAST_REFRESH)

            self.objectAxisCube.setScale(
                self.__modificationNode.getPos(render))
        return task.cont
 def editToolTask(self, task, transX, transY, rotX, rotY, scaleX, scaleY):
   ''' task in which the edittool is active and modifying the model
   '''
   if task.frame: # dont run on first frame (mouse is not centered yet)
     #print "editToolTask", transX, transY, rotX, rotY, scaleX, scaleY
     mx,my = mouseHandler.getMousePos()
     dt = 0.1 #globalClock.getDt() * 10
     dPosX   = transX * mx * dt * 250
     dPosY   = transY * my * dt * 250
     dRotX   = rotX   * mx * dt * 250
     dRotY   = rotY   * my * dt * 250
     dScaleX = scaleX * mx * dt
     dScaleY = scaleY * my * dt
     
     self.__modificationNode.setPos(self.__modificationNode, dPosX)
     self.__modificationNode.setPos(self.__modificationNode, dPosY)
     self.__modificationNode.setHpr(self.__modificationNode, dRotX)
     self.__modificationNode.setHpr(self.__modificationNode, dRotY)
     self.__modificationNode.setScale(self.__modificationNode.getScale() + dScaleX)
     self.__modificationNode.setScale(self.__modificationNode.getScale() + dScaleY)
     
     # send event that the object has been modified
     messenger.send(EVENT_MODELCONTROLLER_FAST_REFRESH)
     
     self.objectAxisCube.setScale(self.__modificationNode.getPos(render))
   return task.cont
Ejemplo n.º 3
0
 def updatePickerRay(self):
   mx,my = mouseHandler.getMousePos()
   if WindowManager.getDefaultCamera() != None:
     self.editorPickerRay.setFromLens(WindowManager.getDefaultCamera().node(), mx, my)
   else:
     pass # How to unset it?
   return True
Ejemplo n.º 4
0
 def updatePickerRay(self):
     mx, my = mouseHandler.getMousePos()
     if WindowManager.getDefaultCamera() != None:
         self.editorPickerRay.setFromLens(
             WindowManager.getDefaultCamera().node(), mx, my)
     else:
         pass  # How to unset it?
     return True
 def taskMouseButton2Pressed( self, task ):
   # this is needed because the task might be called once more after the exit
   # function has been called
   # also skip first frame
   mx,my = mouseHandler.getMousePos()
   if self.taskMouseButton2PressedRunning and task.frame:
     curHpr = self.cameraRotPivot.getHpr()
     newHpr = curHpr + Vec3(mx,-my,0) * MOUSE_ROTATION_SPEED #* globalClock.getDt()
     newHpr.setY( min( 90, max( -90, newHpr.getY() ) ) )
     self.cameraRotPivot.setHpr( newHpr )
   return task.cont
 def taskMouseButton2Pressed(self, task):
     # this is needed because the task might be called once more after the exit
     # function has been called
     # also skip first frame
     mx, my = mouseHandler.getMousePos()
     if self.taskMouseButton2PressedRunning and task.frame:
         curHpr = self.cameraRotPivot.getHpr()
         newHpr = curHpr + Vec3(
             mx, -my, 0) * MOUSE_ROTATION_SPEED  #* globalClock.getDt()
         newHpr.setY(min(90, max(-90, newHpr.getY())))
         self.cameraRotPivot.setHpr(newHpr)
     return task.cont
 def taskMouseButton3Pressed( self, task ):
   # this is needed because the task might be called once more after the exit
   # function has been called
   # also skip first frame
   mx,my = mouseHandler.getMousePos()
   if self.taskMouseButton3PressedRunning and task.frame:
     diffPos = WindowManager.getDefaultCamera().getPos( render ) - self.cameraPosPivot.getPos( render )
     diffPos.normalize()
     self.cameraPosPivot.setX( self.cameraPosPivot.getX() \
                             - mx * diffPos.getY() * MOUSE_MOVEMENT_SPEED
                             - my * diffPos.getX() * MOUSE_MOVEMENT_SPEED )
     self.cameraPosPivot.setY( self.cameraPosPivot.getY() \
                             - my * diffPos.getY() * MOUSE_MOVEMENT_SPEED
                             + mx * diffPos.getX() * MOUSE_MOVEMENT_SPEED )
   return task.cont
 def taskMouseButton3Pressed(self, task):
     # this is needed because the task might be called once more after the exit
     # function has been called
     # also skip first frame
     mx, my = mouseHandler.getMousePos()
     if self.taskMouseButton3PressedRunning and task.frame:
         diffPos = WindowManager.getDefaultCamera().getPos(
             render) - self.cameraPosPivot.getPos(render)
         diffPos.normalize()
         self.cameraPosPivot.setX( self.cameraPosPivot.getX() \
                                 - mx * diffPos.getY() * MOUSE_MOVEMENT_SPEED
                                 - my * diffPos.getX() * MOUSE_MOVEMENT_SPEED )
         self.cameraPosPivot.setY( self.cameraPosPivot.getY() \
                                 - my * diffPos.getY() * MOUSE_MOVEMENT_SPEED
                                 + mx * diffPos.getX() * MOUSE_MOVEMENT_SPEED )
     return task.cont