コード例 #1
0
ファイル: spore_context.py プロジェクト: tws0002/spore
    def __init__(self):
        ompx.MPxToolCommand.__init__(self)
        self.setCommandString(K_TOOL_CMD_NAME)
        K_TRACKING_DICTIONARY[ompx.asHashable(self)] = self

        self.brush_state = None
        self.instance_data = None
        self.last_brush_position = None

        self.last_undo_journal = ''

        self.position = om.MVectorArray()
        self.scale = om.MVectorArray()
        self.rotation = om.MVectorArray()
        self.instance_id = om.MIntArray()
        self.visibility = om.MIntArray()
        self.normal = om.MVectorArray()
        self.tangent = om.MVectorArray()
        self.u_coord = om.MDoubleArray()
        self.v_coord = om.MDoubleArray()
        self.poly_id = om.MIntArray()
        self.color = om.MVectorArray()
        self.point_id = om.MIntArray()

        self.initial_rotation = om.MVectorArray()
        self.initial_scale = om.MVectorArray()
        self.initial_offset = om.MDoubleArray()
        self.initial_id = om.MIntArray()
        self.spray_coords = []
コード例 #2
0
    def __init__(self):

        OpenMayaMPx.MPxData.__init__(self)

        self.__fValue = 0.0

        fValueDictionary[OpenMayaMPx.asHashable(self)] = self.__fValue
コード例 #3
0
    def readBinary(self, inStream, numBytesToRead):
        """Read in 4 byte packs to cStringIO, unpickle from there
		
		:note: this method is more complicated than it needs be since asCharPtr does not work !
			It returns a string of a single char ... which is not the same :) !
		:note: YES, this is a CUMBERSOME way to deal with bytes ... terrible, thanks maya :), thanks python"""
        sio = cStringIO.StringIO()
        scriptutil = api.MScriptUtil()
        scriptutil.createFromInt(0)
        intptr = scriptutil.asIntPtr()

        # require multiple of 4 !
        if numBytesToRead % 4 != 0:
            raise AssertionError(
                "Require multiple of for for number of bytes to be read, but is %i"
                % numBytesToRead)

        bitmask = 255  # mask the lower 8 bit
        shiftlist = [0, 8, 16, 24]  # used to shift bits by respective values
        for i in xrange(numBytesToRead / 4):
            api.MStreamUtils.readInt(inStream, intptr, True)
            intval = scriptutil.getInt(intptr)

            # convert to chars - endianess should be taken care of by python
            for shift in shiftlist:
                sio.write(chr((intval >> shift) & bitmask))
            # END for each byte
        # END for all 4 bytes to read

        self.__data = cPickle.loads(binascii.a2b_base64(sio.getvalue()))
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #4
0
ファイル: persistence.py プロジェクト: mrv-developers/mrv
    def readBinary(self, inStream, numBytesToRead):
        """Read in 4 byte packs to cStringIO, unpickle from there
        
        :note: this method is more complicated than it needs be since asCharPtr does not work !
            It returns a string of a single char ... which is not the same :) !
        :note: YES, this is a CUMBERSOME way to deal with bytes ... terrible, thanks maya :), thanks python"""
        sio = cStringIO.StringIO()
        scriptutil = api.MScriptUtil()
        scriptutil.createFromInt(0)
        intptr = scriptutil.asIntPtr()

        # require multiple of 4 !
        if numBytesToRead % 4 != 0:
            raise AssertionError("Require multiple of for for number of bytes to be read, but is %i" % numBytesToRead)

        bitmask = 255                               # mask the lower 8 bit
        shiftlist = [0, 8, 16, 24]              # used to shift bits by respective values
        for i in xrange(numBytesToRead  / 4):
            api.MStreamUtils.readInt(inStream, intptr, True)
            intval = scriptutil.getInt(intptr)

            # convert to chars - endianess should be taken care of by python
            for shift in shiftlist:
                sio.write(chr((intval >> shift) & bitmask))
            # END for each byte
        # END for all 4 bytes to read

        self.__data = cPickle.loads(binascii.a2b_base64(sio.getvalue()))
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #5
0
    def copy(self, other):

        # Cannot convert other to self.  Use a dictionary

        # to hold the information we need.

        self.__fValue = fValueDictionary[OpenMayaMPx.asHashable(other)]
コード例 #6
0
ファイル: moveTool.py プロジェクト: JIuBeP/xray-1.5.10-2015-
    def __init__(self):

        OpenMayaMPx.MPxToolCommand.__init__(self)

        self.setCommandString(kPluginCmdName)

        self.__delta = OpenMaya.MVector()

        kTrackingDictionary[OpenMayaMPx.asHashable(self)] = self
コード例 #7
0
	def readASCII(self, args, lastParsedElement):
		try:
			if args.length() > 0:
				parsedIndex = OpenMaya.MScriptUtil.getUint(lastParsedElement)
				self.__fValue = args.asDouble( parsedIndex )
				parsedIndex += 1
				OpenMaya.MScriptUtil.setUint(lastParsedElement,parsedIndex)
				fValueDictionary[OpenMayaMPx.asHashable(self)]=self.__fValue
		except:
			sys.stderr.write("Failed to read ASCII value.")
			raise
コード例 #8
0
ファイル: persistence.py プロジェクト: mrv-developers/mrv
    def readASCII(self, args, lastParsedElement):
        """Read base64 element and decode to cStringIO, then unpickle"""
        parsedIndex = api.MScriptUtil.getUint(lastParsedElement)
        base64encodedstring = args.asString(parsedIndex)
        self.__data = cPickle.loads(binascii.a2b_base64(base64encodedstring))

        parsedIndex += 1
        api.MScriptUtil.setUint(lastParsedElement,parsedIndex)  # proceed the index

        # update tracking dict
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #9
0
    def readASCII(self, args, lastParsedElement):
        """Read base64 element and decode to cStringIO, then unpickle"""
        parsedIndex = api.MScriptUtil.getUint(lastParsedElement)
        base64encodedstring = args.asString(parsedIndex)
        self.__data = cPickle.loads(binascii.a2b_base64(base64encodedstring))

        parsedIndex += 1
        api.MScriptUtil.setUint(lastParsedElement,
                                parsedIndex)  # proceed the index

        # update tracking dict
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #10
0
ファイル: persistence.py プロジェクト: mrv-developers/mrv
 def __del__(self):
     """Remove ourselves from the dictionary to prevent flooding
     
     :note: we can be called even if maya is already unloaded or shutting down"""
     if mpx.asHashable is not None:
         del(sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)])
     # call super just to be on the safe side in future, currently it appears
     # not to be required
     try:
         super(PyPickleData, self).__del__()
     except AttributeError:
         # Maya 2008 and following do not require this anymore as they
         # do not have a del method implemented apparently
         pass
コード例 #11
0
    def __del__(self):
        """Remove ourselves from the dictionary to prevent flooding
		
		:note: we can be called even if maya is already unloaded or shutting down"""
        if mpx.asHashable is not None:
            del (sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)])
        # call super just to be on the safe side in future, currently it appears
        # not to be required
        try:
            super(PyPickleData, self).__del__()
        except AttributeError:
            # Maya 2008 and following do not require this anymore as they
            # do not have a del method implemented apparently
            pass
コード例 #12
0
	def doEditFlags(self):
		theParser = self._parser()
		theControl = kPythonPtrTable.get(OpenMayaMPx.asHashable(self._control()), None)

		if theParser.isFlagSet(kNopFlag):
			theControl.setOperation(kNop)
		elif theParser.isFlagSet(kMultFlag):
			theControl.setOperation(kMult)
		elif theParser.isFlagSet(kAddFlag):
			theControl.setOperation(kAdd)
		elif theParser.isFlagSet(kRedrawFlag):
			theControl.redrawCells()
			theControl.redrawLabels()
		else:
			OpenMayaMPx.MPxControlCommand.doEditFlags(self)
コード例 #13
0
    def doEditFlags(self):
        theParser = self._parser()
        theControl = kPythonPtrTable.get(
            OpenMayaMPx.asHashable(self._control()), None)

        if theParser.isFlagSet(kNopFlag):
            theControl.setOperation(kNop)
        elif theParser.isFlagSet(kMultFlag):
            theControl.setOperation(kMult)
        elif theParser.isFlagSet(kAddFlag):
            theControl.setOperation(kAdd)
        elif theParser.isFlagSet(kRedrawFlag):
            theControl.redrawCells()
            theControl.redrawLabels()
        else:
            OpenMayaMPx.MPxControlCommand.doEditFlags(self)
コード例 #14
0
    def doPress(self, event):
        OpenMayaMPx.MPxSelectionContext.doPress(self, event)
        spc = OpenMaya.MSpace.kWorld

        # If we are not in selecting mode (i.e. an object has been selected)
        # then set up for the translation.
        #
        if not self._isSelecting():
            argX = OpenMaya.MScriptUtil()
            argX.createFromInt(0)
            argXPtr = argX.asShortPtr()
            argY = OpenMaya.MScriptUtil()
            argY.createFromInt(0)
            argYPtr = argY.asShortPtr()
            event.getPosition(argXPtr, argYPtr)
            self.__startPos_x = OpenMaya.MScriptUtil(argXPtr).asShort()
            self.__startPos_y = OpenMaya.MScriptUtil(argYPtr).asShort()
            self.__view = OpenMayaUI.M3dView.active3dView()

            camera = OpenMaya.MDagPath()
            self.__view.getCamera(camera)
            fnCamera = OpenMaya.MFnCamera(camera)
            upDir = fnCamera.upDirection(spc)
            rightDir = fnCamera.rightDirection(spc)

            # Determine the camera used in the current view
            #
            if fnCamera.isOrtho():
                if upDir.isEquivalent(OpenMaya.MVector.zNegAxis,
                                      kVectorEpsilon):
                    self.__currWin = MoveContext.kTop
                elif rightDir.isEquivalent(OpenMaya.MVector.xAxis,
                                           kVectorEpsilon):
                    self.__currWin = MoveContext.kFront
                else:
                    self.__currWin = MoveContext.kSide
            else:
                self.__currWin = MoveContext.kPersp

            # Create an instance of the move tool command.
            #
            newCmd = self._newToolCommand()
            self.__cmd = kTrackingDictionary.get(
                OpenMayaMPx.asHashable(newCmd), None)
            self.__cmd.setVector(0.0, 0.0, 0.0)
コード例 #15
0
ファイル: moveTool.py プロジェクト: DimondTheCat/xray
	def doPress(self, event):
		OpenMayaMPx.MPxSelectionContext.doPress(self, event)
		spc = OpenMaya.MSpace.kWorld

		# If we are not in selecting mode (i.e. an object has been selected)
		# then set up for the translation.
		#
		if not self._isSelecting():
			argX = OpenMaya.MScriptUtil()
			argX.createFromInt(0)
			argXPtr = argX.asShortPtr()
			argY = OpenMaya.MScriptUtil()
			argY.createFromInt(0)
			argYPtr = argY.asShortPtr()
			event.getPosition(argXPtr, argYPtr)
			self.__startPos_x = OpenMaya.MScriptUtil(argXPtr).asShort()
			self.__startPos_y = OpenMaya.MScriptUtil(argYPtr).asShort()
			self.__view = OpenMayaUI.M3dView.active3dView()

			camera = OpenMaya.MDagPath()
			self.__view.getCamera(camera)
			fnCamera = OpenMaya.MFnCamera(camera)
			upDir = fnCamera.upDirection(spc)
			rightDir = fnCamera.rightDirection(spc)

			# Determine the camera used in the current view
			#
			if fnCamera.isOrtho():
				if upDir.isEquivalent(OpenMaya.MVector.zNegAxis, kVectorEpsilon):
					self.__currWin = MoveContext.kTop
				elif rightDir.isEquivalent(OpenMaya.MVector.xAxis, kVectorEpsilon):
					self.__currWin = MoveContext.kFront
				else:
					self.__currWin = MoveContext.kSide
			else:
				self.__currWin = MoveContext.kPersp

			# Create an instance of the move tool command.
			#
			newCmd = self._newToolCommand()
			self.__cmd = kTrackingDictionary.get(OpenMayaMPx.asHashable(newCmd), None)
			self.__cmd.setVector(0.0, 0.0, 0.0)
コード例 #16
0
	def __del__(self):
		del kPythonPtrTable[OpenMayaMPx.asHashable(self)]
コード例 #17
0
	def __init__(self, command):
		OpenMayaMPx.MPxUITableControl.__init__(self, command)
		self.__myOperation = None
		kPythonPtrTable[OpenMayaMPx.asHashable(self)] = self
コード例 #18
0
ファイル: persistence.py プロジェクト: mrv-developers/mrv
 def copy(self, other):
     """Copy other into self - allows copy pointers as maya copies the data each
     time you retrieve it"""
     otherdata = sys._maya_pyPickleData_trackingDict[mpx.asHashable(other)]
     self.__data = otherdata
     sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #19
0
ファイル: spore_context.py プロジェクト: tws0002/spore
 def __del__(self):
     try:
         del K_TRACKING_DICTIONARY[ompx.asHashable(self)]
     except KeyError:
         pass
コード例 #20
0
 def __del__(self):
     del kTrackingDictionary[OpenMayaMPx.asHashable(self)]
コード例 #21
0
 def getRockingTransformationMatrix(self):
     baseXform = self.transformationMatrixPtr()
     return kTrackingDictionary[OpenMayaMPx.asHashable(baseXform)]
コード例 #22
0
 def __init__(self):
     OpenMayaMPx.MPxTransformationMatrix.__init__(self)
     kTrackingDictionary[OpenMayaMPx.asHashable(self)] = self
     self.rockXValue = 0.0
コード例 #23
0
 def __init__(self):
     mpx.MPxData.__init__(self)
     self.__data = dict()
     sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #24
0
 def __del__(self):
     del kTrackingDictionary[ompx.asHashable(self)]
コード例 #25
0
 def __init__(self):
     ompx.MPxTransformationMatrix.__init__(self)
     kTrackingDictionary[ompx.asHashable(self)] = self
     self.pivotX = 0.0
     self.pivotY = 0.0
     self.pivotZ = 0.0
コード例 #26
0
 def getPivotTransformationMatrix(self):
     baseXform = self.transformationMatrixPtr()
     return kTrackingDictionary[ompx.asHashable(baseXform)]
コード例 #27
0
ファイル: spore_context.py プロジェクト: tws0002/spore
    def create_tool_command(self):
        """ create a new instance of the command associated with the context """

        tool_cmd = self._newToolCommand()
        self.tool_cmd = K_TRACKING_DICTIONARY.get(ompx.asHashable(tool_cmd))
        self.tool_cmd.initialize_tool_cmd(self.state, self.instance_data)
コード例 #28
0
 def getRockingTransformationMatrix(self):
     baseXform = self.transformationMatrixPtr()
     return kTrackingDictionary[OpenMayaMPx.asHashable(baseXform)]
コード例 #29
0
ファイル: persistence.py プロジェクト: mrv-developers/mrv
 def __init__(self):
     mpx.MPxData.__init__(self)
     self.__data = dict()
     sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #30
0
 def __del__(self):
     del kTrackingDictionary[OpenMayaMPx.asHashable(self)]
コード例 #31
0
 def __del__(self):
     del kPythonPtrTable[OpenMayaMPx.asHashable(self)]
コード例 #32
0
 def __init__(self):
     OpenMayaMPx.MPxTransformationMatrix.__init__(self)
     kTrackingDictionary[OpenMayaMPx.asHashable(self)] = self
     self.rockXValue = 0.0
コード例 #33
0
    def copy(self, other):
        """Copy other into self - allows copy pointers as maya copies the data each
		time you retrieve it"""
        otherdata = sys._maya_pyPickleData_trackingDict[mpx.asHashable(other)]
        self.__data = otherdata
        sys._maya_pyPickleData_trackingDict[mpx.asHashable(self)] = self.__data
コード例 #34
0
	def __init__(self):
		OpenMayaMPx.MPxData.__init__(self)
		self.__fValue = 0.0
		fValueDictionary[OpenMayaMPx.asHashable(self)]=self.__fValue
コード例 #35
0
 def __init__(self, command):
     OpenMayaMPx.MPxUITableControl.__init__(self, command)
     self.__myOperation = None
     kPythonPtrTable[OpenMayaMPx.asHashable(self)] = self
コード例 #36
0
	def copy(self, other):
		# Cannot convert other to self.  Use a dictionary
		# to hold the information we need.
		self.__fValue = fValueDictionary[OpenMayaMPx.asHashable(other)]
コード例 #37
0
ファイル: moveTool.py プロジェクト: DimondTheCat/xray
	def __init__(self):
		OpenMayaMPx.MPxToolCommand.__init__(self)
		self.setCommandString(kPluginCmdName)
		self.__delta = OpenMaya.MVector()
		kTrackingDictionary[OpenMayaMPx.asHashable(self)] = self