コード例 #1
0
    def getBoundingBox(cls, dagPath):
        """ Calculates the world bounding box for the specified dag path and returns a
            BoundingBox3D instance populated with those values. """

        box = BoundingBox3D()
        box.fromExactWorldBoundingBox(cmds.exactWorldBoundingBox(dagPath))
        return box
コード例 #2
0
ファイル: TrackwayManager.py プロジェクト: sernst/Cadence
    def setCameraFocus(self, closeup =True):
        """ Center the current camera (CadenceCam or persp) on the currently
            selected node. If using the CadenceCam, the view is fitted to
            FIT_FACTOR; with the persp camera, it is not so contrained. """

        if closeup:

            # compute size (in cm)
            dimensions = cmds.exactWorldBoundingBox()
            if not dimensions:
                return
            dx = dimensions[3] - dimensions[0]
            dy = dimensions[4] - dimensions[1]
            dz = dimensions[5] - dimensions[2]
            size = max(dx, dy, dz)

            # make FitFactor such that a 100 CM object would fill 25% of screen
            fitFactor = 0.25*size/100.0
            cmds.viewFit(fitFactor=fitFactor, animate=True)

        else:
            cmds.viewLookAt(())
コード例 #3
0
    def _scaleItem(self, item):

        bbox = cmds.exactWorldBoundingBox(item)
        currentX = bbox[3] - bbox[0]
        currentY = bbox[4] - bbox[1]
        currentZ = bbox[5] - bbox[2]

        scale = float('inf')
        if self.x is not None:
            scale = min(scale, float(self.x)/float(currentX))
        if self.y is not None:
            scale = min(scale, float(self.y)/float(currentY))
        if self.z is not None:
            scale = min(scale, float(self.z)/float(currentZ))

        if not self.grow:
            scale = min(scale, 1.0)

        if scale == 1.0:
            return None

        cmds.scale(scale, scale, scale, item, relative=True)
        return scale
コード例 #4
0
    def _scaleItem(self, item):

        bbox = cmds.exactWorldBoundingBox(item)
        currentX = bbox[3] - bbox[0]
        currentY = bbox[4] - bbox[1]
        currentZ = bbox[5] - bbox[2]

        scale = float('inf')
        if self.x is not None:
            scale = min(scale, float(self.x) / float(currentX))
        if self.y is not None:
            scale = min(scale, float(self.y) / float(currentY))
        if self.z is not None:
            scale = min(scale, float(self.z) / float(currentZ))

        if not self.grow:
            scale = min(scale, 1.0)

        if scale == 1.0:
            return None

        cmds.scale(scale, scale, scale, item, relative=True)
        return scale