Exemplo n.º 1
0
	def applyToObj( self, obj, applyAsWorld=False ):
		'''applies the current clip to an object - if the animation is being applied as world space, first check to make
		sure the world space animation for the clip exists.  then separate the transform channels out of the channels list
		and apply them as world space data.  then we need to apply the rest of the channels as per normal'''
		transformChannels = []
		nonTransformChannels = []
		for channel in self.channels:
			if channel.attr in g_validWorldAttrs: transformChannels.append(channel)
			else: nonTransformChannels.append(channel)

		if applyAsWorld and self.hasWorld:
			'''NOT DONE YET'''
			frames = self.as_frames(transformChannels)
			for channel in transformChannels:
				tgtAttrpath = obj +'.'+ channel.attr
				channel.applyToObj(obj,applyAsWorld)

			#run a euler filter over the resulting rotation animation - converting to world space
			#rotations often causes all sorts of nasty euler flips
			mel('filterCurve %s.rx %s.ry %s.rz;'%(obj,obj,obj))
		else:
			for channel in transformChannels:
				channel.applyToObj(obj)
			
		for channel in nonTransformChannels:
			channel.applyToObj(obj)
Exemplo n.º 2
0
    def applyToObj(self, obj, applyAsWorld=False):
        '''applies the current clip to an object - if the animation is being applied as world space, first check to make
		sure the world space animation for the clip exists.  then separate the transform channels out of the channels list
		and apply them as world space data.  then we need to apply the rest of the channels as per normal'''
        transformChannels = []
        nonTransformChannels = []
        for channel in self.channels:
            if channel.attr in g_validWorldAttrs:
                transformChannels.append(channel)
            else:
                nonTransformChannels.append(channel)

        if applyAsWorld and self.hasWorld:
            '''NOT DONE YET'''
            frames = self.as_frames(transformChannels)
            for channel in transformChannels:
                tgtAttrpath = obj + '.' + channel.attr
                channel.applyToObj(obj, applyAsWorld)

            #run a euler filter over the resulting rotation animation - converting to world space
            #rotations often causes all sorts of nasty euler flips
            mel('filterCurve %s.rx %s.ry %s.rz;' % (obj, obj, obj))
        else:
            for channel in transformChannels:
                channel.applyToObj(obj)

        for channel in nonTransformChannels:
            channel.applyToObj(obj)
Exemplo n.º 3
0
	def __init__(self,clip):
		keys = clip.listKeysInOrder()
		transformKeys = [key for key in keys if key.attr in g_validWorldAttrs]
		worldKeys = []

		prevTime = transformKeys[0].time
		cmd.currentTime(prevTime)
		mel('zooAllViews 0;')

		for key in transformKeys:
			#make sure the time is set to that of the current key
			if prevTime != key.time:
				cmd.currentTime(key.time)
				prevTime = key.time

			xyz = cmd.xform(key.obj,query=True,worldSpace=True,rotatePivot=True)

		mel('zooAllViews 1;')

		self.t = (tx,ty,tz)
		self.r = (rx,ry,rz)
Exemplo n.º 4
0
    def __init__(self, clip):
        keys = clip.listKeysInOrder()
        transformKeys = [key for key in keys if key.attr in g_validWorldAttrs]
        worldKeys = []

        prevTime = transformKeys[0].time
        cmd.currentTime(prevTime)
        mel('zooAllViews 0;')

        for key in transformKeys:
            #make sure the time is set to that of the current key
            if prevTime != key.time:
                cmd.currentTime(key.time)
                prevTime = key.time

            xyz = cmd.xform(key.obj,
                            query=True,
                            worldSpace=True,
                            rotatePivot=True)

        mel('zooAllViews 1;')

        self.t = (tx, ty, tz)
        self.r = (rx, ry, rz)