def setModelerCameraTransform(self, cameraTransform):
     self.__modelerCameraTransform = cameraTransform
     if self._cameraControlMode == CameraControlMode.MODELER:
         cameraTransformInv = cgmath.Mat44(cameraTransform)
         cameraTransformInv.inverse()
         angles = cameraTransformInv.eulerXYZ()
         self.__data = CameraTransform(cameraTransform[12],
                                       cameraTransform[13],
                                       cameraTransform[14], -angles[0],
                                       angles[1], -angles[2])
         self.cameraChanged.emit()
Exemple #2
0
    def __init__(self, animator, animationEditor, timer):
        super(Camera, self).__init__()
        self.setLayout(hlayout())

        self.__enabled = QPushButton('')
        self.__enabled.clicked.connect(self.toggle)
        self.__enabled.setFlat(True)
        self.layout().addWidget(self.__enabled)
        self.__cameraControlActive = True  # the toggle call will make this the opposite
        self.toggle()
        self.__enabled.setIconSize(QSize(24, 24))

        timer.timeChanged.connect(self.__copyAnim)
        copyAnim = QPushButton(QIcon(icons.get('Film-Refresh-48')), '')
        copyAnim.setToolTip('Copy anim')
        copyAnim.setStatusTip('Copy anim')
        self.__animator = animator
        self.__animationEditor = animationEditor
        self._timer = timer
        copyAnim.clicked.connect(self.copyAnim)
        self.layout().addWidget(copyAnim)
        copyAnim.setIconSize(QSize(24, 24))

        self.__keyStates = {Qt.Key_Shift: False, Qt.Key_Control: False}
        for key in Camera.MOVE_LUT:
            self.__keyStates[key] = False
        for key in Camera.TURN_LUT:
            self.__keyStates[key] = False
        self.__data = CameraTransform()
        self.__inputs = []
        for i, value in enumerate(self.__data):
            s = DoubleSpinBox(value)
            s.setMinimumWidth(50)
            self.__inputs.append(s)
            if i in (3, 4, 5):
                s.setSingleStep(5)
            self.layout().addWidget(s)
            s.valueChanged.connect(functools.partial(self.__setData, i))
        self.__prevTime = None
        self.__appLoop = QTimer()
        self.__appLoop.timeout.connect(self.flyUpdate)
        self.__appLoop.start(1.0 / 15.0)
        self.__drag = None
        self.__dirty = False
    def __init__(self, animator, animationEditor, timer):
        super(Camera, self).__init__()
        self.setLayout(hlayout())

        self._freeCameraControlButton = QPushButton(
            icons.get('icons8-video-camera-50'), '')
        self._freeCameraControlButton.clicked.connect(
            self._setFreeCameraControl)
        self._freeCameraControlButton.setCheckable(True)
        self._freeCameraControlButton.setIconSize(QSize(24, 24))
        self._freeCameraControlButton.setToolTip("Free")
        self._animationCameraControlButton = QPushButton(
            icons.get('icons8-line-chart-50'), '')
        self._animationCameraControlButton.clicked.connect(
            self._setAnimationCameraControl)
        self._animationCameraControlButton.setCheckable(True)
        self._animationCameraControlButton.setIconSize(QSize(24, 24))
        self._animationCameraControlButton.setToolTip("Animation curves")
        self._modelerCameraControlButton = QPushButton(
            icons.get('icons8-grid-50'), '')
        self._modelerCameraControlButton.clicked.connect(
            self._setModelerCameraControl)
        self._modelerCameraControlButton.setCheckable(True)
        self._modelerCameraControlButton.setIconSize(QSize(24, 24))
        self._modelerCameraControlButton.setToolTip("Modeler viewport")

        self.layout().addWidget(self._freeCameraControlButton)
        self.layout().addWidget(self._animationCameraControlButton)
        self.layout().addWidget(self._modelerCameraControlButton)
        self.layout().addSpacing(24)

        self._cameraControlMode = CameraControlMode.FREE
        self.toggleBetweenFreeAndAnimation()

        timer.timeChanged.connect(self.__copyAnim)
        copyAnim = QPushButton(QIcon(icons.get('Film-Refresh-48')), '')
        copyAnim.setToolTip('Copy anim')
        copyAnim.setStatusTip('Copy anim')
        self.__animator = animator
        self.__animationEditor = animationEditor
        self._timer = timer
        copyAnim.clicked.connect(self.copyAnim)
        self.layout().addWidget(copyAnim)
        copyAnim.setIconSize(QSize(24, 24))

        self.__keyStates = {Qt.Key_Shift: False, Qt.Key_Control: False}
        for key in Camera.MOVE_LUT:
            self.__keyStates[key] = False
        for key in Camera.TURN_LUT:
            self.__keyStates[key] = False
        self.__data = CameraTransform()
        self.__modelerCameraTransform = cgmath.Mat44()
        self.__inputs = []
        for i, value in enumerate(self.__data):
            s = DoubleSpinBox(value)
            s.setMinimumWidth(50)
            self.__inputs.append(s)
            if i in (3, 4, 5):
                s.setSingleStep(5)
            self.layout().addWidget(s)
            s.valueChanged.connect(functools.partial(self.__setData, i))
        self.__prevTime = None
        self.__appLoop = QTimer()
        self.__appLoop.timeout.connect(self.flyUpdate)
        self.__appLoop.start(1.0 / 15.0)
        self.__drag = None
        self.__dirty = False
 def setCamera(self, data):
     self.__data = CameraTransform(*data)
 def setData(self, *args):
     self.__data = CameraTransform(*args)
 def copyAnim(self):
     data = self.__animator.evaluate(self._timer.time)
     if 'uOrigin' not in data or 'uAngles' not in data:
         return
     self.__data = CameraTransform(*(data['uOrigin'] + data['uAngles']))
     self.cameraChanged.emit()